|
Subject: RE: [xsl] Using "variable" in a select... From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxxxxxx> Date: Thu, 18 Sep 2003 15:19:35 +0100 |
just put the attribute in a variable
<xsl:variable name="lang" select="document('originalxmldata.xml')/Attest/@lang"/>
then your use variable in the value-of select statement
<xsl:value-of select="document('fiscalAttestsTxt.xml')/Texts/Loan/LoanNr[@lang=$lang]"/>
you may run into potential problems if the xml doc is the root xml doc, that is u are not using the document() command to bring it into your stylesheet......just make sure your variable is a global one ( declared at the top of your stylesheet )....though of couse you may have multiple transformations.
gl, jim fuller
-----Original Message-----
From: Michel.Baily@xxxxxxxxxxxxxxxxx
[mailto:Michel.Baily@xxxxxxxxxxxxxxxxx]
Sent: 18 September 2003 15:03
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Using "variable" in a select...
Dear All,
Im currently working on an XSL-FO project needing multiple languages
documents.
I've an XML document containing the data to be written :
<Attest year="2002" documentDate="21/08/2003">
<Taker>
<Name>
Adam Dure
</Name>
<Address>
<Street>
Katrienwiel 6
</Street>
...
...
</Address>
...
...
</Taker>
...
...
</Attest>
I've an XSL document used to transform XML into PDF using FOP.
To allow easiest maintenance, I've placed all the document static texts
into an other XML file like the one below :
<?xml version='1.0' encoding="UTF-8" ?>
<Texts>
<Loan>
<LoanNr lang="nl">Hypotecaire leningen Nr</LoanNr>
<LoanNr lang="fr">Prêt hypotécaire Nr</LoanNr>
<Year lang="nl">Dienst jaar</Year>
<Year lang="fr">Année</Year>
...
...
</Loan>
</Texts>
To acces the texts, I use such construction :
<xsl:template match="Loan">
...
<xsl:value-of select="document('fiscalAttestsTxt.xml')/Texts/Loan/LoanNr
[@lang='nl']"/>
...
</xsl:template>
My question :
In place of using a litteral value for the lang(uage) attribute, I would
like to use a value extracted from my original xml file.
For example, I could add lang attribute to the Attest tag.
...
<Attest year="2002" documentDate="21/08/2003" lang="fr">
<Taker>
<Name>
Adam Dure
</Name>
...
...
</Taker>
...
...
</Attest>
How can I reference this lang attribute as parameter in my select criteria
?
Remark : This value will change from Attest to Attest...
Thanks in advance
Michel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Using "variable" in a select., Michel . Baily | Thread | [xsl] javascript- variable question, Bruce Rojas-Rennke |
| Re: [xsl] multiple template value i, Mukul Gandhi | Date | Re: [xsl] multiple template value i, clemens schrenk |
| Month |