I've got a weird situation that I can't seem to figure out. I'm trying to run a simple transformation on a xhtml document. I'm getting and error when I run it that states, " XTSE0340: XSLT Pattern syntax error at char 51 on line 12 in {...ors']/following-sibling::ta...}: Axis in pattern must be child or attribute" However, I've tested the XPath multiple times and everything looks good to me. It resolves on the document when I run it separately, but in the XSLT it fails. I'm running Saxon 8.9 using Stylus Studio, XSLT 2.0. I've tried it under a couple different processors, even 1.0 and still won't work. I cannot think of a reason why it would be requiring a child or attribute. What am I doing wrong?
The XPath in question that is failing is this.
Code:
font[descendant::text() = 'Consolidated Errors']/following-sibling::table[1]
The input document is as follows. (Sorry it's a bit long but I trimmed it down best I could)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:xs="http://www.w3.org/2001/XMLSchema">
<body>
<table cellpadding="2" cellspacing="0" border="1" width="80%" align="center">
<tr bgcolor="#C0C0C0">
<td>
<font face="Geneva,Arial">
<b>Line of Business</b>
</font>
</td>
<td>
<font face="Geneva,Arial">
<b>Total # of Messages</b>
</font>
</td>
<td>
<font face="Geneva,Arial">
<b># of Passed Messages</b>
</font>
</td>
<td>
<font face="Geneva,Arial">
<b># of Failed Messages</b>
</font>
</td>
<td>
<font face="Geneva,Arial">
<b>Total # of Errors in Failed Messages</b>
</font>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="1" width="98%" align="center" bgcolor="#000000">
<tr valign="top">
<td>
<table cellpadding="2" cellspacing="0" width="100%" bgcolor="#C0C0C0">
<tr valign="top">
<td width="200">
<font face="Geneva,Arial" size="-1">
<b>File (PolSymbol_SubmissionNo)</b>
</font>
</td>
<td width="40" align="right">
<font face="Geneva,Arial" size="-1">
<b>Line</b>
</font>
</td>
<td width="40" align="right">
<font face="Geneva,Arial" size="-1">
<b>Col</b>
</font>
</td>
<td>
<font face="Geneva,Arial" size="-1">
<b>Error</b>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<font face="Geneva,Arial">
<p align="center">
<b>
<u>Consolidated Errors</u>
</b>
</p>
</font>
<table cellpadding="0" cellspacing="1" width="98%" align="center" class="nested">
<th valign="top" colspan="4" align="left">
<font face="Geneva,Arial" size="3">Farm General Liability</font>
</th>
<tr>
<td align="center">
<font size="-2">
<b>Example</b>
</font>
</td>
<td>
<font size="-2">
<b>Line</b>
</font>
</td>
<td>
<font size="-2">
<b>Occurences</b>
</font>
</td>
<td>
<font size="-2">
<b>Error</b>
</font>
</td>
</tr>
<tr>
<td>
<font size="-1">AFL_5279884.xml</font>
</td>
<td>
<font size="-1">
<a href="files/AFL_5279884.html#l4920">4920</a>
</font>
</td>
<td align="center">
<font size="-1">1</font>
</td>
<td>
<font size="-1">Type 'agrifgl:ENT_Comment_Category_Type' that is used in xsi:type is not derived from the type of element 'Category'</font>
</td>
</tr>
</table>
</body>
</html>
And the full XSLT is below.
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<Errors>
<xsl:apply-templates select="//font[descendant::text() = 'Consolidated Errors']/following-sibling::table[1]"/>
</Errors>
</xsl:template>
<!-- This match fails -->
<xsl:template match="font[descendant::text() = 'Consolidated Errors']/following-sibling::table[1]">
<xsl:apply-templates select="tr[td[1]/font[contains(.,'xml')]]" />
</xsl:template>
</xsl:stylesheet>