Re: Using a second xml document as a lookup table
almost everything is ok, you are switching the context correctly to the second file dbdef.xml, you are only selecting the text-value of a node, that has no text.
With your <xsl:value-of select="$dbdef-col"/> at the end you select the text of an element <AttributeType/>, they all are empty (have no child nodes) in your dbdef.xml. What you want is maybe <xsl:value-of select="$dbdef-col/@name"/>, isn't it?
But your code is not completely full of sense to me. Can the test not be done easier?
<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>
You have something like ID and IDREF. You don't need to output as first the one and as second the other one. The value is the same. So the <xsl:if> is important. Or do you need the "col1=,col2=col2,col3=col3"-String?
Here's my main XML file:>
My XSLT is:
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