You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Jörg Heinicke (JIRA)" <xa...@xml.apache.org> on 2007/12/27 14:43:43 UTC

[jira] Issue Comment Edited: (XALANJ-2091) Namespace attributes not added as attributes when using TransformerIdentityImpl

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

joerg.heinicke@gmx.de edited comment on XALANJ-2091 at 12/27/07 5:43 AM:
-----------------------------------------------------------------

In my opinion there is still an issue with the implementation. Since startPrefixMapping() now changes the state of the DOMBuilder endPrefixMapping() must be implemented as well. The current implementation breaks at least when namespace prefixes are reassociated with a different namespace uri after the scope of the inner prefix mapping is left.

      was (Author: joerg.heinicke@gmx.de):
    In my opinion there is still an issue with the implementation. Since startPrefixMapping() now changes the state of the DOMBuilder endPrefixMapping() must be implemented as well. The current implementation breaks at least when redefining namespace prefixes when the scope of the inner prefix mapping is left.
  
> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>                 Key: XALANJ-2091
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2091
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: transformation
>    Affects Versions: 2.6
>            Reporter: Felix Röthenbacher
>            Assignee: Christine Li
>             Fix For: 2.7.1
>
>         Attachments: Patch.txt, TransformerIdentityImpl.java.diff
>
>
> Namespace attributes are not added as attributes to the resulting
> DOM tree when using TransformerIdentityImpl. The problem is, that
> the namespace-prefix feature is not set to true and therefore the
> namespace attributes are not added. This does not conform to the
> DOM spec saying that also namespace attributes may be handled as
> normal attributes.
> I will attach a patch which fixes the issue by calling
>            reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
>                              true);
> of the XMLReader.
> The following code shows the problem:
> The input XML document looks like this:
> <?xml version="1.0"?>
> <test xmlns:testns="http://testns.org" testns:testattr="3"/>
> And the code used to extract the namespace attributes is as follows:
>   FileInputStream fis = new FileInputStream("test.xml");
>   Transformer trfs = TransformerFactory.newInstance().newTransformer();
>   StreamSource ss = new StreamSource(fis);
>   DOMResult dr = new DOMResult();
>   trfs.transform(ss, dr);
>   Document doc = (Document)dr.getNode();
>   Node node = doc.getFirstChild();
>   System.out.println("First node: " + node.getLocalName());
>   NamedNodeMap nodes = node.getAttributes();
>   for (int i=0; i<nodes.getLength(); i++) {
>     System.out.println("  Attribute: " + nodes.item(i).getLocalName());
>   }
> Finally, the the output looks like this:
>   First node: test
>   Attribute: testattr
> instead of the expected output:
>   First node: test
>   Attribute: testns
>   Attribute: testattr

-- 
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