D
disen
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
gr='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
gr="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
olygon"/>
</xsl:template>
...
The result is:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns
gr="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
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
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
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
</xsl:template>
...
The result is:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns
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