Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

Problem Transforming XML Document That Has A Quote in a parameter

David Furey
Posts: n/a

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

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


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


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


The XSL Transformation fails and returns the following error

A string literal was not closed.

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

<NEXXML xmlns:sql="urn:schemas-microsoft-comml-sql">
<row SAPVendorRef="15001" VendorName="A&quot; A Meats" EntityId="3021"
<row SAPVendorRef="57232" VendorName="A&apos;bbeyhouse Foods"
EntityId="3050" rsposition="2"/>
<row SAPVendorRef="15011" VendorName="Alexandra Rentals" EntityId="3023"
<row SAPVendorRef="10184" VendorName="Alexandra Workwear PLC"
EntityId="3014" rsposition="4"/>
<row SAPVendorRef="15012" VendorName="Allied Bakeries NI" EntityId="3024"
<row SAPVendorRef="60143" VendorName="Astron On Line" EntityId="3056"
<row SAPVendorRef="56531" VendorName="Backgammo'n" EntityId="3048"
<row SAPVendorRef="15062" VendorName="British Bakeries NI" EntityId="3025"

XSL File

<xsl:stylesheet version="1.0"
<xslutput method="xml"/>
<xslaram name="search-for" select=" 'a' "/>
<!-- convert the param to upper case just once -->
<xsl:variable name="uc-search-for"
<xsl:template match="/">
<xsl:template match="rows">
select="row[starts-with(translate(@VendorName,'abcdefghijklmnopqrstuv wxyz','
<xsl:template match="row">
<xsl:copy-of select="."/>


Many thanks in advance for any responses

Reply With Quote

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