<?xml version="1.0" standalone="no"?>
<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
<!--
 Copyright (c) 2003 X-Hive Corporation

 All Rights Reserved. This work is distributed under the W3C(r)
 Software License [1] in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.

 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-->


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


<test xmlns="&level3;" name="DOMWriterFilterTest2">
  <metadata>
    <title>DOMWriterFilterTest2</title>
    &creator;
    <description>Uses a filter to strip text during serialization
    parsers to check expections.</description>
    &contributor; &date;
        <subject resource="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save#LS-LSSerializer-LSSerializerFilter"/>
        <subject resource="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save#LS-LSSerializerFilter-acceptNode"/>
        <subject resource="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save#LS-LSSerializerFilter-whatToShow"/>
        <subject resource="http://www.w3.org/Bugs/Public/show_bug.cgi?id=643"/>
  </metadata>


  <var name="myfilter" type="LSSerializerFilter">
     <var name="name" type="DOMString"/>
     &filterVars;

     <acceptNode>
        <return value="&FILTER_REJECT;"/>
     </acceptNode>

     <whatToShow>
       <get>
        <return value="&SHOW_TEXT;"/>
       </get>
     </whatToShow>

  </var>




  <var name="stringDoc"       type="DOMString" value="&quot;&lt;elt1 attr1='attr1'&gt;first elt1&lt;/elt1&gt;&quot;"/>
  <var name="writeResult"     type="DOMString"/>
  <var name="length"          type="int"/>
  <var name="elementList"     type="NodeList"/>
  <var name="elt1"            type="Element"/>
  <var name="childs"          type="boolean"/>
  <var name="attrNode"        type="Attr"/>
  <var name="attr1"           type="DOMString"/>

  &vars;
  &init;

  <!-- parse the string -->
  <stringData obj="inputSource" value="stringDoc"/>
  <parse  var="document" obj="parser" input="inputSource"/>

  <!-- apply the filter -->
  <filter obj="writer" value="myfilter" interface="LSSerializer"/>

  <!-- serialize result -->
  <writeToString var="writeResult" obj="writer" nodeArg="document"/>

  <!-- parse result -->
  <stringData obj="inputSource" value="writeResult" interface="LSInput"/>
  <parse  var="document" obj="parser" input="inputSource"/>

  <!-- tests no child of elt1-->
  <getElementsByTagName interface="Document" obj="document" tagname="&quot;elt1&quot;" var="elementList"/>
  <item interface="NodeList" obj="elementList" index="0" var="elt1"/>

  <!--  attr not effected since children of attribute nodes not passed to filter -->
  <getAttributeNode var="attrNode" obj="elt1" name='"attr1"'/>
  <assertNotNull actual="attrNode" id="attrExists"/>
  <nodeValue var="attr1" obj="attrNode"/>
  <assertEquals actual="attr1"  expected='"attr1"' ignoreCase="false" id="attrUnchanged"/>

  <!--  elt1 should be empty   -->
  <hasChildNodes obj="elt1" var="childs"/>
  <assertFalse actual="childs" id="nodeHasChilds_elt1"/>


</test>




