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

Singling Out Nodes in Look-up Table

Subject: Singling Out Nodes in Look-up Table
From: Chuck White <chuckwh@xxxxxxxxxxx>
Date: Mon, 14 Jan 2002 19:40:59 -0800
asm lookup table

In the following stylesheet I'm trying to map field element id attribute
values against both the Position element in the first source document and
the name="Position" attribute value pair in the second source document. The
second source doc is a lookup table, which is actually a proper mapping
against the first document, created by a separate, prior transform. You
might not be able to tell because I truncated each here because they're so
long, and I presume I ruined the association doing the truncating. So what I
want is, for example, to report on the id value for:

 <field id="IDAHBMIB" name="Position">ASM</field>
from the second document, mapped against original mapped element from whence
it came, which in this case was this from the first source document:
     <Position>ASM</Position><!-- this is a key -->
     <Type>All Amounts</Type>
The mapping key is the Position element and "name" attribute value pair
within their respective documents.

I can get close with the key I'm using, which gives me the node set I'm
after, but I really need to map each node within that set, so that instead
of this statement:

<xsl:value-of select="$lookup/@id"/>

getting only the first node of the node set, I need a better statement that
iterates through the set. An apply-templates gets me the whole set, instead
of individual nodes, which makes sense to me. These are truncated source
docs -- the full docs would reveal that the key exposes large node sets
consisting of several id="xxxxxx" attribute value pairs.

I think I'm missing something hugely obvious here, but there seems to be a
party going on in my head, and most people on this list are a lot smarter
than me. I've stared at this long enough. Anyone see anything obvious that
I'm missing? My apologies for such a large question, but I'm in one of those
blind spots that I can't get out of on my own. My sincerest thanks in

------- the stylesheet:

 <xsl:output method="text"/>
 <xsl:key name="lookup" match="row" use="field"/>
  <xsl:variable name="rma" select="document('rmaTables.xml')/dbdata"/>
  <xsl:template match="/">
  <xsl:apply-templates select="/RMASignature/Accounts/*/*/*"/>

 <xsl:template match="/RMASignature/Accounts/*/*/*">
 <xsl:variable name="index" select="position()" />
  <xsl:value-of select="Position"/>
  <xsl:text>, </xsl:text>
    <xsl:value-of select="Department"/>
    <xsl:text> ------ The ID# for this position is </xsl:text>

  <xsl:apply-templates select="$rma">
   <xsl:with-param name="position" select="Position"/>

 <xsl:template match="dbdata">
 <xsl:param name="position"/>

    <xsl:variable name="lookup" select="key('lookup',
  <xsl:value-of select="$lookup/@id"/>



<?xml version="1.0" encoding="UTF-8"?>
   <DocHead>Please sign in appropriate box above title</DocHead>
  <GeneralAccounts AccountsType="General Accounts">
   <NonTechnical ProductLine="DRAM">
     <Type>All Amounts</Type>

   <NonTechnical ProductLine="SRAM, Graphics, Flash, Mask ROM &amp; TFT">
     <Type>All Amounts</Type>
  <CorporateAccounts AccountsType="Corporate Accounts">
   <NonTechnical ProductLine="All Product Lines">
     <Type>All Amounts</Type>

   <Technical ProductLine="All Product Lines">
     <Type>All Amounts</Type>
 <Footer>info here</Footer>


 <jdbc_info driver="sun.jdbc.odbc.JdbcOdbcDriver"
  <uname>Pugal St. James</uname>
 <table name="bindings" id="IDAUDMIB">
  <row id="IDAECMIB" productLine="DRAM">
   <field id="IDAHBMIB" name="Position">ASM</field>
   <field id="IDASDMIB" name="AccountsType">GeneralAccounts</field>
   <field id="IDAJEMIB" name="Department"></field>
   <field id="IDANCMIB" name="Type">All Amounts</field>
   <field id="IDASEMIB" name="Status"></field>
   <field id="IDAHCMIB" name="NonTechnical ProductLine">NonTechnical</field>
<!-- many more rows here, truncated -->
  <row id="IDAWAMIB" productLine="DRAM">
   <field id="IDABFMIB" name="Position">Senior Manager</field>
   <field id="IDASDMIB" name="AccountsType">GeneralAccounts</field>
   <field id="IDAMFMIB" name="Department">Inside Sales</field>
   <field id="IDAWCMIB" name="Type">Over $10K</field>
   <field id="IDAREMIB" name="Status"></field>
   <field id="IDAHCMIB" name="NonTechnical ProductLine">NonTechnical</field>

Chuck White
The Tumeric Partnership
Co-Author, Mastering XML, Premium Edition
Sybex Books, May, 2001

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

Current Thread


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.
First Name
Last Name
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.