You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Vladimir Blagojevic <vl...@xisnext.2y.net> on 2001/05/21 05:57:56 UTC

Bug report:EntityResolver not propagated to new XMLReader

Hello,

I've been trying unsuccessfully to enter bug report in bugzilla but the
commit/post just doesn't work so I'll record it here.

1)Overview Description:

Quoting comment by Gary Peskin:

On quickly reviewing the code it looks an XMLReader is created to read
in the l10n.xml document. This happens in
SourceTreeManager.getDOMNode. However, the EntityResolver from the
original reader does not get propagated to this newly created
XMLReader. You might want to hack around with this code and force your
custom EntityResolver into the newly created reader.

I wouldn't feel comfortable making a change to the real Xalan code,
however, without a concrete example to recreate the problem.

Could you enter this in Bugzilla and attach your java code and a set of
minimal XML and XSLT documents needed to recreate this issue. If you're
initiating your transform from the command line with the -entityresolver
switch, please so state and include the command line that you're using.

I'll be out of town in the coming week but this will allow the problem
to be tracked and if someone can fix it before I return, that's great.
Otherwise, I'll have a look when I get back.

Gary

2)Steps to Reproduce


Most minimal example. I used command line to invoke xalan processor:

java org.apache.xalan.xslt.Process -in jbossdocs.xml -xsl l10n.xsl -out
out.html -URIResolver SimpleURIResolver -EntityResolver
SimpleEntityResolver

SimpleURIResolver.java
---------------------------
import java.io.*;
import javax.xml.transform.URIResolver;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;

public class SimpleURIResolver implements URIResolver{



public Source resolve(String href, String base)
{

System.out.println("Called href " + href + " ,base " + base);

InputStream in = null;

try
{
in = new FileInputStream(href);

}
catch (IOException ioe)
{
System.out.println("Did not " + href);
return null;
}


StreamSource source = new StreamSource(in);
source.setSystemId(href);
return source;
}
}

SimpleEntityResolver.java
----------------------------------------------

import java.io.*;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;

public class SimpleEntityResolver implements EntityResolver {



public InputSource resolveEntity (String publicId, String systemId)
{


System.out.println("Custom EntityResolver called , publicId " + publicId +
" systemId "+systemId);


InputStream in = null;
try
{
in = new FileInputStream(systemId);
}
catch (IOException ioe)
{
System.out.println("Did not find" + systemId);
return null;
}
return new InputSource(in);
}
}

l10n.xsl
------------------------------

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>



<xsl:template match="book">
<xsl:message>Found book element</xsl:message>
<xsl:param name="l10n.xml" select="document('l10n.xml')"/>
<xsl:message>End book element template</xsl:message>
</xsl:template>

</xsl:stylesheet>

jbossdocs.xml
-----------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

<book>
<bookinfo>
<title>JBoss 2.1+ documentation</title>
<copyright>
<year>2000</year>
<year>2001</year>
<holder>JBoss Organization</holder>
</copyright>
</bookinfo>
</book>



3)Actual Results

file:///home/vlad/xalanbug/l10n.xsl; Line 8; Column 14; Found book element
Called href l10n.xml ,base file:///home/vlad/xalanbug/l10n.xsl
Called href l10n.xml ,base file:///home/vlad/xalanbug/l10n.xsl
file:///home/vlad/xalanbug/l10n.xsl; Line 10; Column 14; End book element
template

4)Expected Results

The specified SimpleEntityResolver was never called although it was
supposed to in order to resolve l10n.dtd and en.xml referenced in newly
loaded l10n.xml.

These two files(l10.dtd, en.xml) are automatically resolved by default
EntityResolver. If these two files are not present processor complains that
it can not find them, which ok, but AGAIN custom EntityResolver was not
invoked.

5)Build Date & Platform
xalanj2.0.1 official release , sun jdk1.3, Linux 2.4 kernel


Re: Bug report:EntityResolver not propagated to new XMLReader

Posted by Gary L Peskin <ga...@firstech.com>.
Validimir --

Hi.  I've entered the bug into bugzilla.  It is bug 1830.  However, you
omitted the file l10n.xml which contains the entity references that we
are supposed to be resolving via the EntityResolver.

Could you either update the bug
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1830) with that file
or send it to the mailing list and I'll update the bug if you're still
having bugzilla problems.

Thanks,
Gary

Vladimir Blagojevic wrote:
> 
> Hello,
> 
> I've been trying unsuccessfully to enter bug report in bugzilla but the
> commit/post just doesn't work so I'll record it here.
> ...