[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using a second xml document as a lookup table

Subject: Using a second xml document as a lookup table
From: John Sands <WonkoWatson@xxxxxxxxx>
Date: Thu, 9 May 2002 17:14:59 -0400
xml document lookup table
I want to output a node only if it is referenced in a second XML file.
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>

Eventually I'm going to build a SQL select statement, so I want to output:

 col2, col3

But first I'm trying to just match the values and output all of them like this:

 col1=, col2=col2, col3=col3,

Then I'll figure out how to eliminate the one that has no matching
value in the lookup document.

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>

I'm getting:

 col1=, col2=, col3=,

So my lookup is not working. Can anyone see why?
Also, is this a good way to do this kind of lookup, or is there a simpler way?
I'm using MSXML4.

Thanks,
John Sands


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.