Re: localization techniques and code review
> Earlier, Jeni Tennison mailto:mail@xxxxxxxxxxxxxxxx wrote: > > [snip] > Thanks Jeni, That's exactly the kind of critique that I needed. > > 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. I am confused about your statement about moving localization.xml to the outer xsl:for-each. How would that be more advantageous? Would it change my xsl:key? On another note, is there a way for me to modify the following statement to only return nodes which match lang=$selectLang attribute? (the idea is to filter non-chosen languages - could I use something like [@lang='$selectLang']??) <xsl:variable name="trans" select="document('localization.xml')" /> How can the above statement be modified to achieve the above objective and is that even something to consider? For reference: <?xml version="1.0"?> <!-- localization.xml --> <localization> <word name="_FIRST_NAME"> <translation lang="es">Nombre</translation> <translation lang="en">First Name</translation> <translation lang="it">Nome</translation> </word> <word name="_OCCUPATION"> <translation lang="es">Ocupacion</translation> <translation lang="en">Occupation</translation> <translation lang="it">Occupazione</translation> </word> </localization> > > > 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 I am sorry. I think my choice of wording made you look deeper than I intended. (My knowledge is not deep enough to think of document caching at the server level :-)). I had meant to ask if I could re-print the results, another time without having to re-document() the localization.xml file, (perhaps in another style)? By clarifying the use of the $trans in: <xsl:variable name="trans" select="document('localization.xml')" /> I know now that it is re-usable and has all the nodes inside it. Thanks again, -- Haroon Rafique <haroon@xxxxxxxxxxxx> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format