You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by METALOID <me...@gmail.com> on 2008/02/07 17:43:13 UTC
XALAN URIResolver not behaving correctly?
I have a problem with xalan URIResolver, it just doesn't call resolve at all
when my XML file is inputed by a document() function on the XSLT and has
latin1 characters like ã , ç ... etc.
Why is this happening?
{code}
static class MyResolver implements URIResolver{
public Source resolve(String href, String base)
{
try {
System.out.println("RESOLVING: href: "+href+" base: "+base);
StreamSource ss = new StreamSource(new FileInputStream(new File(href)));
return ss;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
}
....
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.setURIResolver(new MyResolver());
trans.setParameter("lang", lang);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document xslfo = db.newDocument();
trans.transform(xmlSource, new DOMResult(xslfo));
{code}
My XSLT calls the document() function this way:
{code}
.....
<xsl:variable name="cp-doc-path">
<xsl:text>lala/certprofile_</xsl:text>
<xsl:value-of
select="normalize-space(default_certificate_profile)"></xsl:value-of>
<xsl:text>-</xsl:text>
<xsl:value-of
select="default_certificate_profile/@id"></xsl:value-of>
<xsl:text>.xml</xsl:text>
</xsl:variable>
.....
<xsl:variable name="n2">
<xsl:for-each select="document($cp-doc-path)">
<xsl:variable name="a0">
<xsl:value-of select="$n0 + count(
//field |
//key_usage |
//ku |
//policies |
//extended_key_usage |
//eku
)"></xsl:value-of>
</xsl:variable>
.....
{code}
As it doesn't perform the URIResolver resolve() call, I get the following
exception:
javax.xml.transform.TransformerException:
com.sun.org.apache.xalan.internal.xsltc.TransletException:
javax.xml.transform.TransformerException:
com.sun.org.apache.xml.internal.utils.URI$MalformedURIException: Path
contains invalid character: ç
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:715)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
I'm currently using the latest Xalan version.
--
View this message in context: http://www.nabble.com/XALAN-URIResolver-not-behaving-correctly--tp15337911p15337911.html
Sent from the Xalan - J - Users mailing list archive at Nabble.com.