<?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="DOMEntityResolverTest2">
  <metadata>
    <title>DOMEntityResolverTest2</title>
    &creator;
    <description>Resource resolvers do not participate in resolving the top-level document entity.
    This test attempts to redirect any resource and then checks that the
    requested document was not affected.</description>
    &contributor; &date;
    <subject resource="&spec;#LS-LSResourceResolver-resolveResource"/>
    <subject resource="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save#parameter-resource-resolver"/>
  </metadata>

  <var name="resourceURI" type="DOMString"/>
  <var name="docElem" type="Element"/>
  <var name="docElemName" type="DOMString"/>
  <var name="myentityresolver" type="LSResourceResolver">
     <resolveResource>
             <var name="domImplLS" type="DOMImplementationLS"/>
             <var name="redirectedInput" type="LSInput"/>
             <var name="source" type="DOMString" value='"&lt;!DOCTYPE failure [&lt;!ELEMENT failure EMPTY&gt;]&gt;&lt;failure/&gt;"'/>

        <!--
            The resolveResource should not be invoked,
               but if it is substitute a failure document   -->
        <implementation var="domImplLS"/>
        <createLSInput var="redirectedInput" obj="domImplLS"/>
        <stringData obj="redirectedInput" value="source" interface="LSInput"/>
        <return value="redirectedInput"/>
     </resolveResource>
  </var>

  <var name="configuration" type="DOMConfiguration"/>

  &vars;
  &init;

  <domConfig var="configuration" obj="parser" interface="LSParser"/>
  <setParameter obj="configuration" name='"resource-resolver"' value="myentityresolver"/>

  <getResourceURI var="resourceURI" href="TEST0" contentType="text/xml"/>
  <parseURI var="document" obj="parser" uri="resourceURI"/>
  <assertNotNull actual="document" id="documentNotNull"/>
  <documentElement var="docElem" obj="document"/>
  <nodeName var="docElemName" obj="docElem"/>
  <assertEquals actual="docElemName" expected='"elt0"'
                  id="docElemName" ignoreCase="false"/>
</test>





