You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Dave Brosius <db...@mebigfatguy.com> on 2008/02/06 07:30:35 UTC
cloneNode in extension functions
Hi folks,
I'm trying use cloneNode from a node retrieved from a extension function
parameter, or alternatively creating a node from node.getOwnerDocument on
the node that is the extension function parameter. I seem to be getting
errors of the form
SystemId Unknown; Line #8; Column #41; org.apache.xml.dtm.DTMDOMException:
Is this something that just can't be done, or am i doing something wrong?
Or instead should I just create my own document in the extension function
and add nodes to it, finally returning NodeLists from this document back to
the xsl file?
Thanks.
Re: cloneNode in extension functions
Posted by Raymond Auge <ra...@doublebite.com>.
Hi Dave,
I've used some simple workarounds to "make a copy" of a node. So, while
not cloning the node per say, in my case a copy was "good enough".
Perhaps it might be for you?
Mind, this uses an exslt function (which xalan-j supports of course).
e.g.:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
...
<xsl:variable name="cat_temp">
<xsl:for-each select="$category_blog">
<xsl:element name="category">
<xsl:attribute name="name"><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of
select="@type"/></xsl:attribute>
<xsl:attribute name="mode">blog</xsl:attribute>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="$category_podcast">
<xsl:element name="category">
<xsl:attribute name="name"><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of
select="@type"/></xsl:attribute>
<xsl:attribute name="mode">podcast</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="category_defs"
select="exsl:node-set($cat_temp)/category"/>
...
What this does is aggregate two node sets into a single one
(category_defs) so they could be sorted, etc...
Hope that helps,
Raymond Augé
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.
On Wed, 2008-02-06 at 01:30 -0500, Dave Brosius wrote:
> Hi folks,
>
> I'm trying use cloneNode from a node retrieved from a extension function
> parameter, or alternatively creating a node from node.getOwnerDocument on
> the node that is the extension function parameter. I seem to be getting
> errors of the form
>
> SystemId Unknown; Line #8; Column #41; org.apache.xml.dtm.DTMDOMException:
>
> Is this something that just can't be done, or am i doing something wrong?
>
> Or instead should I just create my own document in the extension function
> and add nodes to it, finally returning NodeLists from this document back to
> the xsl file?
>
>
> Thanks.
>
>
Re: cloneNode in extension functions
Posted by ke...@us.ibm.com.
Internally, Xalan uses a read-only data model (the DTM), which is has a
read-only DOM adapter layer wrapped around it when nodes are passed to
extension functions. The cloneNode operation, because it creates a new
node in the same Document as the original node, would break the read-only
behavior and is not permitted in this implementation.
If you need to create new instances of nodes, or modify them, create a new
DOM using your preferred implementation and copy/import the nodes into
that.
______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)