rivashin

This bug is reproducible in IE 7 (my build is 7.0.5730.11), IE 6.
Problem: IE incorrectly resolves relative links passed to XSLT document()
function.
This happens only if user agent was redirected to a XML document with
associated XSL stylesheet, and parameter for document() function is a node
from this XML document.
In this case relative link should be resolved based on URI of XML document.
But it is resolved incorrectly.
Moreover, when user agent visits this XML document for the first time in
current session, everything is ok. If then it goes to some page that will redirect
back to the XML document, link is resolved incorrectly and browser shows
error
"The XML page cannot be displayed. Cannot view XML input using XSL style
sheet. Please correct the error and then click the Refresh button, or try
again later.
The system cannot locate the object specified."

Yes, this description is a little bit confusing.. I've created a small
testcase that contains only 2 XML files, 1 XSL file and 1 JSP page (this page
simply redirects user to XML document). But I didn't found any place where I
can report this bug and attach this testcase to it. If you provide me a link
to such place, I can post it there.
I can only add content of XML and XSL here, but directory structure is
critical to reproduce this bug.
I'm using Apache Tomcat 5.5.20 and deploy this testcase as web-module to
"/bad" folder.

main XML doc: /bad/xml/main/test.xml
< xml version="1.0" encoding="UTF-8" >
< xml-stylesheet type="text/xsl" href="../../xsl/test.xsl" >
<aaa>
<bbb href="../../xml/include/bar.xml"/>
</aaa>


XML doc included by XSL: /bad/xml/include/bar.xml
< xml version="1.0" encoding="UTF-8" >
<eee>
qwerty
</eee>


XSL file: /bad/xsl/test.xsl
< xml version="1.0" encoding="UTF-8" >
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="dialog-element" select="document(//bbb[1]/@href)/eee"/>
<xsl:template match="/">
      eeeee
<xsl:value-of select="$dialog-element"/>
</xsl:template>
</xsl:stylesheet>

JSP file (redirects to /bad/xml/main/test.xml): /bad/index.jsp
<%
response.sendRedirect("xml/main/test.xml");
%>

Steps to reproduce:
  1. deploy files to Apache Tomcat, to "/bad" folder.
  2. In IE go to /bad/index.jsp It redirects you to /bad/xml/main/test.xml, this time XSLT works fine and browser shows "eeeee qwerty"
  3. In the same window, go again to /bad/index.jsp
    This time XSLT fails and browser shows error page.
    This is because relative link "../../xml/include/bar.xml" was incorrectly resolved to
    "/xml/include/bar.xml", while base URI is "/bad/xml/main/test.xml"