RE: [xsl] Cannot write an attribute node when no element start tag is open [was mistitled]

Subject: RE: [xsl] Cannot write an attribute node when no element start tag is open [was mistitled]
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 14 May 2004 15:35:46 +0100
You get this error message from Saxon if you write

<e>
   some text
   <xsl:attribute name="a">3</xsl:attribute>
</e>

In your case the attribute is written from within a called template but the
effect is the same.

You can't add an attribute to an element after adding children to the
element.

Probably your previous XSLT processor was ignoring the error. It's one of
those recoverable errors that a processor is not obliged to report. The
fallback action is to ignore the attribute node.

Michael Kay 

> -----Original Message-----
> From: Shiva.Sadayan@xxxxxxxxxxxxxxxxxxxxxxxx 
> [mailto:Shiva.Sadayan@xxxxxxxxxxxxxxxxxxxxxxxx] 
> Sent: 14 May 2004 12:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] dynamically generated XSL that needs to 
> include namespace for extension functions
> 
> Hi,
> Can someone tell what error is this?
> 
> 	*** Cannot write an attribute node when no element 
> start tag is open
> ***
> 
> 
> *****Background story******
> This Code was working all right in Apache, recently we started to use
> RenderX.  
> 
> 
> <xsl:template name="questhead">
> 	<xsl:param name="MailName"/>
> 	<xsl:param name="BirthDate"/>
> 	<xsl:param name="ReferenceCode"/>
> 	<xsl:param name="BorderStyle"/>
> 
> 	<xsl:attribute name="border-before-style"><xsl:value-of
> select="$BorderStyle"/></xsl:attribute>
> 	<xsl:attribute name="border-start-style"><xsl:value-of
> select="$BorderStyle"/></xsl:attribute>
> 	<xsl:attribute name="border-end-style"><xsl:value-of
> select="$BorderStyle"/></xsl:attribute>
> 
> 
> Cheers
> 
> Shiva S.
> 
> -----Original Message-----
> From: Michael Kay [mailto:mhk@xxxxxxxxx]
> Sent: 14 May 2004 13:43
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] dynamically generated XSL that needs to include
> namespace for extension functions
> 
> 
> > 
> > I am using a stylesheet to generate XSL within an 
> > xsl:document command.
> 
> Not sure what you mean by the xsl:document "command" - do you 
> mean the XSLT
> 1.1 instruction of that name?
> > 
> > The problem I have is that I want to include the xmlns:str 
> > namespace to my
> > generated stylesheet so that I can use the EXSLT string function
> > uri-decode().
> 
> XSLT 2.0 has an xsl:namespace instruction for this purpose. 
> In 1.0 there is
> a workaround: copy the namespace from a source document. E.g.
> 
> <xsl:variable name="dummy">
>   <str:dummy xmlns:str="the namespace"/>
> </xsl:variable>
> 
> <xsl:copy-of select="xx:node-set($dummy)//namespace::str"/>
> 
> Michael Kay
> 
> (XQuery, incidentally, decided not to provide this 
> capability. I think I
> will start pointing out all the things you can do with XSLT 
> 2.0 and not with
> XQuery 1.0, just in case anyone believes that Microsoft have got it
> right...)
> 
> 
> 
> ______________________________________________________________
> 
> CONFIDENTIALITY NOTICE
> 
> This communication and the information it contains is 
> intended for the person or organisation to 
> whom it is addressed.  Its contents are confidential and may 
> be protected in law.  Unauthorised use,
>  copying or disclosure of any of it may be unlawful.  If you 
> are not the intended recipient, please 
> contact us immediately.
> 
> The contents of any attachments in this e-mail may contain 
> software viruses, which could damage your 
> own computer system.  While Marlborough Stirling has taken 
> every reasonable precaution to minimise 
> this risk, we cannot accept liability for any damage, which 
> you sustain as a result of software 
> viruses.  You should carry out your own virus checking 
> procedure before opening any attachment.
> 
> 
> Marlborough Stirling plc, Registered in England and Wales 
> Registered No. 3008820,
> Allen Jones House, Jessop Avenue, Cheltenham, 
> Gloucestershire, GL50 3SH
> Tel: 01242 547000     Fax: 01242 547100
> http://www.marlborough-stirling.com

Current Thread