[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: getting "Cannot create an attribute node (...) who

Subject: Re: getting "Cannot create an attribute node (...) whose parent is a document node" when copying attribute nodes through an XSLT function
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Jun 2020 16:17:15 -0000
Re:  getting "Cannot create an attribute node (...) who
On Tue, Jun 30, 2020 at 04:10:23PM -0000, Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx scripsit:
> Hello! Language is XSLT 2.0, processor is Saxon-PE 9.9.1.7 in Oxygen XML Editor v22.1.
> 
> I'm trying to pass attribute nodes from an element template to a function, make a modified copy of the attributes inside the function, then return them for inclusion in the element. But when I attempt this, I get
> 
> Cannot create an attribute node (class) whose parent is a document node.

You put the attributes in a variable:

<xsl:variable name="new_atts">
    <xsl:sequence select="$orig_atts"/>
</xsl:variable>

By default, any untyped variable will be created as a document node.

You avoid that by using "as" to specify a type, specifically that this
variable is a sequence of one or more attributes:

<xsl:variable name="new_atts" as="attribute()+">
    <xsl:sequence select="$orig_atts"/>
</xsl:variable>

(Possibly zero or more, which would make it "attribute()*".

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.