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]
Other format: [Raw text]

Re: Repeated Recursion on different parts of a tree


Thanks David. The stylesheet compiles now, but I am still 
not getting a result returned from the template.

Looking at the template it seems that the choose statement 
is not stopping the recursion on the last <bitfield> node,
and so the <choose> conditions are not correct.

Even If I eliminate the arithmetic, It seems the last node 
in which the template switches to the default <otherwise> 
statement and outputs a result, is not the valid last 
<bitfield> node.

I have verified this by changing the <otherwise> statement 
to output just the @name attribute of the current (last) 
node. It returns nothing. Even when I try to output the 
@name of the parent of the last node (or any of its other 
element), on the last pass of recursion, still no value is 
returned.

It looks as if the template is going onto a node or part of 
a tree that doesnt exist on the last pass?

I have double checked the statements and all seems to 
conform to the advice I have been given and certain texts. 

My XML and XSL for reference:



 <xsl:template name="calcInitialValue">
  <xsl:param name="initialValue" /> 
  <xsl:param name="newNode" /> 
  <xsl:variable name="bitfieldInitialValue">
   <xsl:call-template name="shifter">
    <xsl:with-param name="Answer"
select="$newNode/initialvalue" /> 
    <xsl:with-param name="decimalBitPos" 
select="$newNode/bitpos" /> 
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="newValue" select="$bitfieldInitialValue + $initialValue" /> 
   <xsl:choose>
    <xsl:when test="following-sibling::node()">
     <xsl:call-template name="calcInitialValue">
      <xsl:with-param name="initialValue" 
select="$newValue" /> 
      <xsl:with-param name="newNode" 
select="following-sibling::bitfield[1]" /> 
     </xsl:call-template>
    </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$newValue" /> 
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>




A small part of the xml file:


  <register name="control" offset="0">
    <no_of_regs>1</no_of_regs>  
    
    <bitfield name="DATA">
      <function>xxxxxx</function>
      <bitpos>0</bitpos>
      <no_of_bits>10</no_of_bits>
      <initialvalue>5</initialvalue>
      <accesstype>readonly</accesstype>
    </bitfield>
    <bitfield name="extra">
      <function>........</function>
      <bitpos>8</bitpos>
      <no_of_bits>4</no_of_bits>
      <initialvalue>1</initialvalue>
      <accesstype>read only</accesstype>
    </bitfield>    
  </register> 
 ..........
............ 
 



Thankyou for your time



Peter.





On Thu, 3 Oct 2002 16:29:14 +0100 David Carlisle 
<davidc@nag.co.uk> wrote:

> 
> 
>     <xsl:when test="following-sibling::node()">
> 
> That's your problem, when you do a call-template the current node
> doesn't change, so you spin here.
> 
> as far as I can see without running it everything is based on your
> newNode param and you want to know if there is something after that so
> 
>   <xsl:when test="$newNode/following-sibling::node()">
> 
> David
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service. For further
> information visit http://www.star.net.uk/stats.asp or alternatively call
> Star Internet for details on the Virus Scanning Service.
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

----------------------
Peter Doggett
ee99ppd@brunel.ac.uk


 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]