Problem Transforming XML Document That Has A Quote in a parameter

D

David Furey

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:
<xsl:param name="search-for" select=" 'a' "/>

[Code]

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

[Code]

<xsl:param 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-com:xml-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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<xsl:output method="xml"/>
<xsl:param 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,'abcdefghijklmnopqrstuvwxyz','
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top