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 20:45:23 UTC

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

    [ 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