W3C home > Mailing lists > Public > www-dom-ts@w3.org > March 2002

Re: Writing DOM Level 3 Load & Save tests

From: <jvrdam@xs4all.nl>
Date: Sun, 24 Mar 2002 13:48:06 +0100 (CET)
Message-ID: <4913.>
To: <www-dom-ts@w3.org>
Curt wrote:

  handleEvent basically was intended to be used to define something 
  like an anonymous inner class.

  <var name="myHandler" type="EventListener">
     <handleEvent return="true">
        <!--  body of method goes here -->

Ok, sounds promising.
Lets have a look at a simple example derived from our testsuite to verify 
the setup. (bare in mind that this is the first test I'm writing using the 

public class LSTest {

  DOMImplementation   implementation  ;
  DOMImplementationLS lsImplementation;
  Document            document        ;
  DOMBuilder          builder         ;
  MyDOMBuilderFilter  myfilter        ;


  public void testFilterStartNode() throws Exception {

    lsImplementation = (DOMImplementationLS) implementation;
    builder          = lsImplementation.createDOMBuilder
    myfilter         = new MyDOMBuilderFilter();

    document = builder.parseURI(getURL("test.xml").toString());

    assertEquals("elt2 is skipped, so document element has only one child", 
1, document.getDocumentElement().getChildNodes().getLength());
    assertEquals("That one child is elt1", "elt1", 


class MyDOMBuilderFilter implement DOMBuilderFilter{

      public int startNode(Node element) {
        boolean accept = ! element.getNodeName().equals("elt2");
        if (accept) {
          return NodeFilter.FILTER_ACCEPT;
        } else {
          return NodeFilter.FILTER_REJECT;

      public int endNode(Node enode) {
        return NodeFilter.FILTER_ACCEPT;

      public int getWhatToShow() {
        return NodeFilter.SHOW_ELEMENT;

The XML file for the actual test would look something like:

<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-3" 

    <date qualifier="created">2002-03-23</date>
    <subject resource="http://www.w3.org/TR/DOM-Level-3-ASLS/load-

  <var name="implementation"   type="DOMImplementation"/>   
  <var name="lsImplementation" type="DOMImplementationLS"/> 
  <var name="document"         type="Document"/>            
  <var name="builder"          type="DOMBuilder"/>          

  <var name="myfilter"         type="MyDOMBuilderFilter"> 

     <var name="accept" type="boolean"/>

     <startNode return="returnValue" snode="element">
        <nodeName var="accept" obj="element"/>
            <equals actual="accept" expected="elt2" ignoreCase="false"/>
            <assign var="returnValue" value="FILTER_REJECT"/>            
            <assign var="returnValue" value="FILTER_ACCEPT"/>            

     <endNode return="returnValue" enode="endnode">
        <assign var="returnValue" value="FILTER_ACCEPT"/>            

     <getWhatToShow return="returnValue">
        <assign var="returnValue" value="SHOW_ELEMENT"/>            

  <implementationLS var="lsImplementation"/>
  <createDOMBuilder var="builder" obj="lsImplementation"
  <setFilter obj="builder" filter="myfilter"/>
  <parseURI  var="document" obj="builder" uri="test.xml"/>




If this is somehow correct than I guess the dtd needs some work, especially 
when you look at the definition of <var>
By the way, how are constants handled ?


Jeroen van Rotterdam
X-Hive Corporation
Received on Sunday, 24 March 2002 07:43:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:34:04 UTC