[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Which parser is used when document() is called?

Subject: RE: Which parser is used when document() is called?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 2 Apr 2002 18:18:00 +0100
why parser is used
You might find that Xalan uses the parser given by the
javax.xml.parsers.SAXParserFactory system property; on the other hand, to
use that you have to implement a SAXParser rather than merely an XMLReader.
The URIResolver technique is probably better and more portable. You can find
URIResolver in the JAXP documentation.

Something like:

    transformer.setURIResolver(new UserURIResolver());
...

    public static class UserURIResolver implements URIResolver {

        public Source resolve(String href, String base)
        throws TransformerException {
            if (href.endsWith(".xxx")) {
                try {
                    URL url = new URL(new URL(base), href);
			  SAXSource ss = new SAXSource();
                    ss.setSystemId(url.toString());
                    ss.setXMLReader(new MyOwnParser());
                    return ss;
                } catch ...
            } else {
                return null;
            }
        }

    }

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> Jakub.Valenta@xxxxxxxx
> Sent: 02 April 2002 17:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Which parser is used when document() is called?
>
>
>
> Hi Michael,
>
> in my case I use Xalan as an XSLT processor and my 100% home
> grown parser
> (it just implements XMLReader), which takes delimiter text
> and makes simple
> conversion to SAX events.
>
>      /* my factory which returns my implementation of XMLReader */
>      XMLReader myParser = ParserFactory.getParser(config);
>      InputSource input =  new InputSource(new StringReader(data));
>
>           SAXSource source = new SAXSource(myParser , input);
>           StreamResult result = new StreamResult(new File("g:
> \\dev\\parsers\\test\\result.xml"));
>
>           transformer.transform(source, result);
>
> If I start the XSLT processor like this, it has reference only to my
> proprietary parser (No to any xerces, or crimson), so then if
> I'll have
> some "documnet()" call in the XSLT style sheet will it use
> the same parser
> which I specified in SAXSource() (it mean my parser), or what?
>
> I just think that it has to call my parser since it does not
> know about any
> other (I didn't provide instance of any other parser), but I
> am not sure.
>
> btw: what is the URIResolver?
>
> br,
>
> Jakub
>
>
>
>
>
> "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>@lists.mulberrytech.com on
> 04/02/2002 05:00:22 PM
>
> Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>
> Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>
>
> To:   <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> cc:
>
> Subject:  RE:  Which parser is used when document() is called?
>
> If you are using a JAXP-conformant processor, then you can
> set the parser
> from the URIResolver that is called when document() is called.
>
> The details for this kind of question depend very much on
> which product you
> are using!
>
> Michael Kay
> Software AG
> home: Michael.H.Kay@xxxxxxxxxxxx
> work: Michael.Kay@xxxxxxxxxxxxxx
>
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> > Jakub.Valenta@xxxxxxxx
> > Sent: 02 April 2002 11:47
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Which parser is used when document() is called?
> >
> >
> > Hi all,
> > I am doing some text to xml conversion, and I have build my
> > own SAX-like
> > parser which I use as a source for XSLT. It works just fine,
> > but now I would like to use the document() function in my
> > xslt and I would
> > like it to use my parser again sine I want to include file which is
> > textual (so the parser should conver it to xml).
> >
> > So does anyone know which parser is used for document()
> > calls? is it the
> > same one which is used to parse the main document (then I am
> > save) or is it
> > always some
> > default parser (the I have troubles?).
> >
> > br,
> >
> > Jakub
> >
> >
> >  XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.