You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Joe James Fenton (JIRA)" <xe...@xml.apache.org> on 2009/03/09 16:12:50 UTC

[jira] Created: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
-------------------------------------------------------------------------------------------------------------------------------------

                 Key: XERCESJ-1361
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
             Project: Xerces2-J
          Issue Type: Bug
          Components: Other
         Environment: Linux
            Reporter: Joe James Fenton


If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
element in the DOM on output contains only the final text node:

Demonstration code:
//////////////////////////////////

package test;
import junit.framework.TestCase;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.ls.LSParserFilter;
import org.w3c.dom.traversal.NodeFilter;

import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;

public class TestBug extends TestCase {

  private static final String EXAMPLE_NS = "http://www.example.com";

  public void testFilteringSiblingTextNodes() throws Exception {
    final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
    parser.setFilter(new LSParserFilter() {

      public short acceptNode(final Node nodeArg) {
        return LSParserFilter.FILTER_ACCEPT;
      }

      public int getWhatToShow() {
        return NodeFilter.SHOW_ALL;
      }

      public short startElement(final Element elementArg) {
        if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
          return LSParserFilter.FILTER_ACCEPT;
        }
        else {
          return LSParserFilter.FILTER_SKIP;
        }
      }
    });

    final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
    assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
  }
}

/////////////////////////////////

resource "input.xml"

<html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
  <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
</html>


/////////////////////////////////////////

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


[jira] Resolved: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1361.
-------------------------------------------

    Resolution: Fixed

There was a flag in the DOM parser which wasn't getting reset and this caused the loss of the text data.  Fixed now in SVN revision 751800.

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Commented: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680227#action_12680227 ] 

Michael Glavassevich commented on XERCESJ-1361:
-----------------------------------------------

I've confirmed that this is still an issue with the current code in SVN. In case either of you don't know, you should be creating an LSParser like this:

import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSParser;

            DOMImplementationRegistry dir = DOMImplementationRegistry.newInstance();
            DOMImplementationLS dils = (DOMImplementationLS) dir.getDOMImplementation("LS");
            LSParser parser = dils.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema");

instead of coding directly to the implementation. Also, if you're seeking a fix in the JDK you need to pursue it with Sun. We have no affiliation with that fork of the code and have no influence on what goes into it.

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Commented: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Chris Simmons (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680446#action_12680446 ] 

Chris Simmons commented on XERCESJ-1361:
----------------------------------------

Thanks.  We're actually using our own repackaged version of Xerces, the com.sun stuff was just confusion.

I've found that we have to use the (repackaged) Xerces implementation directly as there's no way of getting line/column information for the elements using the DOM api's AFAIK.  I'd be glad to be corrected if I'm wrong though!

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Issue Comment Edited: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680227#action_12680227 ] 

Michael Glavassevich edited comment on XERCESJ-1361 at 3/17/10 2:50 PM:
------------------------------------------------------------------------

I've confirmed that this is still an issue with the current code in SVN. In case either if you don't know, you should be creating an LSParser like this:

import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSParser;

            DOMImplementationRegistry dir = DOMImplementationRegistry.newInstance();
            DOMImplementationLS dils = (DOMImplementationLS) dir.getDOMImplementation("LS");
            LSParser parser = dils.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema");

instead of coding directly to the implementation. Also, if you're seeking a fix in the JDK you need to pursue it with Sun. We have no affiliation with that fork of the code and have no influence on what goes into it.

      was (Author: mrglavas@ca.ibm.com):
    I've confirmed that this is still an issue with the current code in SVN. In case either of you don't know, you should be creating an LSParser like this:

import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSParser;

            DOMImplementationRegistry dir = DOMImplementationRegistry.newInstance();
            DOMImplementationLS dils = (DOMImplementationLS) dir.getDOMImplementation("LS");
            LSParser parser = dils.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema");

instead of coding directly to the implementation. Also, if you're seeking a fix in the JDK you need to pursue it with Sun. We have no affiliation with that fork of the code and have no influence on what goes into it.
  
> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>             Fix For: 2.10.0
>
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Assigned: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich reassigned XERCESJ-1361:
---------------------------------------------

    Assignee: Michael Glavassevich

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Updated: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich updated XERCESJ-1361:
------------------------------------------

    Fix Version/s: 2.10.0

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>            Assignee: Michael Glavassevich
>             Fix For: 2.10.0
>
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Updated: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich updated XERCESJ-1361:
------------------------------------------

          Component/s:     (was: Other)
                       DOM (Level 3 Load & Save)
    Affects Version/s: 2.9.1

> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DOM (Level 3 Load & Save)
>    Affects Versions: 2.9.1
>         Environment: Linux
>            Reporter: Joe James Fenton
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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


[jira] Commented: (XERCESJ-1361) DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input

Posted by "Chris Simmons (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680185#action_12680185 ] 

Chris Simmons commented on XERCESJ-1361:
----------------------------------------

Before the obvious 'that's not Xerces' reply, this test fails identically with Xerces 2.9.0 if you make the following changes:-

import org.apache.xerces.parsers.DOMParserImpl;

final DOMParserImpl parser = new DOMParserImpl("org.apache.xerces.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");


> DOMParserImpl repeatedly overwrites text node child of an element (rather than appending) when there are multiple text nodes in input
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1361
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1361
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>         Environment: Linux
>            Reporter: Joe James Fenton
>
> If there are multiple text node children on an element (which, in this case given below, results from filtering elements during parsing) then the 
> element in the DOM on output contains only the final text node:
> Demonstration code:
> //////////////////////////////////
> package test;
> import junit.framework.TestCase;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.Node;
> import org.w3c.dom.ls.LSParserFilter;
> import org.w3c.dom.traversal.NodeFilter;
> import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
> public class TestBug extends TestCase {
>   private static final String EXAMPLE_NS = "http://www.example.com";
>   public void testFilteringSiblingTextNodes() throws Exception {
>     final DOMParserImpl parser = new DOMParserImpl("com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration", "http://www.w3.org/2001/XMLSchema");
>     parser.setFilter(new LSParserFilter() {
>       public short acceptNode(final Node nodeArg) {
>         return LSParserFilter.FILTER_ACCEPT;
>       }
>       public int getWhatToShow() {
>         return NodeFilter.SHOW_ALL;
>       }
>       public short startElement(final Element elementArg) {
>         if (EXAMPLE_NS.equals(elementArg.getNamespaceURI())) {
>           return LSParserFilter.FILTER_ACCEPT;
>         }
>         else {
>           return LSParserFilter.FILTER_SKIP;
>         }
>       }
>     });
>     final Document document = parser.parseURI(getClass().getResource("input.xml").toString());
>     assertEquals("List:1)Item 1,2)Item 2.", document.getElementsByTagNameNS(EXAMPLE_NS, "foo").item(0).getTextContent());
>   }
> }
> /////////////////////////////////
> resource "input.xml"
> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:ex='http://www.example.com'>
>   <ex:foo>List:<br />1)Item 1,<br />2)Item 2.</ex:foo>
> </html>
> /////////////////////////////////////////

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