xsltParanthelessAlternative - aleksei-khitev/knowledge_base GitHub Wiki
При записи вида (VAL| ANOTHER.VAL)
ругается на скобки
Error at xsl:template on line 149 column 155 of some.xsl:
XTSE0340 XSLT Pattern syntax error at char 0 on line 149 in {(VAL}:
Parentheses are not allowed in an XSLT 2.0 pattern
...
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 3 errors detected.
Как вариант решения, можно (VAL| ANOTHER.VAL)
заменить на *[self::VAL| self::ANOTHER.VAL]
Как в примере
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<VAL>
<country>ANNEX</country>
<company>Columbia</company>
</VAL>
<ANOTHER.VAL>
<country>CONS.ANNEX</country>
<company>CBS Records</company>
</ANOTHER.VAL>
<VAL>
<country>ANNEX</country>
<company>RCA</company>
</VAL>
</catalog>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Current Tickets</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Key</th>
<th>Name</th>
</tr>
<xsl:for-each select="catalog/*[self::VAL| self::ANOTHER.VAL]">
<tr>
<td><xsl:value-of select="country"/></td>
<td><xsl:value-of select="company"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>