Advertisement
Guest User

extract-gml.xsl

a guest
Jan 7th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.38 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:gmi="http://standards.iso.org/iso/19115/-2/gmi/1.0"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
  4. xmlns:gsr="http://www.isotc211.org/2005/gsr" xmlns:gco="http://www.isotc211.org/2005/gco"
  5. xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gss="http://www.isotc211.org/2005/gss"
  6. xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2"
  7. xmlns:srv="http://www.isotc211.org/2005/srv"  
  8. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  9.     <xsl:output method="xml" indent="no"/>
  10.     <xsl:template match="/" priority="2">
  11.         <gml:GeometryCollection >
  12.             <xsl:apply-templates/>
  13.         </gml:GeometryCollection>
  14.     </xsl:template>
  15.     <xsl:template match="*">
  16.         <xsl:apply-templates/>
  17.     </xsl:template>
  18.    
  19.     <xsl:template match="text()"/>
  20.    
  21.         <xsl:template match="gmd:EX_BoundingPolygon[string(gmd:extentTypeCode/gco:Boolean) != 'false' and string(gmd:extentTypeCode/gco:Boolean) != '0']" priority="2">
  22.             <xsl:for-each select="gmd:polygon/gml:*">
  23.                 <xsl:copy-of select="."/>
  24.             </xsl:for-each>
  25.     </xsl:template>
  26.  
  27.     <xsl:template match="gmd:EX_GeographicBoundingBox" priority="2">
  28.         <xsl:variable name="w" select="./gmd:westBoundLongitude/gco:Decimal/text()"/>
  29.         <xsl:variable name="e" select="./gmd:eastBoundLongitude/gco:Decimal/text()"/>
  30.         <xsl:variable name="n" select="./gmd:northBoundLatitude/gco:Decimal/text()"/>
  31.         <xsl:variable name="s" select="./gmd:southBoundLatitude/gco:Decimal/text()"/>
  32.             <xsl:if test="$w!='' and $e!='' and $n!='' and $s!=''">
  33.                 <gml:Polygon>
  34.                     <gml:exterior>
  35.                         <gml:LinearRing>
  36.                             <gml:posList srsDimension="2">
  37.                                 <xsl:value-of select="$w"/>&#160;<xsl:value-of select="$n"/>&#160;<xsl:value-of select="$e"/>&#160;<xsl:value-of select="$n"/>&#160;<xsl:value-of select="$e"/>&#160;<xsl:value-of select="$s"/>&#160;<xsl:value-of select="$w"/>&#160;<xsl:value-of select="$s"/>&#160;<xsl:value-of select="$w"/>&#160;<xsl:value-of select="$n"/>
  38.                             </gml:posList>
  39.                         </gml:LinearRing>
  40.                     </gml:exterior>
  41.                 </gml:Polygon>
  42.             </xsl:if>
  43.     </xsl:template>
  44. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement