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

RE: failed to find the right child node

Subject: RE: failed to find the right child node
From: "Lin, Jessica" <jlin@xxxxxxxxxxx>
Date: Thu, 31 Aug 2006 08:43:30 -0700
RE:  failed to find the right child node
No one replays my question by now. I just send again to bring up your
attention. Thanks ahead.

-- Jessica

-----Original Message-----
From: Lin, Jessica [mailto:jlin@xxxxxxxxxxx]
Sent: Tuesday, August 29, 2006 4:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  failed to find the right child node

I am trying to find out whether all channel objects are in the same
networks. Each legacy_stream has a different network_id which indicates
different
Networks. I plan to recursively check all fast_load stream, if it
contains channel object, I will increase sum of networks by 1. At the
end, I will check the sum of network, if it is larger than one, I will
assign a Boolean false value to indicate that all channels are in the
different network. Otherwise, I will assign a Boolean true value.
But, when I try to check each fast_load_stream by using  select
="//fast_load_stream[position()=$index]", it does not work. Could you
please help me to find out what's wrong in my code?


<?xml version="1.0" encoding="UTF-8"?>
<streams>
  <legacy_stream name="stream1">
    <mpt_stream>
	<apg_stream>
	  <fast_load_stream>
		<network_id>0</network_id>
		<cycle_time_seconds>4</cycle_time_seconds>
		<objects>
		   <update_list_object ref="ULO1"/>
		   <channel_object ref="CO1"/>
		   <channel_object ref="CO2"/>
		</objects>
	  </fast_load_stream>
	</apg_stream>
    </mpt_stream>
  </legacy_stream>
  <legacy_stream name="stream2">
    <mpt_stream>
	<apg_stream>
	  <fast_load_stream>
		<network_id>1</network_id>
		<cycle_time_seconds>4</cycle_time_seconds>
		<objects>
		   <update_list_object ref="ULO2"/>
		   <channel_object ref="CO3"/>
		   <channel_object ref="CO4"/>
		</objects>
	  </fast_load_stream>
	</apg_stream>
    </mpt_stream>
  </legacy_stream>
  <legacy_stream name="stream3">
    <mpt_stream>
	<apg_stream>
	  <fast_load_stream>
		<network_id>2</network_id>
		<cycle_time_seconds>4</cycle_time_seconds>
		<objects>
		   <update_list_object ref="ULO3"/>
		   <channel_object ref="CO5"/>
		   <channel_object ref="CO6"/>
		</objects>
	  </fast_load_stream>
	</apg_stream>
    </mpt_stream>
  </legacy_stream>
</streams>


Here is my xslt file. I use some xsl:value-of to print out some outputs
for debug purpose.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8" indent="yes" />


<xsl:template match="/">
  <xsl:call-template name="isInSameNetwork">
    <xsl:with-param name="totalNetworks"
select="count(//fast_load_stream)"/>
    </xsl:call-template>
</xsl:template>


<xsl:template name="isInSameNetwork">
  <xsl:param name="totalNetworks"/>
  <xsl:param name="index" select="1"/>
  <xsl:param name="sumNetworks" select="0"/>
  <xsl:value-of select="concat('#totalNetworks = ',
$totalNetworks, ', index = ', $index, ' sumNetworks = ',
$sumNetworks)"/>
  <xsl:variable name="fastloadStream"
select="//fast_load_stream[position()=$index]"/>
  <xsl:if test="$index &lt; $totalNetworks">
    <xsl:choose>
	<xsl:when test="fastloadStream/objects/channel_object" >
	   <xsl:text> $has COs </xsl:text>
	   <xsl:call-template name="isInSameNetwork">
	      <xsl:with-param name="totalNetworks"
select="$totalNetworks"/>
	      <xsl:with-param name="index" select="$index + 1"/>
	      <xsl:with-param name="sumNetworks" select="$sumNetworks +
1" />
	   </xsl:call-template>
	</xsl:when>
     <xsl:otherwise>
	  <xsl:text> $has no COs </xsl:text>
	  <xsl:call-template name="isInSameNetwork">
	     <xsl:with-param name="totalNetworks"
select="$totalNetworks"/>
	     <xsl:with-param name="index" select="$index + 1"/>
	     <xsl:with-param name="sumNetworks" select="$sumNetworks" />
	  </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:if>

<xsl:choose>
   <xsl:when test="$sumNetworks &gt; 1">
	<xsl:value-of select="false()"/>
   </xsl:when>
   <xsl:otherwise>
	<xsl:value-of select="true()"/>
   </xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

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.