Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help example does not Filter for strings that have "

Status
Not open for further replies.

dfurey16

Programmer
Jun 24, 2003
2
GB
Hi, I have an XML document and a XSLT document

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)

XML Document


<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;C:\XSL1.xsl&quot;?>
<NEXXML xmlns:sql=&quot;urn:schemas-microsoft-com:xml-sql&quot;>
<columns/>
<rows>
<row SAPVendorRef=&quot;15001&quot; VendorName=&quot;A&quot; A Meats&quot; EntityId=&quot;3021&quot; rsposition=&quot;1&quot;/>
<row SAPVendorRef=&quot;57232&quot; VendorName=&quot;Abbeyhouse Foods&quot; EntityId=&quot;3050&quot; rsposition=&quot;2&quot;/>
<row SAPVendorRef=&quot;15011&quot; VendorName=&quot;Alexandra Rentals&quot; EntityId=&quot;3023&quot; rsposition=&quot;3&quot;/>
<row SAPVendorRef=&quot;10184&quot; VendorName=&quot;Alexandra Workwear PLC&quot; EntityId=&quot;3014&quot; rsposition=&quot;4&quot;/>
<row SAPVendorRef=&quot;15012&quot; VendorName=&quot;Allied Bakeries NI&quot; EntityId=&quot;3024&quot; rsposition=&quot;5&quot;/>
<row SAPVendorRef=&quot;60143&quot; VendorName=&quot;Astron On Line&quot; EntityId=&quot;3056&quot; rsposition=&quot;6&quot;/>
<row SAPVendorRef=&quot;56531&quot; VendorName=&quot;Backgammo'n&quot; EntityId=&quot;3048&quot; rsposition=&quot;7&quot;/>
<row SAPVendorRef=&quot;15062&quot; VendorName=&quot;British Bakeries NI&quot; EntityId=&quot;3025&quot; rsposition=&quot;8&quot;/>
</rows>
</NEXXML>


XSLT Document

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; xmlns:fo=&quot; xmlns:sql=&quot;urn:schemas-microsoft-com:xml-sql&quot;>
<xsl:eek:utput method=&quot;xml&quot;/>
<xsl:template match=&quot;/&quot;>
<NEXXML>
<rows>
<xsl:apply-templates/>
</rows>
</NEXXML>
</xsl:template>
<xsl:template match=&quot;rows&quot;>
<xsl:apply-templates select=&quot;row&quot;/>
</xsl:template>
<xsl:template match=&quot;row[ starts-with(translate( @VendorName,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]&quot;>
<xsl:copy-of select=&quot;.&quot;/>
</xsl:template>
</xsl:stylesheet>


If I want to search on the string A&quot; the line

<xsl:template match=&quot;row[ starts-with(translate( @VendorName,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]&quot;>
<xsl:copy-of select=&quot;.&quot;/>

changes to:
<xsl:template match=&quot;row[ starts-with(translate( @VendorName,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]&quot;>
<xsl:copy-of select=&quot;.&quot;/>


I now get an error Expected token ')' found 'STRING'

Does anyone know how to solve this

Your help is greatly appreciated.

Regards David Furey
 
That's because you can't have a double-quote within a double-quote in XML. If you start with double quotes, then you have to use single quotes within them. If you really need the double quote inside, change the coding so that the string is inside single quotes instead:

VendorName='&quot;A&quot; A Meats'

You may also be able to use output escaping to get what you want.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top