You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Brian Dupras <br...@centera.com> on 2000/02/03 17:20:53 UTC

WRONG_DOCUMENT_ERR

I'm trying to track down a bug in my code, but i'm having some trouble.  Any
help is greatly appreciated.

I've written the following function to transform an XML Element through an
XSL Document, and store the results as children of another XML Element:

public static void transformElement(Element xmlSource, Document xsl, Element
xmlTarget) 
	throws SAXException {
	XSLTProcessor xsltProcessor = XSLTProcessorFactory.getProcessor(new
org.apache.xalan.xpath.xdom.XercesLiaison());
	xsltProcessor.process(	new XSLTInputSource(xmlSource), 
					new
XSLTInputSource(xsl.getDocumentElement()), 
					new XSLTResultTarget(xmlTarget)
					);
	} //transformElement


However, I'm gettnig a WRONG_DOCUMENT_ERR.  I'm not sure which part I'm
doing wrong.  Any clues from the above?

For xmlSource, I'm passing an Element Node <pp:component> deep inside one
document tree.
For xmlTarget, I'm passing an Element Node <html:span> that is owned by a
different Document.
xsl is a new Document that holds the xsl transform.



the xsl:

<?xml version="1.0"?>

<xsl:stylesheet	
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:html='http://www.w3.org/1999/xhtml'
	exclude-result-prefixes="html"
	>
	
    <xsl:output 
		method="xml" 
		indent="yes"
		omit-xml-declaration="yes" 
		/>
	
	<xsl:template match="/">
	</xsl:template>

</xsl:stylesheet>






I'm getting this on the stderr:

WRONG_DOCUMENT_ERR
org.apache.xerces.dom.DOMExceptionImpl: WRONG_DOCUMENT_ERR
	at
org.apache.xerces.dom.NodeImpl.internalInsertBefore(NodeImpl.java, Compiled
Code)
	at org.apache.xerces.dom.NodeImpl.insertBefore(NodeImpl.java,
Compiled Code)
	at org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java,
Compiled Code)
	at
org.apache.xalan.xpath.xml.FormatterToDOM.append(FormatterToDOM.java:129)
	at
org.apache.xalan.xpath.xml.FormatterToDOM.characters(FormatterToDOM.java:328
)
	at
org.apache.xalan.xslt.XSLTEngineImpl$ResultTreeHandler.characters(XSLTEngine
Impl.java, Compiled Code)
	at
org.apache.xalan.xslt.XSLTEngineImpl.cloneToResultTree(XSLTEngineImpl.java:1
810)
	at
org.apache.xalan.xslt.ElemTemplateElement.transformChild(ElemTemplateElement
.java:976)
	at
org.apache.xalan.xslt.ElemTemplateElement.transformSelectedChildren(ElemTemp
lateElement.java, Compiled Code)
	at
org.apache.xalan.xslt.ElemApplyTemplates.execute(ElemApplyTemplates.java:147
)
	at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
t.java, Compiled Code)
	at org.apache.xalan.xslt.ElemTemplate.execute(ElemTemplate.java:141)
	at org.apache.xalan.xslt.StylesheetRoot.process(StylesheetRoot.java,
Compiled Code)
	at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java,
Compiled Code)
	at com.medwired.pp.XmlHelper.transformElement(XmlHelper.java:65)
	at
com.medwired.pp.components.StaticStory.render(StaticStory.java:27)
	at jsp.medwired.pagetest.pagegen.renderComponent(pagegen.java:312)
	at jsp.medwired.pagetest.pagegen.renderComponents(pagegen.java,
Compiled Code)
	at jsp.medwired.pagetest.pagegen._jspService(pagegen.java:130)
	at
com.livesoftware.jsp.HttpJSPServlet.service(HttpJSPServlet.java:31)
	at com.livesoftware.jsp.JSPServlet.service(JSPServlet.java:118)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
	at com.livesoftware.jrun.JRun.runServlet(JRun.java, Compiled Code)
	at
com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java:116)
	at
com.livesoftware.jrun.JRunGeneric.handleProxyConnection(JRunGeneric.java:78)
	at
com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(JR
unProxyServiceHandler.java:102)
	at
com.livesoftware.jrun.service.ThreadConfigHandler.run(ThreadConfigHandler.ja
va, Compiled Code)


Brian Dupras
Centera Information Systems, Inc.
phone	303.939.0200 x294
fax	303.939.0111
web	http://www.centera.com
email	briand@centera.com

Re: WRONG_DOCUMENT_ERR

Posted by Andy Clark <an...@apache.org>.
Brian Dupras wrote:
> However, I'm gettnig a WRONG_DOCUMENT_ERR.  I'm not sure which part I'm
> doing wrong.  Any clues from the above?

The DOM Level 1 explicitly disallows nodes created with one
document factory from being inserted into another document.
DOM Level 2 addresses this problem with the importNode() 
method. Our DOM implementation has always had this method;
DOM Level 2 just makes it standard.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org