You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Yechiel Mondrowitz (JIRA)" <ji...@apache.org> on 2007/08/28 22:17:31 UTC

[jira] Created: (AXIS2-3156) OMElement.declareDefaultNamespace() declares empty namespace for child element.

OMElement.declareDefaultNamespace() declares empty namespace for child element.
-------------------------------------------------------------------------------

                 Key: AXIS2-3156
                 URL: https://issues.apache.org/jira/browse/AXIS2-3156
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: om
    Affects Versions: 1.3
         Environment: Microsoft Windows 2003 Server, Java 1.5.0_11. Axis2 version 1.3 (uses AXIOM version 1.2.5). 
            Reporter: Yechiel Mondrowitz
             Fix For: 1.3


When calling declareDefaultNamespace() on a parent node, AXIOM assignes a blank namespace on the first level's child element.  So if XML is passed to AXIOM that looks like this:

<outerTag>
    <innerTag>
        <node1>Hello</node1>
        <node2>Hello</node2>
    </innerTag>
</outerTag>

And then declareDefaultNamespace() of "http://someNamespace" is called on the <outerTag>, the resulting XML will be this:

<outerTag xmlns="http://someNamespace">
    <innerTag xmlns="">
        <node1>Hello</node1>
        <node2>Hello</node2>
    </innerTag>
</outerTag>

Notice the xmlns="" declared in the <innerTag>.  According to my understanding of XML namespaces, the <innerTag> and its child nodes will no longer belong to the parent namespace of "http://someNamespace", since it explicitly overrides it with an empty namespace.  So <innerTag> and its child nodes will in fact not belong to any namespace!  Here is a small program to illustrate:

import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.llom.util.*;

