Stylesheet calling customized document() function namespace problem
-------------------------------------------------------------------
Key: XALANJ-2165
URL: http://issues.apache.org/jira/browse/XALANJ-2165
Project: XalanJ2
Type: Bug
Components: XSLTC
Versions: 2.6
Environment: Windows XP SP2
Java SDK 1.5.0
Reporter: Giacomo Villoresi
Hi,
I needed to customize the XSLT document() function to manage certain
exceptions, so I wrote an utility class in Java with the loadDocument() static
method.
Here is a part of the Stylesheet, that invokes the external method:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ic="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsltutil="my.package.XSLTUtil"
exclude-result-prefixes="ic xsltutil">
[...]
<xsl:variable name="doc" select="xsltutil:loadDocument($doc-url)"/>
[...]
and this is a snippet of the Java code:
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
public class XSLTUtil {
[...]
public static Node loadDocument(String urlString) {
try {
URL url = new URL(urlString);
InputStream is = url.openStream();
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(is);
return doc;
} catch (Exception e) {
getLog().error("Unable to load document: " + e.getMessage());
}
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder()
.newDocument();
} catch (Exception ignored) {
}
return null;
}
}
the code works well when I try to load document without namespace, but in all
the other cases (default namespace or qualified elements, using only namespaces
also declared in the stylesheet, for instance the one with the "ic" prefix) the
XSLT hangs with the following error:
'NAMESPACE_ERR: An attempt is made to create or change an object in a way which
is incorrect with regard to namespaces.'
while I notice that Xalan interpreter simply removes the namespace.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]