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

Re: Problems with apersand (&) when trying to dynamica

Subject: Re: Problems with apersand (&) when trying to dynamically define a character value as an attribute value.
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 Oct 2006 12:54:26 +0100
apersand char
> Unfortunately I am restricted to using only xslt1. Is there any way to
> define the character in XSLT1 using the code I have without having to
> attach the & to the beginning? 

your processor may have an extension function (eg saxon:parse() would
work) or the answer to your question technically is yes but you really
don't want to do it

<xsl:choose>
<xsl:when test="@character=65">A</xsl:when>
<xsl:when test="@character=66">B</xsl:when>
.... a few thousand lines later....
</xsl:choose>

doing it as an xsl:choose would be painful, as it would have to do a
linear search each time. What would be not quite so painful is to make
yourself a document
<x>
<char num="65">A</char>
.... a few thousand lines later....
</x>

then you could have 
<xsl:key name="char" match="char" use="@num"/>
...

<xsl:variable name="c" select="@character"/>
<xsl:for-each select="document('char.xml')">
  <xsl:value-of select="key('char',$c)"/>
</xsl:for-each>

which would mean that having read the file once xslt had a hash table
lookup of character numbers, but still (if you want to cover all
unicode) this is still rather painful, and you may just prefer to get
xslt to write out [AMP]#1234; and then just use perl or sed or any other
text editor to change [AMP] to &

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.