You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Toshiro Takase (JIRA)" <ji...@apache.org> on 2006/09/14 17:45:24 UTC

[jira] Created: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Incorrect default namespace serialization for un-prefixed attribute.
--------------------------------------------------------------------

                 Key: WSCOMMONS-99
                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
             Project: WS-Commons
          Issue Type: Bug
          Components: AXIOM
         Environment: Windows
            Reporter: Toshiro Takase
            Priority: Critical


Current serialization prints default namespace declaration for un-prefixed attributes.
According to "Namespaces in XML 1.0",
http://www.w3.org/TR/REC-xml-names/#defaulting
	"Default namespace declarations do not apply directly to attribute names."
	"The namespace name for an unprefixed attribute name always has no value."
So the default namespace declaration should not be printed.
I am afraid that this serialization sometimes breaks XML signature and XML Infoset.

This is my test code.
----------
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMDocument doc = factory.createOMDocument();
        OMElement elem1 = factory.createOMElement("local1", "ns1", "");
        doc.addChild(elem1);
        OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
        elem1.addChild(elem2);
        elem2.addAttribute("attrLocal", "attrValue", null);
        OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
        elem2.addChild(elem3);
        doc.serialize(System.out);
----------

The result is here. (indented for readability)
----------
<?xml version="1.0" encoding="utf-8"?>
<local1 xmlns="ns1">
    <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
        <local3 xmlns="ns1"/>
    </pre2:local2>
</local1>
----------

In my understanding, this should be the following.
----------
<?xml version="1.0" encoding="utf-8"?>
<local1 xmlns="ns1">
    <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
        <local3/>
    </pre2:local2>
</local1>
----------


-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Resolved: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Posted by "Eran Chinthaka (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=all ]

Eran Chinthaka resolved WSCOMMONS-99.
-------------------------------------

    Resolution: Duplicate

Resolving as a duplicate as per Toshiro's last comment. 

> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
>                 Key: WSCOMMONS-99
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Windows
>            Reporter: Toshiro Takase
>            Priority: Critical
>         Attachments: diff.txt, unprefixed.xml, UnprefixedTest.java
>
>
> Current serialization prints default namespace declaration for un-prefixed attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> 	"Default namespace declarations do not apply directly to attribute names."
> 	"The namespace name for an unprefixed attribute name always has no value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML Infoset.
> This is my test code.
> ----------
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMDocument doc = factory.createOMDocument();
>         OMElement elem1 = factory.createOMElement("local1", "ns1", "");
>         doc.addChild(elem1);
>         OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
>         elem1.addChild(elem2);
>         elem2.addAttribute("attrLocal", "attrValue", null);
>         OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
>         elem2.addChild(elem3);
>         doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3 xmlns="ns1"/>
>     </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3/>
>     </pre2:local2>
> </local1>
> ----------

-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Posted by "Toshiro Takase (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=comments#action_12434765 ] 
            
Toshiro Takase commented on WSCOMMONS-99:
-----------------------------------------

I have no confidence, but this is possible fix. I think.

