Hi
I have an XML documnet and a XSLT document as shown below
THe XSLT document brings back a filtered docmument that has the VendorName
that starts with a particular sub-string
This works as expected with alphabet and number characters and the ' (single
quote ' entity) character but does not work if a double quote character
" is part of the string to filter on
This returns all Vendor Names that begin with A (either case)
The XML Document
<?xml-stylesheet type="text/xsl" href="C:\XSL1.x sl"?>
<NEXXML xmlns:sql="urn: schemas-microsoft-com:xml-sql">
<columns/>
<rows>
<row SAPVendorRef="1 5001" VendorName="A&q uot; A Meats" EntityId="3021"
rsposition="1"/>
<row SAPVendorRef="5 7232" VendorName="Abb eyhouse Foods" EntityId="3050"
rsposition="2"/>
<row SAPVendorRef="1 5011" VendorName="Ale xandra Rentals" EntityId="3023"
rsposition="3"/>
<row SAPVendorRef="1 0184" VendorName="Ale xandra Workwear PLC"
EntityId="3014" rsposition="4"/>
<row SAPVendorRef="1 5012" VendorName="All ied Bakeries NI" EntityId="3024"
rsposition="5"/>
<row SAPVendorRef="6 0143" VendorName="Ast ron On Line" EntityId="3056"
rsposition="6"/>
<row SAPVendorRef="5 6531" VendorName="Bac kgammo'n" EntityId="3048"
rsposition="7"/>
<row SAPVendorRef="1 5062" VendorName="Bri tish Bakeries NI" EntityId="3025"
rsposition="8"/>
</rows>
</NEXXML>
The XSLT Document
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:sql="urn: schemas-microsoft-com:xml-sql">
<xsl:output method="xml"/>
<xsl:template match="/">
<NEXXML>
<rows>
<xsl:apply-templates/>
</rows>
</NEXXML>
</xsl:template>
<xsl:template match="rows">
<xsl:apply-templates select="row"/>
</xsl:template>
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"," abcdefghijklmno pqrstuvwxyz&quo t
;,"ABCDEFG HIJKLMNOPQRSTUV WXYZ")) ]">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
If I want to search on the string A" the line
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"," abcdefghijklmno pqrstuvwxyz&quo t
;,"ABCDEFG HIJKLMNOPQRSTUV WXYZ")) ]">
<xsl:copy-of select="."/>
changes to:
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"", "abcdefghi jklmnopqrstuvwx y
z","A BCDEFGHIJKLMNOP QRSTUVWXYZ" ;)) ]">
<xsl:copy-of select="."/>
I now get an error Expected token ')' found 'STRING'
From what I can see, this is because the XML parser reads the translate
function intereprets the 1st " as the start of the first argument and
interprets the 2nd " as the end of the 1st argument, instead of being
part of the first argument and then expects a comma (,) and the second
string argument
How I can make the parser take the 2nd quote as part of the first string
argument if there is a quote in the 1st argument
I know I could probably do this by replacing the double quotes with single
quotes but then I am assumming I will get the same problem with single
quotes been part of the literal string.
Your help is greatly appreciated. Thanks in advance
Regards David Furey
I have an XML documnet and a XSLT document as shown below
THe XSLT document brings back a filtered docmument that has the VendorName
that starts with a particular sub-string
This works as expected with alphabet and number characters and the ' (single
quote ' entity) character but does not work if a double quote character
" is part of the string to filter on
This returns all Vendor Names that begin with A (either case)
The XML Document
<?xml-stylesheet type="text/xsl" href="C:\XSL1.x sl"?>
<NEXXML xmlns:sql="urn: schemas-microsoft-com:xml-sql">
<columns/>
<rows>
<row SAPVendorRef="1 5001" VendorName="A&q uot; A Meats" EntityId="3021"
rsposition="1"/>
<row SAPVendorRef="5 7232" VendorName="Abb eyhouse Foods" EntityId="3050"
rsposition="2"/>
<row SAPVendorRef="1 5011" VendorName="Ale xandra Rentals" EntityId="3023"
rsposition="3"/>
<row SAPVendorRef="1 0184" VendorName="Ale xandra Workwear PLC"
EntityId="3014" rsposition="4"/>
<row SAPVendorRef="1 5012" VendorName="All ied Bakeries NI" EntityId="3024"
rsposition="5"/>
<row SAPVendorRef="6 0143" VendorName="Ast ron On Line" EntityId="3056"
rsposition="6"/>
<row SAPVendorRef="5 6531" VendorName="Bac kgammo'n" EntityId="3048"
rsposition="7"/>
<row SAPVendorRef="1 5062" VendorName="Bri tish Bakeries NI" EntityId="3025"
rsposition="8"/>
</rows>
</NEXXML>
The XSLT Document
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:sql="urn: schemas-microsoft-com:xml-sql">
<xsl:output method="xml"/>
<xsl:template match="/">
<NEXXML>
<rows>
<xsl:apply-templates/>
</rows>
</NEXXML>
</xsl:template>
<xsl:template match="rows">
<xsl:apply-templates select="row"/>
</xsl:template>
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"," abcdefghijklmno pqrstuvwxyz&quo t
;,"ABCDEFG HIJKLMNOPQRSTUV WXYZ")) ]">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
If I want to search on the string A" the line
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"," abcdefghijklmno pqrstuvwxyz&quo t
;,"ABCDEFG HIJKLMNOPQRSTUV WXYZ")) ]">
<xsl:copy-of select="."/>
changes to:
<xsl:template match="row[ starts-with(translate(
@VendorName,&qu ot;abcdefghijkl mnopqrstuvwxyz& quot;,"ABC DEFGHIJKLMNOPQR S
TUVWXYZ"), translate(" ;A"", "abcdefghi jklmnopqrstuvwx y
z","A BCDEFGHIJKLMNOP QRSTUVWXYZ" ;)) ]">
<xsl:copy-of select="."/>
I now get an error Expected token ')' found 'STRING'
From what I can see, this is because the XML parser reads the translate
function intereprets the 1st " as the start of the first argument and
interprets the 2nd " as the end of the 1st argument, instead of being
part of the first argument and then expects a comma (,) and the second
string argument
How I can make the parser take the 2nd quote as part of the first string
argument if there is a quote in the 1st argument
I know I could probably do this by replacing the double quotes with single
quotes but then I am assumming I will get the same problem with single
quotes been part of the literal string.
Your help is greatly appreciated. Thanks in advance
Regards David Furey
Comment