|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:attributes as parameter to a template
On 5/3/05, Jan Tietjens <jan.tietjens@xxxxxxxxxxxxxx> wrote: > Hello, > I am not understanding why the following xslt snipped produces an empty > 'someElement' element (XSLT 1.0): > > <xsl:template match="/"> > <xsl:call-template name="printSomeAttributes"> > <xsl:with-param name="attributes"> > <xsl:attribute name="juhu">Hello World!</xsl:attribute> > </xsl:with-param> > </xsl:call-template> > </xsl:template> > > <xsl:template name="printSomeAttributes"> > <xsl:param name="attributes"/> > <xsl:element name="someElement"> > <xsl:value-of select="$attributes"/> > </xsl:element> > </xsl:template> > If you run it with Saxon 8.4 the error message that is produced describes the cause of the problem very well: "Error at attribute constructor juhu="{...}" on line 6 of file:/C:/Program%20Files/Java/jdk1.5.0_01/bin/marrowtr.xsl: XTDE0410: Cannot create an attribute node whose parent is a document node Transformation failed: Run-time errors were reported" Saxon 6.5.3 produces also a good message: "Recoverable error at xsl:attribute on line 6 of file:/(Untitled): Cannot write an attribute node when no element start tag is open" What is happening is that the previous node produced is not an element (in fact it is a root node), so the attribute (even if created) cannot be attached to an element node. The result is either an error (in XSLT 2.0) or a recoverable error (as in XSLT 1.0) in which case no attribute is present in the output. Cheers, Dimitre Novatchev
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






