RE: /* undeclared */ on declared variables

"Curt Arnold" <[email protected]>
Newsgroups gmane.comp.web.dom.test-suites.general
Message-ID <009901c2bdf9$10098180$a800a8c0@CurtMicron>
I've fixed test-to-java.xsl to eliminate the problem.  The parameter type was wrong and the value type was missing on a template call to generate arguments for property mutators.  Since things were seriously wrong the template hoped for the best and emitted the warning and the raw parameter value.

There were a decent number of problems with the DOMBuilderTest1 that schema validation uncovered (once I fixed some issues with schema generation).  I've attached modified copies of DOMBuilderTest1.xml and dom3tests.ent.  The problems were:

short and String were used for type parameter of var elements.  I added short to the list of supported datatypes and changed String to DOMString in the tests.

<var> elements must appear before any other statements in the body of the test.

changed the spec attribute of <subject> to resource.

Added SYSTEM 'dom3.dtd' to the document type declaration.  MSV would not schema validate with a document type declaration but without definitions for all the encountered elements.

Changed the id attributes on assert statements to meaningful unique values.  The assertion IDs are intended to cross reference test failures back to specific assertion statements.

dom-to-xsd.xsl and dom-to-dtd.xsl would produce the readonly form of an property element when there was at least one use of the property name that was readonly.  This resulted in systemId not having a value attribute since there was one readonly form in addition to the read/write use in DOMInputSource.  I changed to tests so the readonly form is only emitted when all uses of the property name are read-only.

I added Jeroen's dom3-gen-java and dom3-javac targets to allow quick iterative code generation.  I would suggest trying to find better names for them since they are confusing with the targets that are used for full rebuilds.

I had hoped to avoid DTD production for Level 3 since there were a decent number of complications that did not affect schema generation.  However, use of external entities in the L3 tests requires (at least for MSV as of 2002-04-14) a DTD before schema validation could proceed.  The DTD produced by dom3-dtd contains multiple declarations for some elements, but is sufficient to let MSV proceed to schema validation.  To check tests, run dom3-dtd at least once to get a copy of dom3.dtd into the tests/level3/ls directory and run dom3-schema to get dom3.xsd into the build directory and then

java -jar msv.jar build/dom3.xsd tests/level3/ls/*.xml
dom3tests.ent (text/xml, 3.3 KB)
<!ENTITY level3      "http://www.w3.org/2001/DOM-Test-Suite/Level-3">
<!ENTITY spec        "http://www.w3.org/TR/DOM-Level-3-LS/load-save.html">
<!ENTITY date        "<date qualifier='created'>2002-03-23</date>">
<!ENTITY contributor "<contributor>X-Hive Corporation</contributor>">
<!ENTITY creator     "<creator>Jeroen van Rotterdam</creator>">

<!ENTITY vars        "
                      <var name='implementation'   type='DOMImplementation'/> 
                      <var name='lsImplementation' type='DOMImplementationLS'/> 
                      <var name='inputSource'      type='DOMInputSource'/> 
                      <var name='document'         type='Document'/>            
                      <var name='writer'           type='DOMWriter'/>            
                      <var name='builder'          type='DOMBuilder'/>
                      <var name='schemaType'       type='DOMString' value='null'/>
                     
                      <!-- constants  -->
                      <var name='SHOW_ELEMENT'      type='short'  value='1'/>
                      <var name='FILTER_ACCEPT'     type='short'  value='1'/>
                      <var name='FILTER_REJECT'     type='short'  value='2'/>
                      <var name='FILTER_SKIP'       type='short'  value='3'/>
                      <var name='MODE_SYNCHRONOUS'  type='short'  value='1'/>
                      <var name='MODE_ASYNCHRONOUS' type='short'  value='2'/>
                      <var name='DTD_SCHEMATYPE'    type='DOMString' value='&quot;http://www.w3.org/TR/REC-xml&quot;'/>
                      <var name='SCHEMA_SCHEMATYPE' type='DOMString' value='&quot;http://www.w3.org/2001/XMLSchema&quot;'/>

                      <!-- action types DOMBuilder.parseWithContext -->
                      <var name='ACTION_REPLACE'             type='short' value='1'/>
                      <var name='ACTION_APPEND_AS_CHILDREN'  type='short' value='2'/>
                      <var name='ACTION_INSERT_AFTER'        type='short' value='3'/>
                      <var name='ACTION_INSERT_BEFORE'       type='short' value='4'/>


                      <!-- testfiles  -->
                      <var name='TEST0' type='DOMString' value='&quot;test0.xml&quot;'/>
                      <var name='TEST1' type='DOMString' value='&quot;test1.xml&quot;'/>
                      <var name='TEST2' type='DOMString' value='&quot;test2.xml&quot;'/>

                      <implementation var='implementation'/> 
                      <assign var='lsImplementation' value='implementation'/> 
                      ">

<!ENTITY init        "<createDOMBuilder      var='builder'     obj='lsImplementation' mode='MODE_SYNCHRONOUS' schemaType='schemaType'/>
                      <createDOMWriter       var='writer'      obj='lsImplementation'/>
                      <createDOMInputSource  var='inputSource' obj='lsImplementation'/>">

<!ENTITY builder.setFilter_myfilter "<filter obj='builder' value='myfilter' interface='DOMBuilder'/>">

<!--
  <!ENTITY SHOW_ELEMENT "1">
  <!ENTITY FILTER_ACCEPT "1">
  <!ENTITY FILTER_REJECT "2">
  <!ENTITY FILTER_SKIP "3">
  <!ENTITY MODE_SYNCHRONOUS "(short)1">
  <!ENTITY MODE_ASYNCHRONOUS "(short)2">
  <!ENTITY DTD_SCHEMATYPE    "&quot;http://www.w3.org/TR/REC-xml&quot;">
  <!ENTITY SCHEMA_SCHEMATYPE "&quot;http://www.w3.org/2001/XMLSchema&quot;">
-->
DOMBuilderTest1.java (text/java, 2.6 KB)
package org.w3c.domts.level3.ls;

import org.w3c.dom.*;
import org.w3c.dom.html.*;
import org.w3c.dom.events.*;
import org.w3c.domts.*;

import org.w3c.dom.ls.*;
    

import javax.xml.parsers.*;
import java.util.List;
import java.util.Collection;
import java.util.ArrayList;



/**
* DOM Builder test
* @author Jeroen van Rotterdam
* @author X-Hive Corporation
* @see <a href=""></a>
*/
public class DOMBuilderTest1 extends DOMTestCase {

