xsl-list
[Top] [All Lists]

AW:RE: [xsl] Translating "("

2004-11-15 06:25:33
Hi Michael,

Actually, I though about this way over the substring functions before (since I 
am still using XSLT 1.0), but was hoping that there is a simplier way using the 
translate function.

David was right, that not the angle brackets but my '"' character reference 
(thanks for the terminological correction, David) was the reason for my saxon 
exception.

I tried the work-around with concat() and now everything works out fine.
Thank you very much for your comprehensive and quick help!!
I can't await learning XSLT 2.0 :)

wbr,
Roman

-----Ursprüngliche Nachricht-----
Von: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Gesendet: Montag, 15. November 2004 14:04
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: RE: [xsl] Translating "("


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


You presumably want to generate element nodes in the result tree, rather
than constructing angle brackets within a text node. To construct an
element
node, you need to use either a literal result element or xsl:element - you
can't do it by generating the XML markup directly as a string.

This use case (assuming parens are not nested) becomes very easy in XSLT
2.0
with xsl:analyze-string: something like

<xsl:analyze-string select="." regex="\(.*?\)">
  <xsl:matching-substring>
    <ln:term>
      <xsl:value-of select="translate(., '()', '')"/>
    </ln:term>
  </xsl:matching-substring>
  <xsl:non-matching-substring>
    <xsl:value-of select="."/>
  </xsl:non-matching-substring>
</xsl:analyze-string>

With 1.0, assuming you can have multiple instances of (..) within a text
node, but not nested instances, it needs a recursive template along the
following lines:

output substring-before "("
<ln:term>
  output substring-before ")" substring-after "("
</ln:term>
recursive call to process substring-after ")"

Michael Kay


--~------------------------------------------------------------------
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>
  • AW:RE: [xsl] Translating "(", Huditsch Roman <=