xsl-list
[Top] [All Lists]

AW: Translating "("

2004-11-15 05:59:10
Thank you very very much, David.
That was exactly what I needed.

wbr,
Roman

-----Ursprüngliche Nachricht-----
Von: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Gesendet: Montag, 15. November 2004 13:36
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] Translating "("


  I need translate special characters like "(", ")" etc in <ln:term>.

  <xsl:variable name="val" select="translate(normalize-space(ln:term),
  '&#39;&#160;/&#40;&#41;,&#34;""', '_')" />

  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 &#39; 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),
                                 ^
  '&#39;&#160;/&#40;&#41;,&#34;""', '_')" />
                               ^^       ^

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("'&#160;/()",'"')

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("'&#160;/()",'"')
   '_')

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 &quot; the
occurrences of " in the attribute value

select="translate(normalize-space(ln:term),
   concat(&quot;'&#160;/()&quot;,'&quot;')
   '_')"

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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>