-
Bug
-
Resolution: Fixed
-
P2
-
5.0
-
1.6
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2125981 | 5.0u14 | Santiago Pericasgeertsen | P2 | Resolved | Fixed | b01 |
I have a stylesheet, outer.xsl, that includes another stylesheet, inner.xsl,
via the xsl:include construct. If I provide my own URIResolver and attempt
to compile outer.xsl from a DOMSource then XSLTC loops forever, repeatedly
resolving inner.xsl but never actually making any progress.
-- Bug.java --
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
public class Bug {
private static URIResolver resolver = new URIResolver() {
private int n = 0;
public Source resolve(String href, String base)
throws TransformerException
{
System.err.println("resolve " + href);
if (n++ > 10) {
System.err.println("Test failed");
System.exit(1);
}
return new StreamSource(Bug.class.getResourceAsStream(href));
}
};
private static Document load(InputStream in)
throws IOException
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
DocumentBuilder db = dbf.newDocumentBuilder();
return db.parse(in);
} catch (Exception x) {
throw new RuntimeException(x);
}
}
public static void main(String[] args) throws Exception {
boolean workaround = args.length > 0;
TransformerFactory tff = TransformerFactory.newInstance();
tff.setURIResolver(resolver);
InputStream xin
= new BufferedInputStream(new FileInputStream("outer.xsl"));
Templates tt = null;
if (workaround)
tt = tff.newTemplates(new StreamSource(xin));
else
tt = tff.newTemplates(new DOMSource(load(xin)));
Transformer tf = tt.newTransformer();
}
}
-- outer.xsl --
<s:stylesheet xmlns:s="http://www.w3.org/1999/XSL/Transform" version="1.0">
<s:include href="inner.xsl"/>
</s:stylesheet>
-- inner.xsl --
<s:stylesheet xmlns:s="http://www.w3.org/1999/XSL/Transform" version="1.0"/>
If I use a StreamSource rather than a DOMSource to read outer.xsl then this
problem does not occur.
This bug is reproducible in Tiger, in 5.0u2, and in Mustang b26.
###@###.### 2005-03-07 04:06:07 GMT
integrated in tag JWSDP-1_6-b08
###@###.### 2005-05-02 23:03:21 GMT
via the xsl:include construct. If I provide my own URIResolver and attempt
to compile outer.xsl from a DOMSource then XSLTC loops forever, repeatedly
resolving inner.xsl but never actually making any progress.
-- Bug.java --
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
public class Bug {
private static URIResolver resolver = new URIResolver() {
private int n = 0;
public Source resolve(String href, String base)
throws TransformerException
{
System.err.println("resolve " + href);
if (n++ > 10) {
System.err.println("Test failed");
System.exit(1);
}
return new StreamSource(Bug.class.getResourceAsStream(href));
}
};
private static Document load(InputStream in)
throws IOException
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
DocumentBuilder db = dbf.newDocumentBuilder();
return db.parse(in);
} catch (Exception x) {
throw new RuntimeException(x);
}
}
public static void main(String[] args) throws Exception {
boolean workaround = args.length > 0;
TransformerFactory tff = TransformerFactory.newInstance();
tff.setURIResolver(resolver);
InputStream xin
= new BufferedInputStream(new FileInputStream("outer.xsl"));
Templates tt = null;
if (workaround)
tt = tff.newTemplates(new StreamSource(xin));
else
tt = tff.newTemplates(new DOMSource(load(xin)));
Transformer tf = tt.newTransformer();
}
}
-- outer.xsl --
<s:stylesheet xmlns:s="http://www.w3.org/1999/XSL/Transform" version="1.0">
<s:include href="inner.xsl"/>
</s:stylesheet>
-- inner.xsl --
<s:stylesheet xmlns:s="http://www.w3.org/1999/XSL/Transform" version="1.0"/>
If I use a StreamSource rather than a DOMSource to read outer.xsl then this
problem does not occur.
This bug is reproducible in Tiger, in 5.0u2, and in Mustang b26.
###@###.### 2005-03-07 04:06:07 GMT
integrated in tag JWSDP-1_6-b08
###@###.### 2005-05-02 23:03:21 GMT
- backported by
-
JDK-2125981 XSLTC never stops resolving imported stylesheets when outer stylesheet is a DOMSource
- Resolved