This looks to be an interesting error...
You might want to debug a little bit (using `echo`) the classes of the toc and book results of XSLT.
At such an error, I would understand that both are either document objects or, at least, are roots of document objects hence not free elements.
Using something <j:set var="dtoc">${toc.detach()}</j:set> might actually help you to avoid that... at worst use ${toc.createCopy()} which is a deep clone.


Hope that helps.

Paul

Brett Porter wrote:
I'm not an expert on jelly xml, but my guess is that its something to do
with loading sample1.xml twice. Are you sure the parameters on the transform
tag do what you think they do?

- Brett


-----Original Message-----
From: Pavel Sher [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 10:32 PM
To: [EMAIL PROTECTED]
Subject: XML tag library



Hello,


When I am trying to process the following Jelly script I've got the error: [java] org.apache.commons.jelly.JellyTagException: file:/C:/Work/SDS/templates/sample1.xhtml:31:105: <x:transform> The node "[EMAIL PROTECTED] [Element: <h1 attributes: []/>]" could not be added to the branch "null" because: Cannot add another element to this Document as it already has a root element of: h1
[java] at org.apache.commons.jelly.impl.TagScript.handleException(TagScr
ipt.java:683)



Script:


<?xml version="1.0"?>
<j:jelly xmlns="http://my.uri.com"; xmlns:j="jelly:core" xmlns:x="jelly:xml"> ${systemScope.setProperty('javax.xml.transform.TransformerFact
ory','net.sf.saxon.TransformerFactoryImpl')}
${systemScope.setProperty('org.xml.sax.driver','org.apache.xer

ces.parsers.SAXParser')}


<html>
<head>
   <title>The first sample</title>
</head>
<body>

<x:transform xslt="${basedir}/stylesheets/sample1-toc.xsl" xml="${basedir}/xml/sample1.xml" var="toc"/>
<x:transform xslt="${basedir}/stylesheets/sample1.xsl" xml="${basedir}/xml/sample1.xml" var="book"/>


   <table border="1" cellspacing="0" cellpadding="0">
   <tr>
       <td>Table Of Contents</td>
   </tr>
   <tr>
       <td>
           <!-- TOC -->
           <x:copyOf select="$toc"/>
           <!-- TOC -->
       </td>
   </tr>
   </table>

   <table border="0" cellspacing="0" cellpadding="0">
   <tr>
       <td>
           <!-- BODY -->
           <x:copyOf select="$book"/>
           <!-- BODY -->
       </td>
   </tr>
   </table>

</body>
</html>
</j:jelly>

If I use comment out second <x:transform var="book"/> and remove second <x:copyOf/> then the script works fine. Maybe somebody knows why?

--
Best regards

Pavel Sher, [EMAIL PROTECTED]







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to