I am trying to do a match for two scenarios:
- String contains character other than just a number
- String has more than 8 characters.
So the XSLT is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="record[translate(employeeNumber, 'abcdefghijklmnopqrstuvwxyzABCDEFGHILKLMNOIPQRSTUVWXYZ!£$%^', '')]"/>
<xsl:template match="record[string-length(employeeNumber) < 9]"/>
</xsl:stylesheet>
Test Data is:
<?xml version="1.0" encoding="UTF-8"?>
<request>
<records>
<record>
<employeeNumber>12345678</employeeNumber>
</record>
<record>
<employeeNumber>1234567A</employeeNumber>
</record>
<record>
<employeeNumber>12345678A</employeeNumber>
</record>
<record>
<employeeNumber>123456789</employeeNumber>
</record>
</records>
</request>
This is what should be returned:
<?xml version="1.0" encoding="UTF-8"?>
<request>
<records>
<record>
<employeeNumber>1234567A</employeeNumber>
</record>
<record>
<employeeNumber>12345678A</employeeNumber>
</record>
<record>
<employeeNumber>123456789</employeeNumber>
</record>
</records>
</request>
However as i said in Oxygen i am getting the error:
Severity: warning
Description: Ambiguous rule match for /request[1]/records[1]/record[1]
Matches both "record[string-length(employeeNumber) < 9]" on line 13 of file:/C:/Users/mdown/Desktop/Untitled21.xsl
and "record[translate(employeeNumber, 'abcdefghijklmnopqrstuvwxyzABCDEFGHILKLMNOIPQRSTUVWXYZ!£$%^', '')]" on line 12 of file:/C:/Users/mdown/Desktop/Untitled21.xsl
The reason for this is because it is matching both rules, however this should not be a problem. How would i alter the XSLT to support these options.
It looks to me as if you are getting a warning, not an error. If you want to avoid the warning then decide which template should have higher priority and set that e.g.
<xsl:template match="foo" priority="5"/>as needed.