<?xml version="1.0" encoding="UTF-8"?>
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema"
    xmlns:ogc="http://www.opengis.net/ogc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.geotools.org/app-schema
  http://ogc.bgs.ac.uk/mapping/AppSchemaDataAccess.xsd">
    <namespaces>
        <Namespace>
            <prefix>er</prefix>
            <uri>http://xmlns.earthresourceml.org/EarthResource/2.0</uri>
        </Namespace>
        <Namespace>
            <prefix>gml</prefix>
            <uri>http://www.opengis.net/gml/3.2</uri>
        </Namespace>
        <Namespace>
            <prefix>gsml</prefix>
            <uri>http://xmlns.geosciml.org/GeoSciML-Core/3.2</uri>
        </Namespace>
        <Namespace>
            <prefix>xlink</prefix>
            <uri>http://www.w3.org/1999/xlink</uri>
        </Namespace>
        <Namespace>
            <prefix>swe</prefix>
            <uri>http://www.opengis.net/swe/2.0</uri>
        </Namespace>
        <Namespace>
            <prefix>xsi</prefix>
            <uri>http://www.w3.org/2001/XMLSchema-instance</uri>
        </Namespace>
    </namespaces>
    <includedTypes>
<!--        <Include>er_Resource.xml</Include>
        <Include>er_Reserve.xml</Include>
        <Include>er_CommodityMeasure.xml</Include>-->
    </includedTypes>
    <sourceDataStores>
        <DataStore>
            <id>datastore</id>
            <parameters>
                <Parameter>
                    <name>dbtype</name>
                    <value>Oracle</value>
                </Parameter>
                <Parameter>
                    <name>jndiReferenceName</name>
                    <value>jdbc/earthresource-ora</value>
                </Parameter>
                <Parameter>
                    <name>schema</name>
                    <value>MSEXTON1</value>
                </Parameter>
                <Parameter>
                    <name>Expose primary keys</name>
                    <value>true</value>
                </Parameter>
            </parameters>
        </DataStore>
    </sourceDataStores>
    <targetTypes>
        <FeatureType>
            <schemaUri>
                http://schemas.earthresourceml.org/2.0/earthresourceml.xsd 
            </schemaUri>
        </FeatureType>
    </targetTypes>
    <typeMappings>
        <FeatureTypeMapping>
            <sourceDataStore>datastore</sourceDataStore>
            <sourceType>MV_ER_MINERALOCCURRENCE</sourceType>
            <targetElement>er:MineralOccurrence</targetElement>

            <attributeMappings>
                <AttributeMapping>
                    <targetAttribute>er:MineralOccurrence</targetAttribute>
                    <idExpression>
                        <OCQL>GML_ID</OCQL>
                    </idExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gml:identifier</targetAttribute>
                    <sourceExpression>
                        <OCQL>IDENTIFIER</OCQL>
                    </sourceExpression>
                    <ClientProperty>
                        <name>codeSpace</name>
                        <value>IDENTIFIER_CODESPACE</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gml:name</targetAttribute>
                    <sourceExpression>
                        <OCQL>NAME</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:observationMethod/swe:Category</targetAttribute>
                    <ClientProperty>
                        <name>definition</name>
                        <value>OBSERVATIONMETHOD_DEF</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:observationMethod/swe:Category/swe:label</targetAttribute>
                    <sourceExpression>
                        <OCQL>OBSERVATIONMETHOD</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:observationMethod/swe:Category/swe:identifier</targetAttribute>
                    <sourceExpression>
                        <OCQL>OBSERVATIONMETHOD_ID</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:purpose</targetAttribute>
                    <sourceExpression>
                        <OCQL>PURPOSE</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:parent</targetAttribute>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>if_then_else(isNull(PARENT_IDENTIFIER), 'http://www.opengis.net/def/nil/OGC/0/inapplicable', PARENT_IDENTIFIER)</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:title</name>
                        <value>PARENT_TITLE</value>
                    </ClientProperty>
                </AttributeMapping>


                <AttributeMapping>
                    <targetAttribute>er:child</targetAttribute>
                    <sourceExpression>
                        <OCQL>CHILDREN_PARENT</OCQL>
                        <linkElement>er:MineralOccurrence</linkElement>
                        <linkField>FEATURE_LINK[1]</linkField>
                    </sourceExpression>
                </AttributeMapping>



               <!-- <AttributeMapping>
                    <targetAttribute>er:child</targetAttribute>
                    <sourceExpression>
                        <OCQL>ENO</OCQL>
                        <linkElement>er:MineralOccurrence</linkElement>
                        <linkField>FEATURE_LINK[1]</linkField>
                    </sourceExpression>
                    <isMultiple>true</isMultiple>
                    <encodeIfEmpty>true</encodeIfEmpty>
                </AttributeMapping>-->
                <AttributeMapping>
                    <targetAttribute>FEATURE_LINK[1]</targetAttribute>
                    <sourceExpression>
                        <OCQL>PARENT</OCQL>
                    </sourceExpression>
                </AttributeMapping>
             <!--   <AttributeMapping>
                    <targetAttribute>er:child</targetAttribute>
                    <isMultiple>true</isMultiple>
                    <ClientProperty>
                        <name>xlink:title</name>
                        <value>CHILD_TITLE</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>if_then_else(isNull(CHILD_IDENTIFIER), 'http://www.opengis.net/def/nil/OGC/0/inapplicable', CHILD_IDENTIFIER)</value>
                    </ClientProperty>

                </AttributeMapping>-->
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature</targetAttribute>
                    <ClientProperty>
                        <name>gml:id</name>
                        <value>MF_GML_ID</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:observationMethod/swe:Category</targetAttribute>
                    <ClientProperty>
                        <name>definition</name>
                        <value>MF_OBSERVATIONMETHOD_DEF</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:observationMethod/swe:Category/swe:label</targetAttribute>
                    <sourceExpression>
                        <OCQL>MF_OBSERVATIONMETHOD</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:observationMethod/swe:Category/swe:identifier</targetAttribute>
                    <sourceExpression>
                        <OCQL>MF_OBSERVATIONMETHOD_ID</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:positionalAccuracy/swe:Quantity/swe:uom</targetAttribute>
                    <ClientProperty>
                        <name>code</name>
                        <value>MF_UOM_CODE</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>MF_UOM_HREF</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:title</name>
                        <value>MF_UOM_TITLE</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:positionalAccuracy/swe:Quantity/swe:value</targetAttribute>
                    <sourceExpression>
                        <OCQL>MF_POSITIONALACCURACY</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:resolutionScale</targetAttribute>
                    <sourceExpression>
                        <value>MF_RESOLUTIONSCALE</value>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:samplingFrame</targetAttribute>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>MF_SAMPLINGFRAME</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:shape</targetAttribute>
                    <idExpression>
                        <OCQL>MF_SHAPE_ID</OCQL>
                    </idExpression>
                    <sourceExpression>
                        <OCQL>MF_SHAPE</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:specification</targetAttribute>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>MF_SPECIFICATION</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:occurrence/gsml:MappedFeature/gsml:metadata</targetAttribute>
                    <sourceExpression>
                        <OCQL>MF_METADATA</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:relatedFeature</targetAttribute>
                    <sourceExpression>
                        <OCQL>RELATEDFEATURE</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:classifier</targetAttribute>
                    <sourceExpression>
                        <OCQL>CLASSIFIER</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>gsml:metadata</targetAttribute>
                    <sourceExpression>
                        <OCQL>METADATA</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:explorationHistory</targetAttribute>
                    <sourceExpression>
                        <OCQL>EXPLORATIONHISTORY</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:beginLifespanVersion</targetAttribute>
                    <sourceExpression>
                        <OCQL>BEGINLIFESPANVERSION</OCQL>
                    </sourceExpression>

                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:endLifespanVersion</targetAttribute>
                    <sourceExpression>
                        <OCQL>ENDLIFESPANVERSION</OCQL>
                    </sourceExpression>

                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:dimension</targetAttribute>
                    <sourceExpression>
                        <OCQL>DIMENSION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:expression</targetAttribute>
                    <sourceExpression>
                        <OCQL>EXPRESSION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:form</targetAttribute>
                    <sourceExpression>
                        <OCQL>FORM</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:linearOrientation</targetAttribute>
                    <sourceExpression>
                        <OCQL>LINEARORIENTATION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:planarOrientation</targetAttribute>
                    <sourceExpression>
                        <OCQL>PLANARORIENTATION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:shape</targetAttribute>
                    <sourceExpression>
                        <OCQL>SHAPE</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:composition</targetAttribute>
                    <sourceExpression>
                        <OCQL>COMPOSITION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:oreAmount</targetAttribute>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>'http://www.opengis.net/def/nil/OGC/0/inapplicable'</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:commodityDescription</targetAttribute>
                   <!-- <sourceExpression>
                        <OCQL>ENO</OCQL>
                        <linkElement>er:Commodity</linkElement>
                        <linkField>FEATURE_LINK[4]</linkField>
                    </sourceExpression>
                    <isMultiple>true</isMultiple>
                    <encodeIfEmpty>true</encodeIfEmpty>-->

                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>'http://www.opengis.net/def/nil/OGC/0/inapplicable'</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:type</targetAttribute>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>TYPE_HREF</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:title</name>
                        <value>TYPE_TITLE</value>
                    </ClientProperty>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:sourceReference</targetAttribute>
                    <isMultiple>true</isMultiple>
                    <ClientProperty>
                        <name>xlink:href</name>
                        <value>SOURCEREF_HREF</value>
                    </ClientProperty>
                    <ClientProperty>
                        <name>xlink:title</name>
                        <value>SOURCEREF_TITLE</value>
                    </ClientProperty>

                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:resourceExtraction</targetAttribute>
                    <sourceExpression>
                        <OCQL>RESOURCEEXTRACTION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:classification</targetAttribute>
                    <sourceExpression>
                        <OCQL>CLASSIFICATION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:supergeneModification</targetAttribute>
                    <sourceExpression>
                        <OCQL>SUPERGENEMODIFICATION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:geneticDescription</targetAttribute>
                    <sourceExpression>
                        <OCQL>GENETICDESCRIPTION</OCQL>
                    </sourceExpression>
                </AttributeMapping>
                <AttributeMapping>
                    <targetAttribute>er:endusePotential</targetAttribute>
                    <sourceExpression>
                        <OCQL>ENDUSEPOTENTIAL</OCQL>
                    </sourceExpression>
                </AttributeMapping>
            </attributeMappings>
        </FeatureTypeMapping>
    </typeMappings>
</as:AppSchemaDataAccess>