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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with parsing parameters that have ' & char

Status
Not open for further replies.

dfurey16

Programmer
Jun 24, 2003
2
GB
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=&quot;search-for&quot; select=&quot; 'a' &quot;/>

[Code]

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

[Code]

	<xsl:param name=&quot;search-for&quot; select=&quot; 'a&apos; &quot;/>

[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 &quot; and '

The files I am using are shown below

XML File

[Code]
<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;A&apos;bbeyhouse 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>
[Code]


XSL File

[Code]
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform&quot;[/URL] xmlns:sql=&quot;urn:schemas-microsoft-com:xml-sql&quot;>
	<xsl:output method=&quot;xml&quot;/>
	<xsl:param name=&quot;search-for&quot; select=&quot; 'a' &quot;/>
	<!-- convert the param to upper case just once -->
	<xsl:variable name=&quot;uc-search-for&quot; select=&quot;translate($search-for,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOP
qrstuvwxyz')&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[starts-with(translate(@VendorName,'abcdefghijklmnopqrstuvwxyz','
abcdefghijklmnopqrstuvwxyz'),$uc-search-for)]&quot;/>
	</xsl:template>
	<xsl:template match=&quot;row&quot;>
		<xsl:copy-of select=&quot;.&quot;/>
	</xsl:template>
</xsl:stylesheet>

[Code]

Many thans in advance for any responses
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top