|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Translating "("
I need translate special characters like "(", ")" etc in <ln:term>.
<xsl:variable name="val" select="translate(normalize-space(ln:term),
'' /(),"""', '_')" />
Unfortunately Saxon throws an exception at this line, because of
resolving the character entities...
There's nothing special about ( in strings, you could just use ( to
denote those. and ' are not entity references but character
references (which are expanded at a different time)
You didn't show the error message you got, although it's unlikely to
have been from saxon, your quoted line is not well formed XML (It has a
two literal " characters inside a " delimited attribute value) so should
have been rejected by the XML parser before XSLT processing starts.
<xsl:variable name="val" select="translate(normalize-space(ln:term),
^
'' /(),"""', '_')" />
^^ ^
Getting ' and " into an Xpath string is a FAQ )and the faq for this list
will have an entry for it but you can not have a string literal that
contains both ' and " You appear to want to have the Xpath string
'<nbsp>/(),"
You can have ' in a "-delimited string and " in a 'delimited string but
you can't have both in the same literal so you need to concat them
together eg
concat("' /()",'"')
Your translate function just had a string of length 1 so that's goint to
replace the first character ' by _ and discard the rest, is that what
you want? assuming so:
You need
translate(normalize-space(ln:term),
concat("' /()",'"')
'_')
now to get that expression into a select attrbute. As far as XML is
concerned it's all just an opaque string, that has three " and five '
so if you are using " to delimit the attrinute you need to " the
occurrences of " in the attribute value
select="translate(normalize-space(ln:term),
concat("' /()",'"')
'_')"
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