   public DOMBuilderTest1(DOMTestDocumentBuilderFactory factory) 
 {
      super(factory);

   }

   public void runTest() throws java.lang.Throwable {
      DOMImplementation implementation;
      DOMImplementationLS lsImplementation;
      DOMInputSource inputSource;
      Document document;
      DOMWriter writer;
      DOMBuilder builder;
      String schemaType = null;
      short SHOW_ELEMENT = 1;
      short FILTER_ACCEPT = 1;
      short FILTER_REJECT = 2;
      short FILTER_SKIP = 3;
      short MODE_SYNCHRONOUS = 1;
      short MODE_ASYNCHRONOUS = 2;
      String DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml";
      String SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema";
      short ACTION_REPLACE = 1;
      short ACTION_APPEND_AS_CHILDREN = 2;
      short ACTION_INSERT_AFTER = 3;
      short ACTION_INSERT_BEFORE = 4;
      String TEST0 = "test0.xml";
      String TEST1 = "test1.xml";
      String TEST2 = "test2.xml";
      implementation = getImplementation();
lsImplementation = (DOMImplementationLS) implementation;
builder = lsImplementation.createDOMBuilder(((short)/*short*/MODE_SYNCHRONOUS),((String)/*String*/schemaType));
      writer = lsImplementation.createDOMWriter();
      inputSource = lsImplementation.createDOMInputSource();
      NodeList elementList;
      String stringDoc;
      document = builder.parseURI(((String)/*String*/TEST0));
      elementList = document.getElementsByTagName("elt2");
      assertSize("elementGetElementsByTagNameAssert",1,elementList);
      Element firstElt2;
      firstElt2 = (Element)elementList.item(0);
      inputSource.setSystemId(/* undeclared */TEST2);
      builder.parseWithContext(inputSource,firstElt2,((short)/*short*/ACTION_REPLACE));
      elementList = document.getElementsByTagName("elt2");
      assertSize("elementGetElementsByTagNameAssert",1,elementList);
      elementList = document.getElementsByTagName("elt3");
      assertSize("elementGetElementsByTagNameAssert",1,elementList);
      
   }
   public String getTargetURI() {
      return "http://www.w3.org/2001/DOM-Test-Suite/level3/ls/DOMBuilderTest1";
   }
   public static void main(String[] args) {
        DOMTestCase.doMain(DOMBuilderTest1.class,args);
   }
}
DOMBuilderTest1.xml (text/xml, 1.4 KB)
<?xml version="1.0" standalone="no"?>

<!DOCTYPE test SYSTEM 'dom3.dtd' [
  <!ENTITY % entities SYSTEM "dom3tests.ent">
  %entities;
]>

<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-3" name="DOMBuilderTest1">
  <metadata>
    <title>basic builder test</title>
    &creator; 
    <description>DOM Builder test</description> 
    &contributor; &date;
    <subject resource="&spec;#LS-Interfaces-DOMBuilder"/>
  </metadata>
  <var name="elementList" type="NodeList"/>
  <var name="stringDoc"   type="DOMString"/>
  <var name="firstElt2"   type="Element"/>
  &vars;
  
  &init;

  <parseURI  var="document" obj="builder" uri="TEST0"/>
  <getElementsByTagName interface="Document" obj="document" tagname="&quot;elt2&quot;" var="elementList"/>
  <assertSize collection="elementList" size="1" id="elt2Count_1"/>

  <item interface="NodeList" obj="elementList" var="firstElt2" index="0"/>

  <systemId obj="inputSource" value="TEST2" interface="DOMInputSource"/>
  <parseWithContext  obj="builder" is="inputSource" cnode="firstElt2" action="ACTION_REPLACE"/>
  
  <getElementsByTagName interface="Document" obj="document" tagname="&quot;elt2&quot;" var="elementList"/>
  <assertSize collection="elementList" size="1" id="elt2Count_2"/>

  <getElementsByTagName interface="Document" obj="document" tagname="&quot;elt3&quot;" var="elementList"/>
  <assertSize collection="elementList" size="1" id="elt3Count"/>

</test>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.