[xsl] Trouble using document()

Subject: [xsl] Trouble using document()
From: "mwebster" <mwebster@xxxxxxxxxxxxxxx>
Date: Fri, 10 Jun 2005 01:10:28 -0700
Sorry if I have included too much or too little of my XSL document.  This
section is attempting to replace a recursive solution that worked well in
Saxon but causes a stack overflow error in XALAN.

Basically, I want to use the known number of nodes in 

document($nodeFileName)/nodes/n

to go through my smaller list of stats in my main XML document to produce a
known number of nodes in the final XML.  I believe I am getting some
confusion between the document() items and the items in my pd: XML because
sections like:

	  <xsl:for-each select="pd:stats">
	    <xsl:if test="@index = position()-1">
	      <xsl:value-of select="'true'"/>
	    </xsl:if>
	  </xsl:for-each>


don't seem to be getting accessed at all.

That is, I think when I reference pd:stats, the XLST is thinking I'm
referring to something in document($nodeFileName) rather than something in
my main XML file in the name space pd: 

Can anyone suggest what I'm doing wrong?




<xsl:template match="pd:electrodeStatsList">
<xsl:element name="electrodeStatsList" namespace="urn:probe-design-service">
    <xsl:element name="statsNamesList" namespace="urn:probe-design-service">
	<xsl:for-each select="pd:stats[1]/pd:stat">
	    <xsl:element name="statName"
namespace="urn:probe-design-service">
		<xsl:value-of select="@name" />
	    </xsl:element>
	</xsl:for-each>
    </xsl:element>
<!-- Handle full set of electrode data -->
      <xsl:if test="$useLoop = 'false'">
	  <xsl:for-each select="pd:stats">
	      <xsl:element name="stats"
namespace="urn:probe-design-service">
		  <xsl:for-each select="pd:stat">
		      <xsl:element name="st"
namespace="urn:probe-design-service">
			  <xsl:value-of select="." />
		      </xsl:element>
		  </xsl:for-each>
	      </xsl:element>
	  </xsl:for-each>
    </xsl:if>
<!-- Handle sparse electrode data -->
    <xsl:if test="$useLoop = 'true'">
      <xsl:for-each select="document($nodeFileName)/nodes/n">
	<xsl:variable name="found">
	  <xsl:for-each select="pd:stats">
	    <xsl:if test="@index = position()-1">
	      <xsl:value-of select="'true'"/>
	    </xsl:if>
	  </xsl:for-each>
	</xsl:variable>
	<xsl:choose>
	  <xsl:when test="$found = 'true'">
	    <xsl:for-each select="pd:stats">
	      <xsl:if test="@index = position()-1">
		<xsl:element name="stats"
namespace="urn:probe-design-service">
		    <xsl:for-each select="pd:stat">
			<xsl:element name="st"
namespace="urn:probe-design-service">
			    <xsl:value-of select="." />
			</xsl:element>
		    </xsl:for-each>
		</xsl:element>
	      </xsl:if>
	    </xsl:for-each>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:element name="stats" namespace="urn:probe-design-service">
	      <xsl:for-each select="pd:stats[1]/pd:stat">
		<xsl:element name="st" namespace="urn:probe-design-service"
/>
	      </xsl:for-each>
	    </xsl:element>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:if>
</xsl:element>
</xsl:template>




Michael Webster
CombiMatrix Corporation
Software Department
(425) 493-2266

Current Thread