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

Re: Combining translate() and apply-templates

Subject: Re: Combining translate() and apply-templates
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 27 Jan 2005 11:31:22 -0500
xml representing odd characters
Cynthia,

Watch out though: David's cunning solution won't work in every case:

At 02:33 PM 1/26/2005, you wrote:
<xsl:variable name="title">
  <xsl:apply-templates select="title"/>
</xsl:variable>

<xsl:value-of select="translate($title,$lower,$upper)" />

so long as your upper and lower variables include the spanish
characters.

only works as long as your input title, when processed by applying templates, needs to generate *only* a text value.


So if your input had

<new_rel>
  <title>La <emph>Divorc<eacute />e</emph></title>
  <rating>R</rating>
</new_rel>

that <emph> element would be lost, even if you also had

<xsl:template match="emph">
  <b>
    <xsl:apply-templates/>
  </b>
</xsl:template>

This is because when translate() operates on the variable $title it has to treat it as a string, so the result-tree-fragment created by applying templates to your title is "flattened" into its string value -- the <b> node generated by your template goes away.

I'm afraid a truly general solution to your problem requires multiple passes. This is because your solution to the representing-odd-characters problem straddles the line between markup and text ... you want to represent it as markup (in XSLT terms, "nodes"), yet process it as text.

Or you could constrain the input so that nothing like that emph will ever happen. Just thought it fair to warn....

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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