I'm getting a weird behavior using Xalan 2.0.1 and the transform
method.  I'm not sure if it's just my lack of understanding of what's
happening or a real issue.  I presumed that this would work.

(This isn't the exact code because it's spread out but a best display of
the snippets I'm using with Xalan.)

I have a ControlledParser class which is essentially a subclass of
DomParser with the setDeferred expansion to false by default.  This is
the behavior we need.

I get an instance of the parser and call
parser.parse(new InputSource(new StringReader(xmlString)));
Then I get a DOMSource with new DOMSource(parser.getDocument())

I get my xml source and xsl source the same way.  Then I do the basics:

DOMResult domResult = new DOMResult();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xslSource);
transformer.transform(xmlSource, domResult);

This all seems pretty rudimentary to me.  It seems to work until the
point where I have an xmlSource file of greater than 76K (roughly).
Then I start getting the String index out of range errors during the
transform call.

I can fix this by instead doing:

            DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document xmlDoc = builder.parse(new InputSource(
                new StringReader(xml)));
            DOMSource xmlSource = new DOMSource(xmlDoc);

To get the xmlSource and then doing the same transform but I'm not sure
why that is.  Could somebody explain to me the difference?  I would have
though that I could pass any DOMSource to the transform and it would
work but that doesn't seem to be the case.  It's apparent to me I'm
missing something basic.

   Thanks,
            g888


Reply via email to