Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problem Transforming XML Document That Has A Quote in a parameter

Reply
Thread Tools

Problem Transforming XML Document That Has A Quote in a parameter

 
 
David Furey
Guest
Posts: n/a
 
      06-29-2003
Hi,

I am using the XSLT document to filter records from an XML document
The XSL is shown below:

I have a parameter named "search-for" that is used to bring back a list of
Vendor Names that start with this parameter.

The list works as I want for alpabetical letters. Setting the parameter to
'a' brings back a list of vendors beginning
with 'a' as shown below

[Code]
<xslaram name="search-for" select=" 'a' "/>

[Code]

If I change the parameter to be 'a&apos;' with a single quote

[Code]

<xslaram name="search-for" select=" 'a&apos; "/>

[Code]


The XSL Transformation fails and returns the following error

A string literal was not closed.
'a'-->'<--

The XML Parser is thinking the '&apos; character in the literal string is
the end of the string where I want
it to be treated as part of the string.

Does anyone know how I can get the XML parser to treat the quotes inside the
parameter to be treated as part of the string.
I want the parameter to be able to hold the characters " and '

The files I am using are shown below

XML File

[Code]
<NEXXML xmlns:sql="urn:schemas-microsoft-comml-sql">
<columns/>
<rows>
<row SAPVendorRef="15001" VendorName="A&quot; A Meats" EntityId="3021"
rsposition="1"/>
<row SAPVendorRef="57232" VendorName="A&apos;bbeyhouse 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>
[Code]


XSL File

[Code]
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:sql="urn:schemas-microsoft-comml-sql">
<xslutput method="xml"/>
<xslaram name="search-for" select=" 'a' "/>
<!-- convert the param to upper case just once -->
<xsl:variable name="uc-search-for"
select="translate($search-for,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOP
qrstuvwxyz')"/>
<xsl:template match="/">
<nexxml>
<rows>
<xsl:apply-templates/>
</rows>
</nexxml>
</xsl:template>
<xsl:template match="rows">
<xsl:apply-templates
select="row[starts-with(translate(@VendorName,'abcdefghijklmnopqrstuv wxyz','
abcdefghijklmnopqrstuvwxyz'),$uc-search-for)]"/>
</xsl:template>
<xsl:template match="row">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

[Code]

Many thanks in advance for any responses
David


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with single-quote and double-quote when using subprocess. Evan Python 3 11-04-2008 12:24 PM
problem with quote and single-quote when using "subprocess" Evan Python 1 11-04-2008 12:08 AM
Problem: neither urllib2.quote nor urllib.quote encode the unicodestrings arguments Valery Khamenya Python 3 10-05-2008 10:16 AM
Re: Problem: neither urllib2.quote nor urllib.quote encode theunicode strings arguments Jerry Hill Python 0 10-03-2008 11:37 PM
Help with transforming XML document Mirjana Rakuljic XML 2 11-08-2003 10:56 AM



Advertisments