You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Guillaume Nodet (JIRA)" <xa...@xml.apache.org> on 2007/02/06 15:11:05 UTC

[jira] Commented: (XALANJ-2361) DOM to stream conversion fails on prefix beginning like "xmlConfiguration"

    [ https://issues.apache.org/jira/browse/XALANJ-2361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12470585 ] 

Guillaume Nodet commented on XALANJ-2361:
-----------------------------------------

Yeah, I agree, thanks for pointing that: I will ping the JAXB2 guys, because this prefix is automatically generated.
Anyway, i think the behavior could be enhanced to avoid throwing an exception when parsing such an xml.

> DOM to stream conversion fails on prefix beginning like "xmlConfiguration"
> --------------------------------------------------------------------------
>
>                 Key: XALANJ-2361
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2361
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: Serialization
>    Affects Versions: 2.7
>            Reporter: Guillaume Nodet
>            Priority: Critical
>         Attachments: XALANJ-2361.patch
>
>
> Here is a simple test case to reproduce the problem:
> {{code}}
>         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>         dbf.setNamespaceAware(true);
>         TransformerFactory tf = TransformerFactory.newInstance();
>         
>         String src = "<root><xmlConfiguration:xmlConfiguration xmlns:xmlConfiguration=\"urn:configuration\" /></root>";
>         Document doc = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(src.getBytes()));
>         ByteArrayOutputStream res = new ByteArrayOutputStream();
>         tf.newTransformer().transform(new DOMSource(doc), new StreamResult(res));
>         System.out.println(res);
>         dbf.newDocumentBuilder().parse(new ByteArrayInputStream(res.toByteArray()));
> {{code}}
> The last line throws an exception, because the xmlns:xmlConfiguration attribute has been lost.
> While debugging, I found that the problem comes from http://svn.apache.org/repos/asf/xalan/java/trunk/src/org/apache/xml/serializer/NamespaceMappings.java,
> line 228:
> {{code}}
>         // Prefixes "xml" and "xmlns" cannot be redefined
>         if (prefix.startsWith(XML_PREFIX))
>         {
>             return false;
>         }
> {{code}}
> It seems this test is wrong, and it should be
> {{code}}
>         // Prefixes "xml" and "xmlns" cannot be redefined
>         if (prefix.equals("xml") || prefix.equals("xmlns")
>         {
>             return false;
>         }
> {{code}}

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