Reputation: 375
I have the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<wcs:CoverageDescriptions xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:ows="http://www.opengis.net/ows/2.0" xmlns:swe="http://www.opengis.net/swe/2.0" xmlns:wcs="http://www.opengis.net/wcs/2.0" xmlns:wcsgs="http://www.geoserver.org/wcsgs/2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.opengis.net/wcs/2.0 http://schemas.opengis.net/wcs/2.0/wcsDescribeCoverage.xsd">
<wcs:CoverageDescription gml:id="AOI" xmlns="http://www.opengis.net/gml/3.2" xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:swe="http://www.opengis.net/swe/2.0">
<boundedBy>
<Envelope axisLabels="DATE E N" srsDimension="3" srsName="http://localhost:8080/def/crs-compound?1=http://localhost:8080/def/crs/OGC/0/UnixTime?axis-label="DATE"&2=http://localhost:8080/def/crs/EPSG/0/32630" uomLabels="s metre metre">
<lowerCorner>"2012-05-09T00:00:00.000Z" 210417 4096350</lowerCorner>
<upperCorner>"2013-11-28T00:00:00.000Z" 230417 4116350</upperCorner>
</Envelope>
</boundedBy>
<wcs:CoverageId>AOI</wcs:CoverageId>
<coverageFunction>
<GridFunction>
<sequenceRule axisOrder="+1 +3 +2">Linear</sequenceRule>
<startPoint>0 0 0</startPoint>
</GridFunction>
</coverageFunction>
</wcs:CoverageDescription>
</wcs:CoverageDescriptions>
and I would like to extract the info in the tag lowerCorner (as well as upperCorner) and sequenceRule. I'm using the following xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<!-- TODO: Auto-generated template -->
<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<gmi:MI_Metadata xmlns:gmi="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:gss="http://www.isotc211.org/2005/gss" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" gco:isoType="gmd:MD_Metadata" xsi:schemaLocation="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi/gmi.xsd" xmlns:wcs="http://www.opengis.net/wcs/2.0" xmlns:wcsgs="http://www.geoserver.org/wcsgs/2.0" xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:ows="http://www.opengis.net/ows/2.0" xmlns:swe="http://www.opengis.net/swe/2.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<gmd:extent>
<gmd:EX_Extent>
<gmd:temporalElement>
<gmd:EX_TemporalExtent>
<gmd:extent>
<gml:TimePeriod gml:id="d1e468a1049886">
<gml:beginPosition>
<xsl:for-each select="//Envelope">
<xsl:variable name="my_lowerCorner" select="substring-before(lowerCorner, ' ')" />
<xsl:value-of select="substring($my_lowerCorner,1,19)" />
</xsl:for-each>
<covFunction><xsl:value-of select="//coverageFunction/GridFunction/sequenceRule"/><\covFunction>
</gml:beginPosition>
</gml:TimePeriod>
</gmd:extent>
</gmd:EX_TemporalExtent>
</gmd:temporalElement>
</gmd:EX_Extent>
</gmd:extent>
</gmi:MI_Metadata>
</xsl:template>
</xsl:stylesheet>
But I'm getting empty output. Could you please tell me what I'm doing wrong?
Upvotes: 0
Views: 183
Reputation: 3247
There is a default namespace xmlns="http://www.opengis.net/gml/3.2"
associated with <CoverageDescription>
. This namespace is not mapped in the XSLT.
<wcs:CoverageDescription gml:id="AOI" xmlns="http://www.opengis.net/gml/3.2"
xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:swe="http://www.opengis.net/swe/2.0">
After mapping the namespace in XSLT xmlns:tmp="http://www.opengis.net/gml/3.2"
and associating the elements correctly, the values are received in output.
<xsl:for-each select="//tmp:Envelope">
<xsl:value-of select="substring(substring-before(tmp:lowerCorner, ' '),1,19)" />
</xsl:for-each>
<covFunction>
<xsl:value-of select="//tmp:coverageFunction/tmp:GridFunction/tmp:sequenceRule" />
</covFunction>
Below is the complete XSLT.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gmi="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml"
xmlns:gss="http://www.isotc211.org/2005/gss" xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd" gco:isoType="gmd:MD_Metadata"
xsi:schemaLocation="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi/gmi.xsd"
xmlns:wcs="http://www.opengis.net/wcs/2.0" xmlns:wcsgs="http://www.geoserver.org/wcsgs/2.0"
xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:ows="http://www.opengis.net/ows/2.0"
xmlns:swe="http://www.opengis.net/swe/2.0" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:tmp="http://www.opengis.net/gml/3.2">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<gmi:MI_Metadata >
<gmd:extent>
<gmd:EX_Extent>
<gmd:temporalElement>
<gmd:EX_TemporalExtent>
<gmd:extent>
<gml:TimePeriod gml:id="d1e468a1049886">
<gml:beginPosition>
<xsl:for-each select="//tmp:Envelope">
<xsl:value-of select="substring(substring-before(tmp:lowerCorner, ' '),1,19)" />
</xsl:for-each>
<covFunction>
<xsl:value-of select="//tmp:coverageFunction/tmp:GridFunction/tmp:sequenceRule" />
</covFunction>
</gml:beginPosition>
</gml:TimePeriod>
</gmd:extent>
</gmd:EX_TemporalExtent>
</gmd:temporalElement>
</gmd:EX_Extent>
</gmd:extent>
</gmi:MI_Metadata>
</xsl:template>
</xsl:stylesheet>
Output
<gmi:MI_Metadata xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:swe="http://www.opengis.net/swe/2.0"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gss="http://www.isotc211.org/2005/gss"
xmlns:tmp="http://www.opengis.net/gml/3.2" xmlns:wcs="http://www.opengis.net/wcs/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/2.0"
xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" xmlns:gml="http://www.opengis.net/gml"
xmlns:gmi="http://sdi.eurac.edu/metadata/iso19139-2/schema/gmi"
xmlns:wcsgs="http://www.geoserver.org/wcsgs/2.0">
<gmd:extent>
<gmd:EX_Extent>
<gmd:temporalElement>
<gmd:EX_TemporalExtent>
<gmd:extent>
<gml:TimePeriod gml:id="d1e468a1049886">
<gml:beginPosition>
"2012-05-09T00:00:0
<covFunction>Linear</covFunction>
</gml:beginPosition>
</gml:TimePeriod>
</gmd:extent>
</gmd:EX_TemporalExtent>
</gmd:temporalElement>
</gmd:EX_Extent>
</gmd:extent>
</gmi:MI_Metadata>
Upvotes: 1