[ 
https://issues.apache.org/jira/browse/AXIOM-487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15560620#comment-15560620
 ] 

Andreas Veithen commented on AXIOM-487:
---------------------------------------

In this particular case the recommendation is to fix the application code to 
use setAttributeNS to create the namespace declaration. The reason is that DOM 
itself doesn't recognize namespace declarations added using setAttribute.

On the Axiom side, the issue will be fixed in 1.3.0, but that change will not 
be backported to 1.2.x because the code is significantly different.

> IllegalStateException when processing DOMSource with namespace unaware 
> attributes
> ---------------------------------------------------------------------------------
>
>                 Key: AXIOM-487
>                 URL: https://issues.apache.org/jira/browse/AXIOM-487
>             Project: Axiom
>          Issue Type: Bug
>          Components: DOOM, LLOM
>    Affects Versions: 1.2.17, 1.2.19
>            Reporter: Victor
>            Priority: Minor
>
> Hello,
> I tried to parse a java.xml.transform.Source (a DOMSource) using the 
> following code:
> {code}
> final OMXMLParserWrapper builder = 
> OMXMLBuilderFactory.createOMBuilder(factory, source);
> final OMElement bodyContent = builder.getDocumentElement();
> {code}
> The document contains:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <tns:executeJobResponse 
> xmlns:tns="http://petals.ow2.org/talend/ArticleImporterJob/"; 
> xmlns:jaxb="http://jaxb.dev.java.net/array";
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>     <tns:talend-job-output>
>         <tns:executionResult>
>             <jaxb:item>0</jaxb:item>
>         </tns:executionResult>
>         <tns:outAttachment>
>             <tns:fileResult>
>                 <tns:fileContent>
>                     <xop:include 
> xmlns:xop="http://www.w3.org/2004/08/xop/include"; href="cid:fileResult" />
>                 </tns:fileContent>
>             </tns:fileResult>
>         </tns:outAttachment>
>     </tns:talend-job-output>
> </tns:executeJobResponse>
> {code}
> And I got the following error:
> {noformat}
> java.lang.IllegalStateException
>       at 
> org.apache.axiom.om.impl.common.AxiomNamedInformationItemSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomNamedInformationItemSupport$org_apache_axiom_om_impl_intf_AxiomNamedInformationItem$updateLocalName(AxiomNamedInformationItemSupport.aj:142)
>       at 
> org.apache.axiom.om.impl.llom.OMAttributeImpl.updateLocalName(OMAttributeImpl.java:1)
>       at 
> org.apache.axiom.om.impl.common.AxiomNamedInformationItemSupport.ajc$interMethodDispatch1$org_apache_axiom_om_impl_common_AxiomNamedInformationItemSupport$org_apache_axiom_om_impl_intf_AxiomNamedInformationItem$updateLocalName(AxiomNamedInformationItemSupport.aj)
>       at 
> org.apache.axiom.om.impl.common.AxiomNamedInformationItemSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomNamedInformationItemSupport$org_apache_axiom_om_impl_intf_AxiomNamedInformationItem$coreGetLocalName(AxiomNamedInformationItemSupport.aj:147)
>       at 
> org.apache.axiom.om.impl.llom.OMAttributeImpl.coreGetLocalName(OMAttributeImpl.java:1)
>       at 
> org.apache.axiom.core.NSAwareAttributeMatcher.getName(NSAwareAttributeMatcher.java:84)
>       at 
> org.apache.axiom.core.CoreElementSupport.ajc$interMethod$org_apache_axiom_core_CoreElementSupport$org_apache_axiom_core_CoreElement$coreSetAttribute(CoreElementSupport.aj:96)
>       at 
> org.apache.axiom.om.impl.llom.OMElementImpl.coreSetAttribute(OMElementImpl.java:1)
>       at 
> org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf_AxiomElement$internalAppendAttribute(AxiomElementSupport.aj:282)
>       at 
> org.apache.axiom.om.impl.llom.OMElementImpl.internalAppendAttribute(OMElementImpl.java:1)
>       at 
> org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethodDispatch1$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf_AxiomElement$internalAppendAttribute(AxiomElementSupport.aj)
>       at 
> org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf_AxiomElement$addAttribute(AxiomElementSupport.aj:296)
>       at 
> org.apache.axiom.om.impl.llom.OMElementImpl.addAttribute(OMElementImpl.java:1)
>       at 
> org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethodDispatch1$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf_AxiomElement$addAttribute(AxiomElementSupport.aj)
>       at 
> org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf_AxiomElement$addAttribute(AxiomElementSupport.aj:312)
>       at 
> org.apache.axiom.om.impl.llom.OMElementImpl.addAttribute(OMElementImpl.java:1)
>       at 
> org.apache.axiom.om.impl.builder.StAXBuilder.processAttributes(StAXBuilder.java:247)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.populateOMElement(StAXOMBuilder.java:418)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.createOMElement(StAXOMBuilder.java:434)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.createNextOMElement(StAXOMBuilder.java:298)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:215)
>       at 
> org.apache.axiom.core.CoreParentNodeSupport.ajc$interMethod$org_apache_axiom_core_CoreParentNodeSupport$org_apache_axiom_core_CoreParentNode$buildNext(CoreParentNodeSupport.aj:96)
>       at 
> org.apache.axiom.om.impl.llom.OMDocumentImpl.buildNext(OMDocumentImpl.java:1)
>       at 
> org.apache.axiom.core.CoreParentNodeSupport.ajc$interMethodDispatch1$org_apache_axiom_core_CoreParentNodeSupport$org_apache_axiom_core_CoreParentNode$buildNext(CoreParentNodeSupport.aj)
>       at 
> org.apache.axiom.core.CoreParentNodeSupport.ajc$interMethod$org_apache_axiom_core_CoreParentNodeSupport$org_apache_axiom_core_CoreParentNode$coreGetFirstChild(CoreParentNodeSupport.aj:113)
>       at 
> org.apache.axiom.om.impl.llom.OMDocumentImpl.coreGetFirstChild(OMDocumentImpl.java:1)
>       at 
> org.apache.axiom.core.CoreParentNodeSupport.ajc$interMethodDispatch1$org_apache_axiom_core_CoreParentNodeSupport$org_apache_axiom_core_CoreParentNode$coreGetFirstChild(CoreParentNodeSupport.aj)
>       at 
> org.apache.axiom.core.CoreDocumentSupport.ajc$interMethod$org_apache_axiom_core_CoreDocumentSupport$org_apache_axiom_core_CoreDocument$coreGetDocumentElement(CoreDocumentSupport.aj:42)
>       at 
> org.apache.axiom.om.impl.llom.OMDocumentImpl.coreGetDocumentElement(OMDocumentImpl.java:1)
>       at 
> org.apache.axiom.om.impl.common.AxiomDocumentSupport.ajc$interMethod$org_apache_axiom_om_impl_common_AxiomDocumentSupport$org_apache_axiom_om_impl_intf_AxiomDocument$getOMDocumentElement(AxiomDocumentSupport.aj:32)
>       at 
> org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:1)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:554)
>       at 
> org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:550)
> {noformat}
> Here is a simple executable example of the problem:
> {code}
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.parsers.ParserConfigurationException;
> import javax.xml.transform.dom.DOMSource;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMXMLBuilderFactory;
> import org.apache.axiom.om.OMXMLParserWrapper;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> public class AxiomTest {
>     public static final String XSI_TNS = 
> "http://www.w3.org/2001/XMLSchema-instance";;
>     public static void main(String[] args) throws 
> ParserConfigurationException {
>         Document outputDocument = 
> DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
>         Element rootElement = outputDocument.createElementNS("http://test/";, 
> "tns:executeJobResponse");
>         outputDocument.appendChild(rootElement);
>         rootElement.setAttribute("xmlns:xsi", XSI_TNS);
>         final OMXMLParserWrapper builder = 
> OMXMLBuilderFactory.createOMBuilder(new DOMSource(outputDocument));
>         final OMElement bodyContent = builder.getDocumentElement();
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ws.apache.org
For additional commands, e-mail: dev-h...@ws.apache.org

Reply via email to