xsl-list
[Top] [All Lists]

RE: Repeated Recursion on different parts of a tree

2002-09-30 08:04:47


Ok thanks James.

I am aware of the call-template tag.

However the issue I have was with the fact that 
if I was to call the template by name, how would I deal 
with the fact that I want to use the first <bitfield> node, 
and then the next and then the next etc.. with each pass of 
recursion?

Below it is done by the select attribute, which 
<call-template> does not have?

Thanks for the book reference. I have just ordered 
Michael Kays XSLT Programmers reference, but I may add that 
to my shopping list to.


Thanks


PD





On Mon, 30 Sep 2002 14:12:34 +0100 James Fuller 
<james(_dot_)fuller(_at_)o-idev(_dot_)com> wrote:

my god, do you think you will learn a computer language without having a
basic reference ?

the 'hunt and peck handbook of learning XSLT' ......u nearly answered your
own question !

try <xsl:call-template/> tag.

chow, jim fuller

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of 
Peter Doggett
Sent: 30 September 2002 13:58
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Repeated Recursion on different parts of a tree




Hello,

Is there anyway I can perform the below operation by
'calling' a template by name, instead of using a template
match?

 <xsl:template match="register">
  ... <xsl:apply-templates select="bitfield[1]"/>....


 with
 <xsl:template match="bitfield">
   <xsl:param  ... whatever parameters you need .../>
     ... some sums ...
   <xsl:apply-templates
select="following-sibling::bitfield[1]">
    <xsl:with-param ... new values passed to the next
   </xsl:apply-templates>
 ...


My XML looks like:

<register name="DATA" offset="0">
    <no_of_regs>1</no_of_regs>
    <descriptivename>Data register</descriptivename>
    <description>The ...ster.</description>
    <description>In ord..H.</description>
    <description>..Oe...</description>
    <bitfield name="DATA">
      <function>Input data.</function>
      <bitpos>0</bitpos>
      <no_of_bits>10</no_of_bits>
      <initialvalue>0</initialvalue>
      <accesstype>R</accesstype>
    </bitfield>
    <bitfield name="CONTROL">
      <function>Output data</function>
      <bitpos>10</bitpos>
      <no_of_bits>6</no_of_bits>
      <initialvalue>0</initialvalue>
      <accesstype>RW</accesstype>
    </bitfield>
etc..........

</register>

<register name="SWAP" offset="10">
    <no_of_regs..........

(I want to use values in each bitfield to create an
expression for the whole <register> e.g output document to
look like - Register DATA initialValue = X......)

My existing XSL stylesheet already has a few templates
which are called 'by name'. So when I implement the above,
I an getting junk in my output document. (actually I seem
to get the source xml element value output for each first
<bitfield> element)

Therefore I would like to call the template by name so as
not to incur these side effects. Any ideas?


Thankyou


PD





On Thu, 26 Sep 2002 13:00:20 +0100 David Carlisle
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:


cant dynamically update a variable in XSL while traversing the tree.

you just need to make your variable a parameter to your template and
pass on the parameter at the same time as traversing the tree.
You;ll probably want to traverse th etree one at a time rather than
applying templates to a set of sibling nodes at the same time as that
helps keep ones notion of paremeter passing and template invocation in
sync.

that is, instead of doing

<xsl:template match="register">
 ... <xsl:apply-templates select="bitfield"/>....

do


<xsl:template match="register">
 ... <xsl:apply-templates select="bitfield[1]"/>....


with
<xsl:template match="bitfield">
  <xsl:param  ... whatever parameters you need .../>
    ... some sums ...
  <xsl:apply-templates select="following-sibling::bitfield[1]">
   <xsl:with-param ... new values passed to the next
  </xsl:apply-templates>
...

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(_at_)brunel(_dot_)ac(_dot_)uk


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


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


----------------------
Peter Doggett
ee99ppd(_at_)brunel(_dot_)ac(_dot_)uk


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