Subject: Re: localization techniques and code review From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 17 Nov 2000 17:04:27 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
localization techniques and code re, Haroon Rafique | Thread | Re: localization techniques and cod, Haroon Rafique |
Re: XSLT link to schema, Jeni Tennison | Date | Re: XSLT Debugger, edmund mitchell |
Month |