[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

special chars in xsl:attribute tag

Subject: special chars in xsl:attribute tag
From: Doug Howell <doug@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Aug 2002 16:16:52 -0400
javascript special chars
Thanks to Jeff, I was able to progress to my next problem with the glossary
application.

<entry>
    <term cat="sw">Beginner's All-Purpose Symbolic Instruction
Code</term><!-- fix -->
    <acronym>Basic</acronym>
    <def>whatever</def>
</entry>

The stylesheet now lists all terms and acronyms in alphabetical order. For
each acronym, it creates a JavaScript function call and passes the value of
the term to it, like this:

<xsl:for-each select="//term|//acronym">
    <xsl:sort select="." order="ascending"/>
    <p><strong><xsl:value-of select="."/></strong>:
    <xsl:if test="name()='acronym'">
        <em>See </em>
        <a><xsl:attribute name="href">javascript:searchExact('<xsl:value-of
select="preceding-sibling::term"/>')</xsl:attribute><xsl:value-of
select="preceding-sibling::term"/></a>
    </xsl:if>
    <xsl:if test="name()='term'">
        <xsl:if test="following-sibling::acronym">
            (<xsl:value-of select="following-sibling::acronym"/>)
        </xsl:if>
        <xsl:apply-templates select="following-sibling::def"/>
    </xsl:if>
    </p>
</xsl:for-each>

The XML/XSL files are loaded into an HTML page. The JavaScript function uses
the passed-in parameter to change the select attribute of the xsl:for-each
element and selects the related term. This all works fine except for one
term, the one I've listed above.

The trouble is with the apostrophe. If I include it as it appears above (or
&#39;), the output is:
<a href="javascript:searchExact('Beginner's All-Purpose Symbolic Instruction
Code')">etc.
This causes an error because the single-quotation mark comes too early.

I've declared  <!ENTITY rsquo "&#8217;"> in the XML document, but when I use
&rsquo; the output is:
<a href="javascript:searchExact('Beginner%E2%80%99s All-Purpose Symbolic
Instruction Code', 'ALL')">etc.
This doesn't work because there is no matching term to find.

If I use &quot; the output is:
<a href="javascript:searchExact('Beginner"s All-Purpose Symbolic Instruction
Code', 'ALL')">etc.
This works, but, alas, a quotation mark is not the right character. Sorry,
just trying for a little comic relief.

Have tried a few things with xsl:copy and copy-of but can't seem to get the
right combination. Any help is appreciated!
Thanks,
Doug

Doug Howell
Information Architect, BGI-IT
734.747.7471 (or 477.2857)



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.