Title: Message
Ok, here's the code...
 
    public Document process(Document document) throws Exception
    {
        System.out.println("Processiong TrasnformProcessor = ");
 
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(new DocumentSource(oplet));
 
        // now lets create the TrAX source and result objects and do the transformation
        DocumentSource source = new DocumentSource(document);
        DocumentResult result = new DocumentResult();
 
        transformer.transform( source, result );
        System.out.println("Trasnformation successful");
        return result.getDocument();
    }
I've attached the XSLT file, just in case something in there is causing this.
 
The xml file itself start out like this:
 
 
<?xml-stylesheet type="text/xsl" href="C:\opl1.1\cXML.xslt"?>
<cXML payloadID="[EMAIL PROTECTED]" timestamp="1999-03-12T18:39:09-08:00">
    <Header>
        <From>
            <Credential domain="AribaNetworkUserId">

... blah blah blah.

 
-----Original Message-----
From: James Strachan [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 30, 2001 11:17 AM
To: David Hooker; [EMAIL PROTECTED]
Subject: Re: [dom4j-user] Another error

Are you reusing the same DocumentResult object on two transformations by any chance? (Though a quick look at the code looks like this shouldn't be a problem).
 
If not could you send an example snippet of code and we can try fix it? It appears that a second <payloadID> element is being added to the document result when it already contains one. Are you using a special DocumentFactory?

James
----- Original Message -----
Sent: Friday, November 30, 2001 5:02 PM
Subject: [dom4j-user] Another error

Sorry for all the questions about errors... I just don't know enough about all this XML stuff yet.
 
I have a program which is trying to transform some XML.  The transform code I'm using is straight out of the dom4j cookbook.  The transformation works from Xalan's command line, but not in my program.  Below is the error message I'm seeing.  Can someone point me in the right direction?
 
 
org.dom4j.IllegalAddException: The node "org.dom4j.tree.DefaultElement@e57e8f [Element: <payloadID a
ttributes: []/>]" could not be added to the branch "null" because: Cannot add another element to thi
s Document as it already has  a root element of: payloadID
javax.xml.transform.TransformerException: org.dom4j.IllegalAddException: The node "org.dom4j.tree.De
faultElement@e57e8f [Element: <payloadID 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: payloadID
 
        at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1226)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:638)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1088)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1066)

Attachment: aa1.ZIP
Description: Binary data

Reply via email to