| Subject: [xsl] special chars in xsl:attribute tag From: Doug Howell <doug@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 16 Aug 2002 16:16:52 -0400 | 
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
'), 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 "’"> in the XML document, but when I use
’ 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 " 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 | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] transforming attributes into , Paul Tremblay | Thread | Re: [xsl] special chars in xsl:attr, Jeni Tennison | 
| [xsl] Re: your mail, Paul Tremblay | Date | [xsl] Temp Turn-Off of xsl List, Klass,Joel | 
| Month |