Reputation: 1037
I've been going through https://www.w3schools.com/xml/xsl_intro.asp and want to use the same process on my own data but I keep getting errors. What am I missing?
The XML is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<identifier>Z:/My Drive/Mangoesmapping/Spatial Projects/2019/DSC/132_Ongoing_Asset_Updates/Working/Sewerage_Updates/Sewerage_Manholes_InspectionShafts.TAB</identifier>
<parentidentifier>Sewerage Manhole Infrastructure</parentidentifier>
<keywords vocabulary="gmd:topicCategory">
<keyword>Infrastructure</keyword>
<keyword>Sewerage</keyword>
</keywords>
<keywords vocabulary="undefined 2">
<keyword>Sewerage</keyword>
</keywords>
<keywords vocabulary="undefined 3">
<keyword>Manholes</keyword>
</keywords>
<extent>
<spatial minx="322783.17999999999301508" minz="0" crs="EPSG:28355" maxx="337384.35999999998603016" miny="8170597.66000000014901161" maxz="0" dimensions="2" maxy="8181833.33999999985098839"/>
</extent>
The XSL is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<xsl:template match="/">
<html>
<body>
<h2><xsl:value-of select="identifier"/></h2>
<h2><xsl:value-of select="parentidentifier"/></h2>
<h1>Keywords: </h1>
<xsl:for-each select="//keywords">
<table style="width:100%;">
<tr>
<xsl:for-each select="keyword">
<td>
<xsl:value-of select="current()"/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:for-each>
<xsl:value-of select="//spatial/@maxx"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Views: 328
Reputation: 13006
I added root on your xml
<root>
<identifier>Z:/My Drive/Mangoesmapping/Spatial Projects/2019/DSC/132_Ongoing_Asset_Updates/Working/Sewerage_Updates/Sewerage_Manholes_InspectionShafts.TAB</identifier>
<parentidentifier>Sewerage Manhole Infrastructure</parentidentifier>
<keywords vocabulary="gmd:topicCategory">
<keyword>Infrastructure</keyword>
<keyword>Sewerage</keyword>
</keywords>
<keywords vocabulary="undefined 2">
<keyword>Sewerage</keyword>
</keywords>
<keywords vocabulary="undefined 3">
<keyword>Manholes</keyword>
</keywords>
<extent>
<spatial minx="322783.17999999999301508" minz="0" crs="EPSG:28355" maxx="337384.35999999998603016" miny="8170597.66000000014901161" maxz="0" dimensions="2" maxy="8181833.33999999985098839"/>
</extent>
</root>
And I tried to modify your xsl like this.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:template match="/">
<html>
<body>
<h2>
<xsl:value-of select="identifier"/>
</h2>
<h2>
<xsl:value-of select="parentidentifier"/>
</h2>
<h1>Keywords: </h1>
<xsl:for-each select="//keywords">
<table style="width:100%;">
<tr>
<xsl:for-each select="keyword">
<td>
<xsl:value-of select="current()"/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:for-each>
<xsl:value-of select="//spatial/@maxx"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
And everything is working fine.
Upvotes: 1