RE: How to use xslt to transform xml to xml with added nodes

Subject: RE: How to use xslt to transform xml to xml with added nodes
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Mon, 20 Sep 1999 11:26:24 -0600
> if textg = "xxxx", or "yyyyyyyy" or "zz" then texti = "something"
> if textg = "aaaa", or "bb" or "cccccccccccc", or "d" or "eee" 
> then texti = "something else"
> [...]
> Can this be done with a transform without a huge <xsl:choose>.

You could put the string mappings in the XML, as a kind of lookup table.

<StringMap>
    <texti out="something">
        <textg>xxxxx</textg>
        <textg>yyyyy</textg>
        <textg>zz</textg>
    </texti>
    <texti out="something else">
        <textg>aaaa</textg>
        <textg>bb</textg>
        <textg>cccccccccccc</textg>
    </texti>
</StringMap>

Then you could do this, given string $textg:
<xsl:variable name="texti"
select="string(/StringMap/texti[textg=$textg]/@out)"/>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread