[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: using xsl to substitute synonyms or translate
Sorry to answer my own question. If I had thought about it longer I would
have realized the answer. The whole xsl is below (untested). But I will
walk through the steps in case this is helpful to anyone. I use an include
document, e.g.,
<xsl:variable name="nameLookupDoc" select="document('/includes/names.xml')"/> and then creating a key on that document, e.g., <xsl:key name="nameNumKey" match="nflTeamNames/name" use="@nameId"/> where 'nameId' would be a new attribute, e.g., <nflName nameId='49ers'> <alias>San Francisco</alias> </nflName> Then I do a match and a for-each, e.g., <xsl:template match="names"> <xsl:for-each select="$nameLookupDoc"> <xsl:value-of select="key('nameNumKey',.)/alias"/> </xsl:for-each> </xsl:template> So the whole thing looks like this: <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="html"/> <xsl:variable name="nameLookupDoc" select="document('/stage4/includes/names.xml')"/> <xsl:key name="nameNumKey" match="name" use="@nameId"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="nflTeamNames"/> <xsl:template match="names"> <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable> <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable> <xsl:for-each select="$nameLookupDoc"> <xsl:value-of select="translate(key('nameNumKey',.)/alias"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> From: "Thomas McDonald" <tomandlis@xxxxxxxxxxx> _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus 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
|