Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


newbie xslt namespace question

From: disen@---.-----.-- (-----)
To: NULL
Date: 1/3/2005 10:24:00 AM
Hi,
i try to generate from a gml-file (geography markup language) an
svg-file using java (xalan) (i'm using java 1.4.2)

My problem is now dealing with namespaces in xslt (at least this is
what i guess).

the gml-file looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<ogr:FeatureCollection xmlns:gml='http://www.opengis.net/gml'
xmlns:xsi='http://www.w3c.org/2001/XMLSchema-instance'
xmlns:ogr='http://ogr.maptools.org/'
xmlns='http://gdal.velocet.ca/ogr'
xsi:schemaLocation='http://gdal.velocet.ca/ogr defol.xsd'>
  ...
  <gml:featureMember>
    <defol>
      <cat>1</cat>
      <area>2668790.35979</area>
      <perimeter>8356.95744649</perimeter>
      <sites_for_>2</sites_for_>
      <sites_for1>1</sites_for1>
      <site_id>10</site_id>
      <oid_>2</oid_>
      <objectid>59</objectid>
      <site_id_1>10</site_id_1>
      <ogr:geometryProperty>
           <gml:coordinates>796418.625,...


the xsl-file:
<?xml version="1.0" encoding="ISO-8859-1"?>
  <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogr="http://gdal.velocet.ca/ogr"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <!-- root template -->
   <xsl:template match="/">
      <svg width="400" height="400">
         <g>
           <xsl:apply-templates />
         </g>
      </svg>
    </xsl:template>
    ....
    
    
    <!-- toplevel template -->
    <xsl:template match="gml:featureMember">
      test1
      <xsl:apply-templates select="ogr:defol"/> 
    </xsl:template> 

    <!-- named templates -->
    <!-- namespaces, also the default ns, must be given explicitely
-->
    <xsl:template match="ogr:defol">
      test2
      <xsl:apply-templates select="ogr:geometryProperty"/> 
      <xsl:apply-templates select="ogr:site_id"/> 
      <xsl:apply-templates select="ogr:cat"/> 
    </xsl:template> 

    <xsl:template match="ogr:cat">
      cat = <xsl:value-of select="."/>
    </xsl:template>

    <xsl:template match="ogr:geometryProperty">
      test3
      <xsl:apply-templates select="gml:Polygon"/> 
    </xsl:template>
    ...

The result is:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ogr="http://gdal.velocet.ca/ogr"
xmlns:gml="http://www.opengis.net/gml" height="400" width="400"><g>
  
  
      test1
      
      test2
      
      cat = 1
</g></svg>


the problem i have now is that the element ogr:geometryProperty is not
matched by the template. The problem seems to be the ogr-prefix (which
is the default namespace in the gml-file).

Any ideas? 
Thanx very much in advance

Dani


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent