|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using "variable" in a select...
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: 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
|
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
|

Cart








