XML Development

Moderators: None (Apply to moderate this forum)
Number of threads: 252
Number of posts: 451

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
XSLT Help needed Posted by dfurey16 on 24 Jun 2003 at 4:17 AM
I have an XML document and a XSLT document

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



XSLT Document

<xsl:stylesheet 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,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]">
<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,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]">
<xsl:copy-of select="."/>

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


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

Does anyone know how to solve this

Your help is greatly appreciated.

Regards David Furey

Report
Re: XSLT Help needed Posted by infidel on 24 Jun 2003 at 8:12 AM
: If I want to search on the string A" the line
:
: <xsl:template match="row[ starts-with(translate( @VendorName,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]">
: <xsl:copy-of select="."/>
:
: changes to:
: <xsl:template match="row[ starts-with(translate( @VendorName,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;),translate(&quot;A&quot;&quot;,&quot;abcdefghijklmnopqrstuvwxyz&quot;,&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)) ]">
: <xsl:copy-of select="."/>
:
:
: I now get an error Expected token ')' found 'STRING'
:
: Does anyone know how to solve this

Can you try escaping the " with a \? i.e. &quot;A\"&quot; so the parser doesn't take your query's " as the end of a string containing the letter A?


infidel




 

Recent Jobs