I found next problem similar to the above. 

Tuomas Kiviaho wrote:
>  
>               Result result = new DOMResult();
>               ClassLoader classLoader = Thread.currentThread()
>                               .getContextClassLoader();
>               TransformerFactory transformerFactory = 
> TransformerFactory.newInstance(
>                               
> "org.apache.xalan.processor.TransformerFactoryImpl",
>                               classLoader);
>               Transformer transformer = transformerFactory.newTransformer();
>               transformer.transform(source, result);  
> 

When DOMResult instead of SAXResult (this time with identity transformer)
I'm encountering the following error.  

org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or
change an object in a way which is incorrect with regard to namespaces.
        at org.apache.xerces.dom.ElementNSImpl.setName(Unknown Source)
        at org.apache.xerces.dom.ElementNSImpl.<init>(Unknown Source)
        at org.apache.xerces.dom.CoreDocumentImpl.createElementNS(Unknown 
Source)
        at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:328)
        at
org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073)

DOMBuilder.startElement states the following where the error occured. 

// Note that the namespace-aware call must be used to correctly
// construct a Level 2 DOM, even for non-namespaced nodes.
if ((null == ns) || (ns.length() == 0))
  elem = m_doc.createElementNS(null,name);
else
  elem = m_doc.createElementNS(ns, name);

Document.createElementNS javadoc states that parsing is attempted for qname
which leads to the error. 
I discovered the following from Xerces implementation which would solve this
issue.

boolean domLevel20 =
source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0");
// Create element according to namespace support/qualification.
if(domLevel20 == false || source.getLocalName() == null)
  newElement = createElement(source.getNodeName());
else
  newElement = createElementNS(source.getNamespaceURI(),
source.getNodeName());
-- 
View this message in context: 
http://www.nabble.com/%27prefixed%27-node-names-without-namespace-awareness-causes-problems-with-ToXMLSAXHandler-tp25343671p25345295.html
Sent from the Xalan - J - Users mailing list archive at Nabble.com.

Reply via email to