[
http://issues.apache.org/jira/browse/WSCOMMONS-74?page=comments#action_12430235
]
Rich Scheuerle commented on WSCOMMONS-74:
-----------------------------------------
I am still confused by Eran's last set of comments. Were there some comments
outside this issue ?
Glen's rule: createOMElement("localName", null) should be an unqualified
element (no namespace).
* Problem: Making such a change will break exisiting code and tests.
Eran's rule and current code: createOMElement("localName", null) should create
an element in the default namespace (the namespace defined by the xmlns=<ns> in
scope). This essentially means that the choice
of the namespace is deferred until the element is attached or until
setDefaultNamespace is used on the element.
* Problem: This rules means that the namespace of the element cannot be
determined without contextural information about the element's scope. As the
element moves around
the namespace changes.
-----------------------------------------------
Ruchith,
I can look into the problem with the security xml. Are you sure this is a
serialization problem (and not a model problem) ?
I have not debugged, but here is my suspicion.
A) The Signature element is qualified and using the default namespace to
define its namespace.
B) The Algorithm attribute of CanonicalizationMethod is an unqualified
attribute. This may be forcing a OMNamespace("", "") onto the
OMElement for CanonicalizationMethod.
C) The serialization logic writes out all of the namespaces ...including the
one for OMNamespace("", ""). The serialization logic cannot (and never could)
determine
why a namespace gets into the declared namespace list.
D) xmlns="" is written out.
The root of the problem is that an attribute (per schema spec) can never be
defined with a default namespace. The corrollary is that an attribute refrence
witout a prefix is
always an unqualified attribute.
A quick inspection of the code indicates that the OMElementImpl logic is not
aware of this distinction. The solution may be:
a) make sure that adding an Attribute without a prefix always adds an
unqualified Attribute.
b) adding an unqualified Attribute SHOULD NOT change the declared
namespaces on the element.
I am away from work on personal reasons. It will be several days before I can
do more investigation. If someone wants to jump in and try a solution, please
be my guest.
> Incorrect namespace serialization
> ---------------------------------
>
> Key: WSCOMMONS-74
> URL: http://issues.apache.org/jira/browse/WSCOMMONS-74
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Reporter: Ruchith Udayanga Fernando
> Assigned To: Rich Scheuerle
> Priority: Blocker
> Attachments: axiom_api_patch.txt, axiom_impl_patch.txt,
> axiom_test_patch.txt, jaxsw_test_patch.txt, SerializationTest.java
>
>
> Hi All,
> I noticed that axiom doesn't serialize namespaces correctly.
> 1.) Namespaces in qualified elements
> For example we should be able to produce the following xml with the code that
> follows:
> <person1 xmlns="http://ws.apache.org/axis2/apacheconasia/06">
> <name>John</name>
> <name>John12</name>
> <age>34</age>
> </person1>
> OMFactory fac = OMAbstractFactory.getOMFactory();
>
> OMNamespace ns =
> fac.createOMNamespace("http://ws.apache.org/axis2/apacheconasia/06", "");
> OMElement personElem = fac.createOMElement("person", ns);
> OMElement nameElem = fac.createOMElement("name", ns);
> nameElem.setText("John");
>
> OMElement ageElem = fac.createOMElement("age", ns);
> ageElem.setText("34");
>
> OMElement weightElem = fac.createOMElement("weight", ns);
> weightElem.setText("50");
>
>
> //Add children to the person element
> personElem.addChild(nameElem);
> personElem.addChild(ageElem);
> personElem.addChild(weightElem);
>
> String xml = personElem.toString();
> But right now this produces the following :
> <person xmlns="http://ws.apache.org/axis2/apacheconasia/06"><name
> xmlns="http://ws.apache.org/axis2/apacheconasia/06">John</name><age
> xmlns="http://ws.apache.org/axis2/apacheconasia/06">34</age><weight
> xmlns="http://ws.apache.org/axis2/apacheconasia/06">50</weight></person>
> The repetition of the default namespace should be avoided.
> This is the same even if we used a prefixed namespace.
> 2.) Unqualified elements among qualified elements
>
> OMFactory fac = OMAbstractFactory.getOMFactory();
> OMNamespace ns =
> fac.createOMNamespace("http://ws.apache.org/axis2/apacheconasia/06", "");
> OMElement personElem = fac.createOMElement("person", ns);
> //Create and add an unqualified element
> OMElement nameElem = fac.createOMElement("name", null);
> nameElem.setText("John");
> personElem.addChild(nameElem);
> OMElement ageElem = fac.createOMElement("age", ns);
> ageElem.setText("34");
>
> OMElement weightElem = fac.createOMElement("weight", ns);
> weightElem.setText("50");
> personElem.addChild(ageElem);
> personElem.addChild(weightElem);
> System.out.println(personElem);
> The above should produce the following :
> <person xmlns="http://ws.apache.org/axis2/apacheconasia/06"><name
> xmlns="">John</name><age>34</age><weight>50</weight></person>
> But AXIOM right now produces :
> <person
> xmlns="http://ws.apache.org/axis2/apacheconasia/06"><name>John</name><age
> xmlns="http://ws.apache.org/axis2/apacheconasia/06">34</age><weight
> xmlns="http://ws.apache.org/axis2/apacheconasia/06">50</weight></person>
> What do u folks think?
> Thanks,
> Ruchith
> p.s. Added a test case
--
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]