[xsl] Arrays in XSLT for variables?

Subject: [xsl] Arrays in XSLT for variables?
From: "Maulik Modi" <mxmodi@xxxxxxxxxxxxxxx>
Date: Mon, 19 Feb 2001 17:09:52 -0600

I am trying to parse a XML doc1, extract a particular node value from XML
doc 1and then pass this string as an XPATH expression to be evaluated in a
separate XML doc 2.  I can build the dynamic XPATH using the evaluate() fn.
Next I want to do a conditional test to compare both the parsed value from
doc1 and the validated value from doc2 for each <Node_path>'s and
<Node_value> pairs. If the test returns true, I want to process all the
<URL>'s in the following-siblings.

For example, in the following XML, I have two <Node_path> and <Node_value>
pairs in the first child, I want to test if the values for both the pairs
are true and then process the three <URL>'s for it., meaning 3 times.

WHAT I have working:
In the following XML, I have two <Node_path> and <Node_value> pairs in the
first child, and if both text are valid, it processes each <URL> under it,
meaning six times!

Any help is appreciated. Can I store each pair in an array and refer to it
later when I need to?

My XML doc1 (called BER2.xml in the stylesheet) is:

  <EVENT name="steve14nov">



default XML passed to XSLT (refered to as doc2 above):

<!--bunch of xml tags here ignored -->


Snippet XSL code:

  <xsl:variable name="tempdoc" select="document('BER2.xml')/CHANNEL" />
  <xsl:variable name="chandoc" select="." />

  <xsl:template match="/">
    <!--some other code for presentation deleted here-->

   <xsl:for-each select="$tempdoc//Node_path">

         <xsl:variable name="npath" select="." />
         <xsl:variable name="nvalue" select="following-sibling::Node_value"
         <xsl:variable name="urls" select="following-sibling::URL" />

      <xsl:for-each select="$chandoc//DATA" >
       <xsl:variable name="parsed" select="saxon:evaluate($npath)" />
       <xsl:variable name="valid" select="$nvalue" />

       <xsl:if test="$parsed=$valid">
        <URL><xsl:value-of select="$urls" /></URL>


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

Current Thread