Re: Is it possible to merge attributes from multiple elements?

Subject: Re: Is it possible to merge attributes from multiple elements?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sun, 18 Jun 2000 09:42:29 +0100

Your problem lies in the line where you set the $attrs variable:

  <xsl:variable name="attrs"><xsl:value-of select="@*"/><xsl:variable>

When you set a variable using the *content* of the xsl:variable element, the content is converted into a 'result tree fragment'.  Result tree fragments are like clips of output: you can slot them into your output, but (in standard XSL) you can't process them as input.  The things you *can* process as input are 'node sets'.  The reason your XSL processors are complaining is that you're implicitly converting the result tree fragment into a node set when you try to iterate over its contents.

You want to set your $attrs variable to the *node set* that contains the attributes of the 'row' element, so that you can iterate over them later and include them on your table cells.  The way that you do this is to use the 'select' attribute on xsl:variable:

  <xsl:variable name="attrs" select="@*" />

Making this change makes your template work in SAXON.

So, basically, if you're using a variable to identify specific nodes for processing, then use the 'select' attribute, but if you're using it to hold a clip of output, use the content.

I hope that helps,


P.S. An alternative approach is to convert your result tree fragment into a node set using an extension function, but if you can solve a problem without using an extension function, then you may as well do so.

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx

 XSL-List info and archive:

Current Thread