|
Subject: Re: [xsl] 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 |
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.")
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] getting "Cannot create an, Martin Honnen martin | Thread | Re: [xsl] getting "Cannot create an, Norman Tovey-Walsh n |
| Re: [xsl] getting "Cannot create an, Martin Honnen martin | Date | Re: [xsl] getting "Cannot create an, Norman Tovey-Walsh n |
| Month |