public class Test2 {
    public static void main(String [] args) {
        try {
            String xmlString =
                "<outerTag>" +
                    "<innerTag>" +
                        "<node1>Hello</node1>" +
                        "<node2>Hello</node2>" +
                   "</innerTag>" +
                "</outerTag>";

            OMElement elem = AXIOMUtil.stringToOM(xmlString);
            elem.declareDefaultNamespace("http://someNamespace");
            System.out.println(elem.toString());
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}

The output of this program is this (I added line breaks in the XML for easier readability):

<outerTag xmlns="http://someNamespace">
    <innerTag xmlns="">
        <node1>Hello</node1>
        <node2>Hello</node2>
    </innerTag>
</outerTag>

As you can see, the <innerTag> was assigned xmlns="" by AXIOM.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Re: [jira] Created: (AXIS2-3156) OMElement.declareDefaultNamespace() declares empty namespace for child element.

Posted by ymondrow <ym...@randomhouse.com>.
Thanks, I really appreciate it.  I'm also sitting on another bug, which
appears more serious than this one.  When a default namespace is declared on
a parent node, AXIOM repeats that default namespace declaration for each
child node, bloating the XML greatly.  I reported this in JIRA as
AXIS2-3155.  Here too, it's been already more than 2 months and it's not
been addressed.  This one is actually causing greater problems on our end,
so if you can take a look at that one too, I would really appreciate it.  I
am attaching the contents of AXIS2-3155 here.  Thanks a bunch!

AXIOM writes out duplicate default namespace declarations
---------------------------------------------------------

                 Key: AXIS2-3155
                 URL: https://issues.apache.org/jira/browse/AXIS2-3155
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: om
    Affects Versions: 1.3
         Environment: Microsoft Windows 2003 Server, Java 1.5.0_11.  Axis2
version 1.3 (uses AXIOM version 1.2.5).
            Reporter: Yechiel Mondrowitz
             Fix For: 1.3


When there is a default namespace declaration in a parent node, it seems
that AXIOM repeats that default namespace declaration for every child node. 
So if this piece of XML, with a default namespace in the <outerTag> is fed
to AXIOM:

<outerTag xmlns="http://someNamespace">
    <innerTag>
        <node1>Hello</node1>
        <node2>Hello</node2>
   </innerTag>
</outerTag>

What AXIOM returns is this:

<outerTag xmlns="http://someNamespace">
    <innerTag xmlns="http://someNamespace">
        <node1 xmlns="http://someNamespace">Hello</node1>
        <node2 xmlns="http://someNamespace">Hello</node2>
   </innerTag>
</outerTag>

While this may be valid XML, it doubles or triples the size of the XML. 
With large XML results, this can mean serious performance issues, as double
or triple the bandwith is needed to transport it across the wire.  This only
appears to happen when the OMElement has not yet been built in memory, but
is still in the stream.  After it is already built, the problem goes away. 
So this problem only occurs if toStringWithConsume(), or
serializeAndConsume() is called on the OMElement.  When toString() is called
however, the resulting XML is fine.  Here is a small program to illustrate:


import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.llom.util.*;

public class Test1 {
    public static void main(String [] args) {
        try {
            String xmlString =
                "<outerTag xmlns=\"http://someNamespace\">" +
                    "<innerTag>" +
                        "<node1>Hello</node1>" +
                        "<node2>Hello</node2>" +
                   "</innerTag>" +
                "</outerTag>";

            OMElement elem = AXIOMUtil.stringToOM(xmlString);
            System.out.println("--- Calling toStringWithConsume() ---\n");
            System.out.println(elem.toStringWithConsume());

            xmlString =
                "<outerTag xmlns=\"http://someNamespace\">" +
                    "<innerTag>" +
                        "<node1>Hello</node1>" +
                        "<node2>Hello</node2>" +
                   "</innerTag>" +
                "</outerTag>";

            elem = AXIOMUtil.stringToOM(xmlString);
            System.out.println("\n--- Calling toString() ---\n");
            System.out.println(elem.toString());
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}


The output of this program is this (I added line breaks in the XML for
easier readability):

--- Calling toStringWithConsume() ---

<outerTag xmlns="http://someNamespace">
    <innerTag xmlns="http://someNamespace">
        <node1 xmlns="http://someNamespace">Hello</node1>
        <node2 xmlns="http://someNamespace">Hello</node2>
    </innerTag>
</outerTag>

--- Calling toString() ---

<outerTag xmlns="http://someNamespace">
    <innerTag>
        <node1>Hello</node1>
        <node2>Hello</node2>
    </innerTag>
</outerTag>

I consider this a very big problem for me, because we return very large XML
results, and this bloats the XML tremendously.  I had to refrain from using
default namespaces because of this.  I really hope this can be corrected in
time for the next release of Axis2 / AXIOM.

-- 
View this message in context: http://www.nabble.com/-jira--Created%3A-%28AXIS2-3156%29-OMElement.declareDefaultNamespace%28%29-declares-empty-namespace-for-child-element.-tf4344073.html#a13696397
Sent from the Axis - Dev mailing list archive at Nabble.com.


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


[jira] Commented: (AXIS2-3156) OMElement.declareDefaultNamespace() declares empty namespace for child element.

Posted by "chris snow (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796853#action_12796853 ] 

chris snow commented on AXIS2-3156:
-----------------------------------

I have the same issue with Axis2 1.5.1

> OMElement.declareDefaultNamespace() declares empty namespace for child element.
> -------------------------------------------------------------------------------
>
>                 Key: AXIS2-3156
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3156
>             Project: Axis2
>          Issue Type: Bug
>          Components: om
>    Affects Versions: 1.3
>         Environment: Microsoft Windows 2003 Server, Java 1.5.0_11. Axis2 version 1.3 (uses AXIOM version 1.2.5). 
>            Reporter: Yechiel Mondrowitz
>            Assignee: Deepal Jayasinghe
>
> When calling declareDefaultNamespace() on a parent node, AXIOM assignes a blank namespace on the first level's child element.  So if XML is passed to AXIOM that looks like this:
> <outerTag>
>     <innerTag>
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> And then declareDefaultNamespace() of "http://someNamespace" is called on the <outerTag>, the resulting XML will be this:
> <outerTag xmlns="http://someNamespace">
>     <innerTag xmlns="">
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> Notice the xmlns="" declared in the <innerTag>.  According to my understanding of XML namespaces, the <innerTag> and its child nodes will no longer belong to the parent namespace of "http://someNamespace", since it explicitly overrides it with an empty namespace.  So <innerTag> and its child nodes will in fact not belong to any namespace!  Here is a small program to illustrate:
> import org.apache.axiom.om.*;
> import org.apache.axiom.om.impl.llom.util.*;
> public class Test2 {
>     public static void main(String [] args) {
>         try {
>             String xmlString =
>                 "<outerTag>" +
>                     "<innerTag>" +
>                         "<node1>Hello</node1>" +
>                         "<node2>Hello</node2>" +
>                    "</innerTag>" +
>                 "</outerTag>";
>             OMElement elem = AXIOMUtil.stringToOM(xmlString);
>             elem.declareDefaultNamespace("http://someNamespace");
>             System.out.println(elem.toString());
>         }
>         catch(Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> The output of this program is this (I added line breaks in the XML for easier readability):
> <outerTag xmlns="http://someNamespace">
>     <innerTag xmlns="">
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> As you can see, the <innerTag> was assigned xmlns="" by AXIOM.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (AXIS2-3156) OMElement.declareDefaultNamespace() declares empty namespace for child element.

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Deepal Jayasinghe reassigned AXIS2-3156:
----------------------------------------

    Assignee: Deepal Jayasinghe

> OMElement.declareDefaultNamespace() declares empty namespace for child element.
> -------------------------------------------------------------------------------
>
>                 Key: AXIS2-3156
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3156
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: om
>    Affects Versions: 1.3
>         Environment: Microsoft Windows 2003 Server, Java 1.5.0_11. Axis2 version 1.3 (uses AXIOM version 1.2.5). 
>            Reporter: Yechiel Mondrowitz
>            Assignee: Deepal Jayasinghe
>             Fix For: 1.3
>
>
> When calling declareDefaultNamespace() on a parent node, AXIOM assignes a blank namespace on the first level's child element.  So if XML is passed to AXIOM that looks like this:
> <outerTag>
>     <innerTag>
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> And then declareDefaultNamespace() of "http://someNamespace" is called on the <outerTag>, the resulting XML will be this:
> <outerTag xmlns="http://someNamespace">
>     <innerTag xmlns="">
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> Notice the xmlns="" declared in the <innerTag>.  According to my understanding of XML namespaces, the <innerTag> and its child nodes will no longer belong to the parent namespace of "http://someNamespace", since it explicitly overrides it with an empty namespace.  So <innerTag> and its child nodes will in fact not belong to any namespace!  Here is a small program to illustrate:
> import org.apache.axiom.om.*;
> import org.apache.axiom.om.impl.llom.util.*;
> public class Test2 {
>     public static void main(String [] args) {
>         try {
>             String xmlString =
>                 "<outerTag>" +
>                     "<innerTag>" +
>                         "<node1>Hello</node1>" +
>                         "<node2>Hello</node2>" +
>                    "</innerTag>" +
>                 "</outerTag>";
>             OMElement elem = AXIOMUtil.stringToOM(xmlString);
>             elem.declareDefaultNamespace("http://someNamespace");
>             System.out.println(elem.toString());
>         }
>         catch(Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> The output of this program is this (I added line breaks in the XML for easier readability):
> <outerTag xmlns="http://someNamespace">
>     <innerTag xmlns="">
>         <node1>Hello</node1>
>         <node2>Hello</node2>
>     </innerTag>
> </outerTag>
> As you can see, the <innerTag> was assigned xmlns="" by AXIOM.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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