Subject: RE: [xsl] Reference to a other xml or xsl in the main xsl sheet From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 12 Sep 2003 11:06:05 +0100 |
There are several ways you can do this. You can write a named template that takes the country name as a parameter, and outputs the country code. <xsl:template name="encode-country"> <xsl:param name="code"> <xsl:choose> <xsl:when test="@code='x">Albania</xsl:when> etc. If the code is always in a <Country> element, you could use a match template instead, perhaps in a special mode: <xsl:template match="Country" mode="encode"> This is easier to call than a named template because you don't have to set up the parameter value. Or you could use a lookup table that maps country codes to names, and access this table whenever you need it using a path expression. Such lookup tables can be held in global variables and accessed using xx:node-set($lookup), or they can be held as user-defined data in a top-level stylesheet element and accessed using document('')/*/my:data, or they can be held in a separate XML file and accessed as document('lookup.xml'). Michael Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Wilco Meijer > Sent: 12 September 2003 07:29 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Reference to a other xml or xsl in the main xsl sheet > > > Hi, > > I'm just starting using XSL, and it might be very easy, but I > can't find a solution for the next problem: > > I'm using a xsl-stylesheet to do a transformation from one > xml-file to another. Within these transformation I need to > do a replacement, where for example I need to replace the > node-text "Holland" > (<Country>Holland</Country>) for the country-code "HO". > Therefore I'm using the <xsl:if...> statement. I do have this > <xls:if...> statement in multiple xls-files. What I do want > is one generic file (xml/xls) where I do have standing all of > my replacements standing. Within the xsl-file I do need a > reference to this "replacements-"file. This way, I only have > to change one file if a new country has to be added to the list. > > Can anyone please help me out here, or at least give me some hints? > > Thanks in advance, > > Wilco Meijer > > > 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] Reference to a other xml or x, Wilco Meijer | Thread | RE: [xsl] Reference to a other xml , Jarno . Elovirta |
RE: [xsl] Storing and retrieving ht, Michael Kay | Date | RE: [xsl] TrAX API and xsl:message, Michael Kay |
Month |