cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Artur Zawlocki <a_zawlo...@poczta.onet.pl>
Subject Re: Mystery NullPointerException with standalone usage.
Date Wed, 24 May 2000 07:58:03 GMT
Hello,

Paul Derbyshire wrote:
> 
> At 10:54 PM 5/22/00 I wrote:
> >At 12:54 AM 5/23/00 +0100, you wrote:
> >><?xml-stylesheet?> etc isn't part of the XSL specification, it's a
> >Cocoon (1.x) thing, so Xalan won't know about it. You might be able
> >to write a perl script to do the job, if you're after a quick hack.
> >
> >Are you sure? The Xalan 1.0.1 documentation mentions offhandedly that Xalan
> >can parse these directives, but it doesn't seem to explain how to make it do
> >so.
> 
> I have browsed some docs again and can now quote chapter and verse on that:
> from getstarted.html:
> 
> <blockquote>If the XML document contains a stylesheet Processing
> Instruction (PI), you do not need to create a separate XSLTInputSource
> object for an XSL stylesheet.</blockquote>

Look at the 'org.apache.xalan.xslt.XSLTProcessor' Interface in the Xalan
API docs. There's a 

  StylesheetSpec getAssociatedStylesheet (XSLTInputSource source,
					  String media, String charset)

method which uses <?xsl-stylesheet?> PI. This PI is not cocoon-specific,
it's defined in a W3C recommendation (look at
http://www.w3.org/TR/xml-stylesheet).

And 'StylesheetSpec' is a subclass of 'XSLTInputSource', so you can just
write:

  XSLTProcessor processor = new SomeXSLTProcessorImplementation (..);
  StylesheetSpec spec = 
	processor.getAssociatedStylesheet (new XSLTInputSource(inFileName),
                                           media, null);
  processor.process (new XSLTInputSource (inFileName), 
		     spec,
		     new XSLTResultTarget (outputStream));

which is the way org.apache.xalan.xslt.Process.main works when XSL file
name is not supplied at the command line.

Regards,
Artur

Mime
View raw message