[ 
http://issues.apache.org/jira/browse/WSCOMMONS-114?page=comments#action_12448013
 ] 
            
Ruchith Udayanga Fernando commented on WSCOMMONS-114:
-----------------------------------------------------

Comments from the discussion in the mailing list:

On 11/8/06, Jeehong Min <[EMAIL PROTECTED]> wrote:

> there may also be a bug in the addAttribute(OMAttribute) function of
> OMElementImpl.java.  I don't think it is correctly handling unqualified
> ("" namespace, "" prefix) attributes.  In my local sources (Axiom
> 1.1.1), I have:

I think you are correct !

Right now we add the given ns (even though it is unqualified) with a
generated prefix into the list of declared namespaces of the element
where the attr is added. We should not be doing this in the case where
the unqualified OMNamespace instance is from an *attr*.

> OMElement has incorrect namespace after adding OMAttribute
> ----------------------------------------------------------
>
>                 Key: WSCOMMONS-114
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-114
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Using Axiom 1.1.1 binary distribution, Java 1.4.2_12, 
> Windows XP Professional
>            Reporter: Jeehong Min
>            Priority: Critical
>
> Run the code below that reproduces the issue.  Note that the namespace of 
> child is changed to "" after adding the attribute.  This appears to be a 
> regression since Axiom 1.0.  
> ----
> import java.io.*;
> import org.apache.axiom.om.*;
> public class AttributeHandling {
>     public static void main(String args[]) {
>         OMFactory fac = OMAbstractFactory.getOMFactory();
>         OMNamespace ns = fac.createOMNamespace("urn:foo", "");
>         OMElement titleElem = fac.createOMElement("title", ns);
>         OMNamespace ns2 = fac.createOMNamespace("urn:foo", "");
>         OMElement childElem = fac.createOMElement("child", ns2);
>         childElem.setText("boy");
>         titleElem.addChild(childElem);
>         String xml = titleElem.toString();
>         // expect <title xmlns="urn:foo"><child>boy</child></title>
>         System.out.println("xml = " + xml);
>         
>         // add attribute id="2"
>         OMNamespace idNs = fac.createOMNamespace("", "");
>         OMAttribute attr = fac.createOMAttribute("id", idNs, "2");
>         childElem.addAttribute(attr);
>         xml = titleElem.toString();
>         // expect <title xmlns="urn:foo"><child id="2">boy</child></title>
>         System.out.println("xml 2 = " + xml);
>         
>         OMOutputFormat format = new OMOutputFormat();
>         String charSetEnc = "UTF-8"; 
>         format.setCharSetEncoding(charSetEnc);
>         format.setSOAP11(true);
>         format.setDoOptimize(false);
>         try {
>             ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
>             titleElem.serializeAndConsume(bytesOut, format);
>             xml = new String(bytesOut.toByteArray());
>             // expect <title xmlns="urn:foo"><child id="2">boy</child></title>
>             System.out.println("xml 3 = " + xml);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to