Subject: RE: [xsl] keyed lookup table From: "Pawson, David" <David.Pawson@xxxxxxxxxxx> Date: Fri, 18 Feb 2005 10:31:19 -0000 |
-----Original Message----- From: David Carlisle > that I would access with this expression: > key('language-code', 'de', $stylesheet)"/> > > given: > > <xsl:variable name="stylesheet" select="document('')"/> no don't do that, although it ought to work, it causes the stylesheet to be re-parsed. In 2.0 you can query into variables so you can just use $language-table instead of $stylesheet. Neat :-) Input <name code="de"> </name> xslt <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:variable name="language-table"> <!-- See ISO 639 --> <name code="ar">ARABIC</name> <name code="de">GERMAN</name> <name code="en">ENGLISH</name> <name code="zh">CHINESE</name> </xsl:variable> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:variable name="stylesheet" select="document('')"/> <xsl:key name="language-code" match="name" use="@code"/> <xsl:template match="name"> Document is in [<xsl:value-of select="key('language-code', 'de',$language-table)"/>] </xsl:template> </xsl:stylesheet> output <?xml version="1.0" encoding="utf-8"?> Document is in [GERMAN] regards DaveP. -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] keyed lookup table, Kevin Rodgers | Thread | [xsl] breaking xsl loop or template, Prasad Akella |
[xsl] Matching not only references , Young Matthew | Date | [xsl] Original encoding lost after , guray |
Month |