[GeoNetwork-users] Extending profile - changing minOccurs of an existing element.

I want to extend ISO19139 schema so that some existing elements have more
strict minOccurs attributes: 1 instead of 0. For example, how to change the
minOccurs of gmd:MD_DataIdentification.pointOfContact element to 1?

I used this good manual
<http://geonetwork-opensource.org/manuals/2.8.0/eng/developer/schemaPlugins/index.html&gt;
and have thoroughlly worked through the example of creating the Marine
Community Profile
<http://geonetwork-opensource.org/manuals/2.8.0/eng/developer/schemaPlugins/index.html#example-iso19115-19139-marine-community-profile-mcp&gt;
schema plugin

I also tried to use mcp profile
<https://github.com/geonetwork/schema-plugins/blob/master/iso19139.mcp/schema/extensions/mcpExtensions.xsd&gt;
as a reference, and looking into others schema plugins also to find
something similar, but without any luck. All the schema plugins are only
extending - creating new elements. They do not seem to restrict any
occurrences of existing elements.

I read through the ISO19115 specs
<http://www.iso.org/iso/catalogue_detail.htm?csnumber=26020&gt; and the main
suggestion seems to be there, that a profile should, at first try to use
existing elements and, if needed, change the usage of these more strict.
Creating new elements would be as a last resort, when really no existing ISO
element will not suffice.

I also used Google and some XML books to find the answer and spent time on
trials-and-errors.

Since pointOfContact is originally a part of AbstractMD_Identification_Type,
then should I start extending from there? Seems quite unlikely that to
change
/<xs:element name="pointOfContact"
type="gmd:CI_ResponsibleParty_PropertyType" minOccurs="0"
maxOccurs="unbounded"/> /
to
/<xs:element name="pointOfContact"
type="gmd:CI_ResponsibleParty_PropertyType" minOccurs="1"
maxOccurs="unbounded"/>/
I need to write ca 60 lines of xml...

Does anyone have any ideas on how to do it? I would be very thankful!

My GN version is 2.8.0

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Extending-profile-changing-minOccurs-of-an-existing-element-tp5075858.html
Sent from the GeoNetwork users mailing list archive at Nabble.com.

I derived complexType by restriction as described here:
http://www.w3.org/TR/xmlschema-0/#DerivByRestrict

There has to exist gco:isoType attribute, so I extended the restricted
complexType with gco:isoType attribute.

Since pointOfContact is part of gmd:AbstractMD_Identification_Type I decided
to make things easier and just try to restrict something that is part of
gmd:MD_DataIdentification_Type -- I tried to set characterSet minOccurs to
1.

The result:

  <xs:complexType name="RestrictedMD_DataIdentification_Type">
    <xs:complexContent>
      <xs:restriction base="gmd:MD_DataIdentification_Type">
        <xs:sequence>
          <xs:element ref="gmd:spatialRepresentationType" minOccurs="0"
maxOccurs="unbounded"/>
          <xs:element ref="gmd:spatialResolution" minOccurs="0"
maxOccurs="unbounded"/>
          <xs:element ref="gmd:language" maxOccurs="unbounded"/>
          <xs:element ref="gmd:characterSet" minOccurs="1"
maxOccurs="unbounded"/>
          <xs:element ref="gmd:topicCategory" minOccurs="0"
maxOccurs="unbounded"/>
          <xs:element ref="gmd:environmentDescription" minOccurs="0"/>
          <xs:element ref="gmd:extent" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element ref="gmd:supplementalInformation" minOccurs="0"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:element name="MD_DataIdentification"
substitutionGroup="gmd:AbstractMD_Identification"
type="bmg:MD_DataIdentification_Type"/>

  <xs:complexType name="MD_DataIdentification_Type">
    <xs:complexContent>
      <xs:extension base="bmg:RestrictedMD_DataIdentification_Type">
        <xs:sequence>
        </xs:sequence>
        <xs:attribute ref="gco:isoType" use="required"
fixed="gmd:MD_DataIdentification"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="MD_DataIdentification_PropertyType">
    <xs:sequence minOccurs="0">
      <xs:element ref="bmg:MD_DataIdentification"/>
    </xs:sequence>
    <xs:attributeGroup ref="gco:ObjectReference"/>
    <xs:attribute ref="gco:nilReason"/>
  </xs:complexType>

When importing and validating metadata to this schema in geonetwork, I got
this error: /SAXParseException : src-resolve: Cannot resolve the name
'gmd:spatialRepresentationType' to a(n) 'element declaration' component./

I could not find any solution to that.

Thanks in advance for any help!

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Extending-profile-changing-minOccurs-of-an-existing-element-tp5075858p5076068.html
Sent from the GeoNetwork users mailing list archive at Nabble.com.

The solution was to make local elements global in ISO schema in the
extendable/restrictable element. This does not change the schema.
Creating local or global elements seems to be just a matter of choice and
style.

Here
<http://www.kohsuke.org/xmlschema/XMLSchemaDOsAndDONTs.html#avoid_local&gt;
is an example how to fix this (change local elements to global) and some
reasons on why not use local elements in the first place.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Extending-profile-changing-minOccurs-of-an-existing-element-tp5075858p5077086.html
Sent from the GeoNetwork users mailing list archive at Nabble.com.