cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Pfarr" <apf...@netsurf.de>
Subject AW: Entities
Date Mon, 03 Jan 2000 23:42:39 GMT
Hi Stefano,

it doesn't work with full quallified pathnames or HTTP-URL's either.

I checked the Xalan-code, which seems to be the reason for this problem:
I did a little test-programm (derived from the XALAN-samples) that looks
like

public class transform
{
	public static void main(String[] args)
    throws java.io.IOException,
           java.net.MalformedURLException,
           org.xml.sax.SAXException
	{
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new
XercesLiaison());

    DOMParser parser = new DOMParser();

parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-node
s", false);

    parser.parse(new InputSource("foo.xml"));
    Document doc = (Document)parser.getDocument();
    XSLTInputSource xmlID = new XSLTInputSource(doc);
    XSLTInputSource stylesheetID = new XSLTInputSource("foo.xsl");
    XSLTResultTarget resultTarget = new XSLTResultTarget(System.out);
    processor.process(xmlID,stylesheetID,resultTarget);

	}
}

if you run it like this, the result is correct.

If you use the parser-default-behaviour or set the feature above to true,
the Entities vanish.

In any case, the Entities are eaten up if you do it like this:

public class transform
{
	public static void main(String[] args)
    throws java.io.IOException,
           java.net.MalformedURLException,
           org.xml.sax.SAXException
	{
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new
XercesLiaison());

    DOMParser parser = new DOMParser();

parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-node
s", false);

    parser.parse(new InputSource("foo.xml"));
    Document doc = (Document)parser.getDocument();
    XSLTInputSource xmlID = new XSLTInputSource(doc);
    XSLTInputSource stylesheetID = new XSLTInputSource("foo.xsl");
    Document out = new org.apache.xerces.dom.DocumentImpl();
    XSLTResultTarget resultTarget = new XSLTResultTarget(out);
    processor.process(xmlID,stylesheetID,resultTarget);

    PrintWriter pw = new PrintWriter( System.out );
    FormatterToHTML fl = new FormatterToHTML(pw);
    TreeWalker tw = new TreeWalker(fl);
    tw.traverse(out);
	}
}

To me that looks like a bug in the Xalan distribution (I'm using Xalan
0.19.1). The FormatterToHTML (same goes for the FormatterToXML) just doesn't
behave as it should!

In any case, you should set

parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-node
s", false);
in your code, even though the Xalan-documenation is somewhat misleading in
this aspect.

The program doesn't work, if you construct the XSLTProcessor with
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
That raises an Exception during execution. Since you wrote your own
XMLParserLiaison-class you should check, whether that differs from the
XercesLiaison-class in the Xalan-Distribution, even though, I don't think
that this is the problem.


Hope that helped you over the night

Armin
P.S.
If you want to dive into that stuff more deeply, take a look at James Clarks
XML-testcases (http://www.jclark.com) and run them against the parsers you
are supporting. I know this guy has a strange way of documenting his code
(he must have a program that strips away all the comments), but he knows
what "conforming to the standard" really means (from my experience: most
parser producers don't).



Mime
View raw message