I'm trying to transform the following HTML code, but having problems with getting the values needed and using the substring function for the XSLT. This is part of the HTML code that I'm trying to transform:
<th scope="row">2005DEC</th>
<td>2,757</td>
to the following XML code:
<?xml version="1.0"?>
<Original>
<Entry>
<Year>2005</Year>
<Month>DEC</Month>
<Age>
<Group>
<value>90</value>
</Group>
</Age>
</Entry>
</Original>
I'm trying to run the XSLT query, but it keeps getting an error. My XSLT is:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<Original>
<xsl:for-each select="@scope=row">
<Entry>
<Year>
<xsl:value-of select="substring(@scope=row, 1, 4)"/>
</Year>
<Month>
<xsl:value-of select="substring(@scope=row, 5, 3)"/>
</Month>
<Age>
<Group>
<value>
<xsl:value-of select="td[1]"/>
</value>
</Group>
</Age>
</Entry>
</xsl:for-each>
</Original>
</xsl:template>
</xsl:stylesheet>
The error is:
Ivans-MacBook-Pro:xslt-test ivanteong$ java -jar saxon9he.jar table823.html table823.xslt > out.xml
Error at xsl:value-of on line 13 column 73 of table823.xslt:
XPTY0004: Required item type of first argument of substring() is xs:string; supplied value
has item type xs:boolean
Error at xsl:value-of on line 16 column 73 of table823.xslt:
XPTY0004: Required item type of first argument of substring() is xs:string; supplied value
has item type xs:boolean
Failed to compile stylesheet. 2 errors detected.