This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: <xsl:include> and Oracle java classes
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] <xsl:include> and Oracle java classes
- From: "Ellis, Graham" <graham dot ellis at actfs dot co dot uk>
- Date: Fri, 2 Mar 2001 14:41:25 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Thanks Steve, this worked perfectly. However, once I deployed the classes
and the stylesheets as stored procedures on the database the code failed to
find the main stylesheet. So - should I put the stylesheets outside the
database, or can it be done with the stylesheets deployed?
Graham Ellis
ACT Financial Systems
* Tel: +44 (0) 20 7250 1990
* Fax: +44 (0) 20 7553 4713
* Email: graham.ellis@actfs.co.uk
* http://www.actfs.co.uk
> ----------
> From: Steve Muench[SMTP:Steve.Muench@oracle.com]
> Reply To: xsl-list@lists.mulberrytech.com
> Sent: 01 March 2001 22:36
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] <xsl:include> and Oracle java classes
>
> | I'm writing a Java app that selects data from our Oracle database,
> formats
> | it into XML then uses the Oracle 'XSLStylesheet' and 'XSLProcessor'
> classes
> | to load a stylesheet and transform the XML.
> |
> | Unfortunately it fails on the first <xsl:include> - I assume because the
> | main stylesheet is loaded as an InputStream, and the included
> stylesheets
> | are still files on the disk.
> |
> | Is there a way for the Oracle classes to load stylesheets referenced by
> | <xsl:include>?
>
> Sure. Load the stylesheet from a resource URL instead of
> as an InputStream. The input stream approach works when
> the stylesheet has no relative stylesheets it needs to
> read, but by using a resource URL, all of the relative
> references are handled for you.
>
> Here a sample. Assumes the "Sample.xsl" stylesheet and
> the "SampleHelper.xsl" stylesheet which the former
> includes via <xsl:include> are at the the same level
> of directory hierarchy in your CLASSPATH as the current class.
>
> import oracle.xml.parser.v2.*;
> import java.net.URL;
> public class TransformExample {
> public static void main( String[] arg ) throws Throwable {
> DOMParser theParser = new DOMParser();
> theParser.parse(new java.io.StringReader("<x/>"));
> XMLDocument source = theParser.getDocument();
> // Resource "Sample.xsl" does <xsl:include href="SampleHelper.xsl"/>
> URL url = TransformExample.class.getResource("Sample.xsl");
> XSLStylesheet transform = new XSLStylesheet(url,url);
> XSLProcessor proc = new XSLProcessor();
> proc.processXSL(transform,source,System.out);
> }
> }
>
> ______________________________________________________________
> Steve Muench, Lead XML Evangelist & Consulting Product Manager
> BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
> Author "Building Oracle XML Applications", O'Reilly
> http://www.oreilly.com/catalog/orxmlapp/
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list