[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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"/>
Then I do a match and a for-each, e.g.,
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>
_________________________________________________________________
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
Re: [xsl] using xsl to substitute synonyms or translate
Subject: Re: [xsl] using xsl to substitute synonyms or translate From: "Thomas McDonald" <tomandlis@xxxxxxxxxxx> Date: Tue, 07 Jan 2003 16:23:38 -0500 |
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>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] using xsl to substitute synonyms or translate Date: Tue, 07 Jan 2003 15:36:22 -0500
I have a problem that I think is similar to translating words in one language to words in another language and I was wondering if I could use xsl to do it.
I know what my source input will be (example below) and I know what I want to output to be, but I can't fathom how to build an xsl to get the output. I thought I could use the translate function, but there would be a long list of things to translate. There are 32 teams and I want to use this process again (on something unrelated) for a list of over 300 items.
Here is what my source document will look like
<nflTeamNames> <name>49ers</name> <name>Cowboys</name> . . . <name>Seahawks</name> <nflTeamNames>
Here is what I want the output to look like:
<nflCities> <city>San Francisco</city> <city>Dallas</city> . . . <city>Seattle</city> </nflCities>
In case you don't know American football the 49ers are the San Francisco team, the Cowboys are the Dallas team and so on. :-)
Regards,
Tom
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] using xsl to substitute s, Wendell Piez | Thread | Re: [xsl] using xsl to substitute s, Wendell Piez |
[xsl] using xsl to substitute synon, Thomas McDonald | Date | [xsl] writing xsl for processing do, Hubert Holtz |
Month |
Keywords