|
Subject: Re: [xsl] Using a second xml document as a lookup table From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Fri, 10 May 2002 01:21:25 +0200 |
<xsl:template match="columns">
<xsl:for-each select="column">
<xsl:variable name="dbcolumn" select="@dbcolumn"/>
<xsl:for-each select="$dbdef">
<xsl:if test="key('dbdef-cols', $dbcolumn)">
<xsl:value-of select="$dbcolumn"/>
<xsl:text>=</xsl:text>
<xsl:value-of select="$dbcolumn"/>
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>Here's my main XML file:>
<columns> <column dbcolumn="col1"/> <column dbcolumn="col2" /> <column dbcolumn="col3" /> </columns>
Here's my lookup XML file, dbdef.xml:
<ElementType> <AttributeType name='col2'/> <AttributeType name='col3' /> <AttributeType name='col4' /> </ElementType>
My XSLT is:
<xsl:key name="dbdef-cols" match="AttributeType" use="@name" /> <xsl:variable name="dbdef" select="document('dbdef.xml')" />
<xsl:template match="/"> <xsl:variable name="all-columns" select="//column"/> <xsl:for-each select="$all-columns"> <xsl:variable name="dbcolumn" select="@dbcolumn" /> <xsl:for-each select="$dbdef"> <xsl:variable name="dbdef-col" select="key('dbdef-cols', $dbcolumn)" /> <xsl:value-of select="$dbcolumn"/>=<xsl:value-of select="$dbdef-col"/>, </xsl:for-each> </xsl:for-each> </xsl:template>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Using a second xml document a, John Sands | Thread | Re: [xsl] Using a second xml docume, John Sands |
| Re: [xsl] passing intermediate resu, paul morgan | Date | Re: [xsl] Strange Template Behavior, Joerg Heinicke |
| Month |