org.apache.axiom.om.impl.util.OMSerializerUtil.serializeStartpart()
Current Code:
LL.287-297
----------
            // Default prefix referencing is not allowed on an attribute
            if (prefix == null && namespace != null) {
            	String writerPrefix = writer.getPrefix(namespace);
            	writerPrefix = (writerPrefix != null && writerPrefix.length() == 0) ? null : writerPrefix;
            	prefix = (writerPrefix != null) ? 
            			writerPrefix : getNextNSPrefix();
            }
            newPrefix = generateSetPrefix(prefix, namespace, writer);
            // If the prefix is not associated with a namespace yet, remember it so that we can
        	// write out a namespace declaration
        	if (newPrefix != null) {
----------

Possibly:
----------
            // Default prefix referencing is not allowed on an attribute
            if (prefix == null && namespace != null) {
            	String writerPrefix = writer.getPrefix(namespace);
            	writerPrefix = (writerPrefix != null && writerPrefix.length() == 0) ? null : writerPrefix;
            	prefix = (writerPrefix != null) ? 
            			writerPrefix : getNextNSPrefix();
            }
            if (prefix == null) {
                newPrefix = null;
            } else {
                newPrefix = generateSetPrefix(prefix, namespace, writer);
            }
            // If the prefix is not associated with a namespace yet, remember it so that we can
        	// write out a namespace declaration
        	if (newPrefix != null) {
----------


> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
>                 Key: WSCOMMONS-99
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Windows
>            Reporter: Toshiro Takase
>            Priority: Critical
>
> Current serialization prints default namespace declaration for un-prefixed attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> 	"Default namespace declarations do not apply directly to attribute names."
> 	"The namespace name for an unprefixed attribute name always has no value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML Infoset.
> This is my test code.
> ----------
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMDocument doc = factory.createOMDocument();
>         OMElement elem1 = factory.createOMElement("local1", "ns1", "");
>         doc.addChild(elem1);
>         OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
>         elem1.addChild(elem2);
>         elem2.addAttribute("attrLocal", "attrValue", null);
>         OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
>         elem2.addChild(elem3);
>         doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3 xmlns="ns1"/>
>     </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3/>
>     </pre2:local2>
> </local1>
> ----------

-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Updated: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Posted by "Toshiro Takase (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=all ]

Toshiro Takase updated WSCOMMONS-99:
------------------------------------

    Attachment: diff.txt

For clarification, I got diff of my change.
This works fine in my environment.


> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
>                 Key: WSCOMMONS-99
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Windows
>            Reporter: Toshiro Takase
>            Priority: Critical
>         Attachments: diff.txt
>
>
> Current serialization prints default namespace declaration for un-prefixed attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> 	"Default namespace declarations do not apply directly to attribute names."
> 	"The namespace name for an unprefixed attribute name always has no value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML Infoset.
> This is my test code.
> ----------
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMDocument doc = factory.createOMDocument();
>         OMElement elem1 = factory.createOMElement("local1", "ns1", "");
>         doc.addChild(elem1);
>         OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
>         elem1.addChild(elem2);
>         elem2.addAttribute("attrLocal", "attrValue", null);
>         OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
>         elem2.addChild(elem3);
>         doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3 xmlns="ns1"/>
>     </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3/>
>     </pre2:local2>
> </local1>
> ----------

-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Posted by "Toshiro Takase (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=comments#action_12455997 ] 
            
Toshiro Takase commented on WSCOMMONS-99:
-----------------------------------------

This seems same as COMMONS-119.
The latest code passed all my test cases.
Thanks.

> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
>                 Key: WSCOMMONS-99
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Windows
>            Reporter: Toshiro Takase
>            Priority: Critical
>         Attachments: diff.txt, unprefixed.xml, UnprefixedTest.java
>
>
> Current serialization prints default namespace declaration for un-prefixed attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> 	"Default namespace declarations do not apply directly to attribute names."
> 	"The namespace name for an unprefixed attribute name always has no value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML Infoset.
> This is my test code.
> ----------
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMDocument doc = factory.createOMDocument();
>         OMElement elem1 = factory.createOMElement("local1", "ns1", "");
>         doc.addChild(elem1);
>         OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
>         elem1.addChild(elem2);
>         elem2.addAttribute("attrLocal", "attrValue", null);
>         OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
>         elem2.addChild(elem3);
>         doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3 xmlns="ns1"/>
>     </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3/>
>     </pre2:local2>
> </local1>
> ----------

-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Updated: (WSCOMMONS-99) Incorrect default namespace serialization for un-prefixed attribute.

Posted by "Toshiro Takase (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=all ]

Toshiro Takase updated WSCOMMONS-99:
------------------------------------

    Attachment: UnprefixedTest.java
                unprefixed.xml

I attach one more test code.

Input XML (unprefixed.xml) is here.
-----
<?xml version="1.0" encoding="utf-8"?>
<local1 xmlns="ns1">
    <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
        <local3 />
    </pre2:local2>
</local1>
-----

Then, the test code (UnprefixedTest) just parses, builds AXIOM, and serializes the input XML.
The output XML is here.
-----
<?xml version='1.0' encoding='utf-8'?>
<local1 xmlns="ns1">
    <pre2:local2 xmlns:pre2="ns2" xmlns="" attrLocal="attrValue">
        <local3 xmlns="ns1" />
    </pre2:local2>
</local1>
-----

In the input XML (unprefixed.xml), the namespace URI for "attrLocal" is not ns1, but null.
You can see the XMLStreamReader reports that by test3() method in the test code.
So, AXIOM serializer should not print xmlns="".

Actually, this serializer breaks XML signature sometimes. I found some examples.
I hope this bug is fixed as soon as possible.

Thanks in advance.

> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
>                 Key: WSCOMMONS-99
>                 URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>         Environment: Windows
>            Reporter: Toshiro Takase
>            Priority: Critical
>         Attachments: diff.txt, unprefixed.xml, UnprefixedTest.java
>
>
> Current serialization prints default namespace declaration for un-prefixed attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> 	"Default namespace declarations do not apply directly to attribute names."
> 	"The namespace name for an unprefixed attribute name always has no value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML Infoset.
> This is my test code.
> ----------
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMDocument doc = factory.createOMDocument();
>         OMElement elem1 = factory.createOMElement("local1", "ns1", "");
>         doc.addChild(elem1);
>         OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
>         elem1.addChild(elem2);
>         elem2.addAttribute("attrLocal", "attrValue", null);
>         OMElement elem3 = factory.createOMElement("local3", elem1.getNamespace());
>         elem2.addChild(elem3);
>         doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3 xmlns="ns1"/>
>     </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
>     <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
>         <local3/>
>     </pre2:local2>
> </local1>
> ----------

-- 
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: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org