[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: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Jun 2020 16:16:58 -0000
Re:  getting "Cannot create an attribute node (...) who
Am 30.06.2020 um 18:10 schrieb Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx:
<xsl:variable name="new_atts">

<xsl:sequence select="$orig_atts"/>

</xsl:variable>


This doesn't copy the attribute nodes, it creates a document (fragment) node and tries to populate it with the $orig_atts, so that is not a meaningful approach, as document nodes or document fragment nodes can't contain attribute nodes, only element nodes can do that.

You can simply use

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

or

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

however, that will both bind the new variable to the existing attribute
nodes. If you really need a copy, use `xsl:copy-of` instead of
`xsl:sequence` or perhaps in XSLT 3.0 the `copy-of()` function.

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.