Index: perl_lib/EPrints/MetaField/Compound.pm =================================================================== --- perl_lib/EPrints/MetaField/Compound.pm (revision 4411) +++ perl_lib/EPrints/MetaField/Compound.pm (working copy) @@ -514,7 +514,11 @@ foreach my $field (@{$self->{fields_cache}}) { my $name = $field->{sub_name}; - my $element = $session->make_element( "xs:element", name => $name, type => $field->get_xml_schema_type() ); + my $element = $session->make_element( "xs:element", + name => $name, + type => $field->get_xml_schema_type(), + minOccurs => 0 + ); $sequence->appendChild( $element ); } Index: perl_lib/EPrints/MetaField/Set.pm =================================================================== --- perl_lib/EPrints/MetaField/Set.pm (revision 4410) +++ perl_lib/EPrints/MetaField/Set.pm (working copy) @@ -568,6 +568,14 @@ my( $tags, $labels ) = $self->tags_and_labels( $session ); + # Allow Set fields to have no value. This weakens the + # constraints applied by the schema but is an approach that + # works for the baseline scenario, that is, optional Set + # fields that may have been left unspecified where only weak + # constraints can be applied. + push @{$tags}, ''; + $labels->{''} = $session->phrase( 'lib/metafield:unspecified' ); + my $restriction = $session->make_element( "xs:restriction", base => "xs:string" ); $type->appendChild( $restriction ); foreach my $value (@$tags) Index: perl_lib/EPrints/MetaField/Base64.pm =================================================================== --- perl_lib/EPrints/MetaField/Base64.pm (revision 4410) +++ perl_lib/EPrints/MetaField/Base64.pm (working copy) @@ -74,5 +74,51 @@ return $tag; } +sub get_xml_schema_type +{ + my( $self ) = @_; + + return $self->get_property( "type" ) . "_" . $self->{dataset}->confid . "_" . $self->get_name; +} + +sub render_xml_schema_type +{ + my( $self, $session ) = @_; + + # Returns DOM for the following: + # + # + # + # + # + # + # + # + # + # + # + # + # + + my $type = $session->make_element( 'xs:complexType', name => $self->get_xml_schema_type ); + my $sc = $session->make_element( 'xs:simpleContent' ); + my $ext = $session->make_element( 'xs:extension', base => 'xs:base64Binary' ); + + # encoding attribute + my $encoding = $session->make_element( 'xs:attribute', name => 'encoding' ); + my $enc_type = $session->make_element( 'xs:simpleType' ); + my $enc_restr = $session->make_element( 'xs:restriction', base => 'xs:string' ); + my $enc_enum = $session->make_element( 'xs:enumeration', value => 'base64' ); + + $enc_restr->appendChild( $enc_enum ); + $enc_type->appendChild( $enc_restr ); + $encoding->appendChild( $enc_type ); + $ext->appendChild( $encoding ); + $sc->appendChild( $ext ); + $type->appendChild( $sc ); + + return $type; +} + ###################################################################### 1;