[Home]  [List]  [News]  [Docs]  [FAQ]  [Downloads]  [Resources]  [About]
Search :
/Home /List

list4xt : Mailing list for the XT users community.

[list4xt] Re: input/output xml string on xt

Subject: [list4xt] Re: input/output xml string on xt
From: Eric van der Vlist (vdv@dyomedea.com)
Date: 22/09/2000 - 09:05


Hi,

jvhew@asiatravelmart.com wrote:
>
> Hi all,
>
> I'm very appreciate if someone can help me on this.
>
> How do I pass xml string to XT Processor instead of xml file and
> output it in string format also?

Basically, you just need to use the
com.jclark.xsl.sax.DriverXSLProcessorImpl class with the right
parameters...

A way to do it is to take the com.jclark.xsl.sax.Driver class as a
starting point to create a new class which will do what you want...

The method where the selection of the input and output sources is taking
place is:

  static boolean transformFile(XSLProcessor xsl,
                               OutputMethodHandlerImpl outputMethodHandler,
                               File inputFile,
                               File stylesheetFile,
                               File outputFile) {
    Destination dest;
    if (outputFile == null)
      dest = new FileDescriptorDestination(FileDescriptor.out);
    else
      dest = new FileDestination(outputFile);
    outputMethodHandler.setDestination(dest);
    return transform(xsl,
                     fileInputSource(stylesheetFile),
                     fileInputSource(inputFile));
  }

(You might want to make a less "static" class out of this...).

To "switch" the input to a String, replace the third parameter
(fileInputSource(inputFile)) by a call to the (SAX) InputSource
constructor with a Reader or InputStream parameter (for instance : new
InputSource (new String Reader( myString) )).

To "switch" the output to a String, you have to pass a
com.jclark.xsl.sax.Destination object to the outputMethodHandler.

The available implementation of this interface (Destination) are
handling files or Servlet output and you'll probably have to create your
own StringDestination class (quite straightforward though).

> (I prefer to use SAX API for XT).

Do you mean instead of strings ?
If it's the case, you might want to have a look at Ux which is a SAX
streaming framework.

(http://www.pault.com/Ux/)
(/news/000703-0001.xml)

Hope this helps.

Eric

> Thank you.
>
> regards,
> jvhew
>
> --
> Mailing list for the XT users community. (http://necentennialmall.org)
> (mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://mfbbank.com
http://highriskmerchantcashadvance.com -           http://w3talk.com              http://420mac.com
------------------------------------------------------------------------

-- Mailing list for the XT users community. (http://firststatebanknd.com) (mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)



Archive générée par hypermail 2b28 le 06/11/2001 - 11:46 CET

webmaster@4xt.org


A site designed by Dyomedea