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

Re: localization techniques and code review

Subject: Re: localization techniques and code review
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 17 Nov 2000 17:04:27 +0000
localization.xml error
Haroon,

> 1. Am I on the right track? What about the use of nested
> <xsl:for-each select="document('localization.xml')">

Looks like you are. There's one small error, in that you're using
xsl:param immediately within an xsl:for-each - that needs to be an
xsl:variable instead. The other small thing is that having assigned
the root node of the 'localization.xml' document to the 'trans'
variable, you may as well use it again instead of reaccessing the
document in the xsl:for-each. You also don't have to search all the
root descendants for the 'field' elements: they're all direct children
of 'page' (at least in this example).

In other words, change it to:

  <xsl:for-each select="field">
    <xsl:variable name="field" select="." />
    <xsl:value-of select="$field" />
    <h1>
      <xsl:for-each select="$trans">
        <xsl:value-of
            select="key('translate',concat($field,'-',$selectLang))" />
      </xsl:for-each>
    </h1>
  </xsl:for-each>

The nested xsl:for-each is necessary.  The key() function that you use
is scoped by the current node: it only looks for nodes within the
current document.  In the outer xsl:for-each, the current document is
your source XML.  You need to change it to the localization.xml
document to use the key to retrieve information quickly from it.

> 2. What if I need to re-print the table again? Could I have somehow
> stored the results of the document() call to be able to reuse it at
> a later stage?

Not within XSLT.  It really depends on your set up, how you're
processing the XSLT on the server.  It may be possible for the server
to keep the DOM for the localization.xml document cached so that it
doesn't have to parse it each time.  Perhaps a Cocoon person can give
you a better answer.

Sorry I can't be more help,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.