Thanks Jim.
I have put together a template based on everyones advice.
However when it is called the XSLT processor seems to
compile indefinately.
Here is the template:
<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>
..........
............
the template is called ok, and in the correct part of the
tree (i can access the required values from the xml when
the template isnt being recursive).
also the recursive
template 'shifter' has also been tested and works
correctly. the only problem I could think of is the fact
that each recursive call calls the recursive template
'shifter', but you guys have just told me this is legal?
It is either that or the 'choose' statement isnt picking up
the last <bitfield> node (as if i do an always true test I
get the same compiler lock-up).
Any ideas?
Thanks
PD
On Mon, 30 Sep 2002 17:30:11 +0100 James Fuller
<james(_dot_)fuller(_at_)o-idev(_dot_)com> wrote:
I am aware of the call-template tag.
then u must know that you can pass it a parameter.
http://www.vbxml.com/xsl/elmxsl_call-template.asp
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?
pass a parameter
Below it is done by the select attribute, which
<call-template> does not have?
http://www.dpawson.co.uk/xsl/sect2/N1711.html
Thanks for the book reference. I have just ordered
Michael Kays XSLT Programmers reference, but I may add that
to my shopping list to.
yes, yes also Jeni Tennison's Beginning XSLT is appropriate.
gl, jim fuller
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