You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Felix Röthenbacher (JIRA)" <xa...@xml.apache.org> on 2005/04/04 17:16:19 UTC

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

Namespace attributes not added as attributes when using TransformerIdentityImpl
-------------------------------------------------------------------------------

         Key: XALANJ-2091
         URL: http://issues.apache.org/jira/browse/XALANJ-2091
     Project: XalanJ2
        Type: Bug
  Components: transformation  
    Versions: CurrentCVS    
    Reporter: Felix Röthenbacher


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.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


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

Posted by "Jörg Heinicke (JIRA)" <xa...@xml.apache.org>.
    [ 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


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

Posted by "Jörg Heinicke (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566021#action_12566021 ] 

Jörg Heinicke commented on XALANJ-2091:
---------------------------------------

Any response to my last comment/concern?

> 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


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

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=all ]

Brian Minchau reassigned XALANJ-2091:
-------------------------------------

    Assignee: Christine Li

Assigning to Christine Li per the JIRA triage on November 6, 2006.

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>                 Key: XALANJ-2091
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2091
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: transformation
>    Affects Versions: 2.6
>            Reporter: Felix Röthenbacher
>         Assigned To: Christine Li
>         Attachments: 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.
-
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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


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

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=comments#action_62134 ]
     
Brian Minchau commented on XALANJ-2091:
---------------------------------------

The patch needs careful consideration. In a note to xalan-j-users David Bertoni wrote:
> 
> 
> That's because namespace declaration are represented in the data model as 
> namespaces nodes, not attribute nodes:
> 
> 
> http://www.w3.org/TR/xpath#namespace-nodes
> 
> Dave
> 

I too have concerns about the patch. In a serialized XML document (a stream of characters, usually written to a file) namespace nodes appear as attributes, xmlns:prefix="someURI".
But that doesn't mean that they actually ARE attributes in the data model.  It seems to me with Felix suggested change that the DOM would have both a namespace node and an attribute for the prefix/uri mapping, and I'm not sure that having both is correct.



> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>          Key: XALANJ-2091
>          URL: http://issues.apache.org/jira/browse/XALANJ-2091
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation
>     Versions: CurrentCVS
>     Reporter: Felix Röthenbacher
>  Attachments: 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.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


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

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2091?page=comments#action_12448250 ] 
            
Henry Zongaro commented on XALANJ-2091:
---------------------------------------

I have reviewed Christine's patch[1] and believe that it correctly resolves the problem.

[1] https://issues.apache.org/jira/secure/attachment/12344607/Patch.txt

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>                 Key: XALANJ-2091
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2091
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: transformation
>    Affects Versions: 2.6
>            Reporter: Felix Röthenbacher
>         Assigned To: Christine Li
>         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.
-
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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


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

Posted by "Christine Li (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=all ]

Christine Li resolved XALANJ-2091.
----------------------------------

    Fix Version/s: Latest Development Code
       Resolution: Fixed

The patch has been checked in. Please verify the changes. Thanks,

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>                 Key: XALANJ-2091
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2091
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: transformation
>    Affects Versions: 2.6
>            Reporter: Felix Röthenbacher
>         Assigned To: Christine Li
>             Fix For: Latest Development Code
>
>         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.
-
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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


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

Posted by "Michael Wechner (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=comments#action_62146 ]
     
Michael Wechner commented on XALANJ-2091:
-----------------------------------------

It seems that this "feature" actually works with older Xalan versions, like for instance the one which is shipped with SUN JDK 1.4 (JDK 1.4 is packaged with an old version (2.2D11).

So it might have been removed on purpose from the recent versions and one needs to handle the namespaces differently, but if so, then how?

Thanks

Michi

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>          Key: XALANJ-2091
>          URL: http://issues.apache.org/jira/browse/XALANJ-2091
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation
>     Versions: CurrentCVS
>     Reporter: Felix Röthenbacher
>  Attachments: 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.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


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

Posted by "Felix Röthenbacher (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=history ]

Felix Röthenbacher updated XALANJ-2091:
---------------------------------------

    Attachment: TransformerIdentityImpl.java.diff

Patch for enabling namespace attribute inclusion.

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>          Key: XALANJ-2091
>          URL: http://issues.apache.org/jira/browse/XALANJ-2091
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation
>     Versions: CurrentCVS
>     Reporter: Felix Röthenbacher
>  Attachments: 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.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


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

Posted by "Felix Röthenbacher (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2091?page=comments#action_62145 ]
     
Felix Röthenbacher commented on XALANJ-2091:
--------------------------------------------

>Comment by Brian Minchau [04/Apr/05 09:50 PM]
>
>The patch needs careful consideration. In a note to xalan-j-users David Bertoni wrote:
>>
>>
>> That's because namespace declaration are represented in the data model as
>> namespaces nodes, not attribute nodes:
>>
>>
>> http://www.w3.org/TR/xpath#namespace-nodes
>>
>> Dave
>>
>
>I too have concerns about the patch. In a serialized XML document (a stream of characters,
>usually written to a >file) namespace nodes appear as attributes, xmlns:prefix="someURI".
>But that doesn't mean that they actually ARE attributes in the data model. It seems to me
>with Felix suggested >change that the DOM would have both a namespace node and an attribute
>for the prefix/uri mapping, and I'm not sure that having both is correct.

If you are speaking about DOM and its relevant data model you have to look at
its specification http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/
especially the chapter about namespaces: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#Namespaces-Considerations
where it states that

"... As far as the DOM is concerned, special attributes used for declaring XML namespaces are
still exposed and can be manipulated just like any other attribute. .."

That means in words of the DOM API that you have a org.w3c.dom.Node object from the DOMResult
produced by the transformation with its various node types. But, there is no namespace node
type and namespace attributes are handled "... just like any other attribute".

It's strange that the sources from Sun's JDK expose an implementation in that way (based
on Xalan) but the current trunk does not. It looks like a regression happened here.

> Namespace attributes not added as attributes when using TransformerIdentityImpl
> -------------------------------------------------------------------------------
>
>          Key: XALANJ-2091
>          URL: http://issues.apache.org/jira/browse/XALANJ-2091
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation
>     Versions: CurrentCVS
>     Reporter: Felix Röthenbacher
>  Attachments: 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.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


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

Posted by "Jörg Heinicke (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12554570 ] 

Jörg Heinicke commented on XALANJ-2091:
---------------------------------------

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