Problem Transforming XML Document That Has A Quote in a parameter

Discussion in 'XML' started by David Furey, Jun 29, 2003.

  1. David Furey

    David Furey Guest

    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
     
    David Furey, Jun 29, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mirjana Rakuljic

    Help with transforming XML document

    Mirjana Rakuljic, Nov 7, 2003, in forum: XML
    Replies:
    2
    Views:
    437
    Mirjana Rakuljic
    Nov 8, 2003
  2. Valery Khamenya
    Replies:
    3
    Views:
    744
  3. Jerry Hill
    Replies:
    0
    Views:
    499
    Jerry Hill
    Oct 4, 2008
  4. Evan
    Replies:
    1
    Views:
    419
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  5. Evan
    Replies:
    3
    Views:
    552
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
Loading...

Share This Page