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

Re: xt parse

Subject: Re: xt parse
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: Wed, 23 Feb 2000 22:47:34 +0100
xt parser
Hi,

Basically, you need to create a XSLProcessor, load the stylesheet, set
the output method handler and destination and parse the XML file.

You can find examples in Driver.java (or XSLServlet.java).

I think the following statements should work...

Hope this helps

Eric

----------------------------------------
    XSLProcessor xsl = new XSLProcessorImpl();
    xsl.setParser(createParser());
    try {
      xsl.loadStylesheet(
	new InputSource("./public_html/xml/cc.xsl");
      OutputMethodHandlerImpl outputMethodHandler = new
OutputMethodHandlerImpl(xsl);
      xsl.setOutputMethodHandler(outputMethodHandler);
      outputMethodHandler.setDestination(new
FileDescriptorDestination(FileDescriptor.out));
      xsl.parse(fileInputSource("./public_html/xml/cc.xml"));
    }

// assuming you define the following functions :
 
  static Parser createParser() {
    String parserClass =
System.getProperty("com.jclark.xsl.sax.parser");
    if (parserClass == null)
      parserClass = System.getProperty("org.xml.sax.parser");
    if (parserClass == null)
      parserClass = "com.jclark.xml.sax.CommentDriver";
    try {
      return (Parser)Class.forName(parserClass).newInstance();
    }
    catch (ClassNotFoundException e) {
      System.err.println(e.toString());
    }
    catch (InstantiationException e) {
      System.err.println(e.toString());
    }
    catch (IllegalAccessException e) {
      System.err.println(e.toString());
    }
    catch (ClassCastException e) {
      System.err.println(parserClass + " is not a SAX driver");
    }
    return null;
  }

  static public InputSource fileInputSource(String str) {
    return fileInputSource(new File(str));
  }

  static public InputSource fileInputSource(File file) {
    String path = file.getAbsolutePath();
    String fSep = System.getProperty("file.separator");
    if (fSep != null && fSep.length() == 1)
      path = path.replace(fSep.charAt(0), '/');
    if (path.length() > 0 && path.charAt(0) != '/')
      path = '/' + path;
    try {
      return new InputSource(new URL("file", "", path).toString());
    }
    catch (java.net.MalformedURLException e) {
      /* According to the spec this could only happen if the file
	 protocol were not recognized. */
      throw new Error("unexpected MalformedURLException");
    }
  }

Paul Beer wrote:
> 
> could someone point me in the direction of api documentation for jclark's xt
> parser ?  how do i do the equivalent of this :
> 
> XSLTResultTarget outputXML = new XSLTResultTarget(out);
> XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
> processor.process(new XSLTInputSource("./public_html/xml/cc.xml"),new
> XSLTInputSource("./public_html/xml/cc.xsl"),outputXML);
> 
> w/ jclark's xt ?
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
------------------------------------------------------------------------
Eric van der Vlist                                              Dyomedea

http://www.dyomedea.com                          http://www.ducotede.com
------------------------------------------------------------------------


 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-2013 All Rights Reserved.