This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

need position() of second document


I am parsing an XML document and referring to information from a second document. From the second document, I need to get some information as well as the position() that I can use now and also later in my XSL.

I was first using:
          <xsl:attribute name="id">
               <xsl:for-each select="document($controls)//*">
                    <xsl:if test="name()=$tag">
                                         <xsl:value-of select="position()-1"/>
                    </xsl:if>
               </xsl:for-each>
          </xsl:attribute>

I want to also create a variable that contains the position so I can use it as an index later when some additional information is needed (so I won't have to search the second file again - speed issues).

The $controls file has unique strings I am thinking about replacing the above with something like this (I like this approach better so I don't have to take the time to walk through every element of $control just to find a single unique node):
     <xsl:variable name="str" select="document($controls)//*[name()=$tag]"/>
     <xsl:variable name="pos" select="position()"/>
and then using the pos for the attribute id (i.e. <TABLE id="{$pos}"...> )
I could then use the pos as an index later (i.e.  "item[$pos]" ).
Essentially, I need to get (from the $control file) the tagName, the node value, and the position() of these items.

My question is, how do I reference the $controls document when I need to get the position? The code above returns the position in my first file, not the second document file that I had just referenced. I'm sure this is a simple answer, but I am not
finding it in the books and references I have been looking at. Also, later when I need to use the $pos as an index, I will also need to reference the document file. Do I do it like this:  <... select="document($controls)//item[$pos]"...>

Any help on this is greatly appreciated!

- Ken    < ><
  (email: Ken.Dickerson@philips.com)



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]