You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Evgeniy Strokin <ev...@yahoo.com> on 2002/08/09 17:42:38 UTC

Is some way read XML not from file but from String for DOMImpl?

I'm running translet.
In example, I've found, what I can parse XML from
File:

    final DOMImpl dom = new DOMImpl();
    dom.setDocumentURI(xmldocname);

But I have XML in String.
How can I put String for parsing instead of file name?

Thanks,
Jenya

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

Re: speed up transform?

Posted by Kim <ki...@yahoo.com>.
Guy,

Try to upgrade JRE to 1.3.1_04 to see if it would help to speed up.  My
experience was with the same xsl and everything else identical, it takes twice
to run on the Sun Solaris vs Win NT 4.0!  Still have not figured out which
factors (IO process, traffic on the server, etc.) on the Sun Solaris makes this
vast difference!




--- Guy McArthur <gu...@guymcarthur.com> wrote:
> I've got a certain set of data, the largest blocks of which are grids of
> about a quarter million points. If xslt can process the sax stream from
> one grid within about 30 seconds it will be suitable to use in this
> particular application. I've written a subclass of InputSource that parses
> it and sends out a stream of sax events. Which looks like this:
> 
> <points>
>  <p>1.234778</p>
>  <p>3.141159</p>
>  .
>  .
>  .
>  about a quarter million of 'em
> </points>
> 
> 
> The identity transform [Transformer t=tfactory.newTransformer()] takes 12 
> seconds to complete. Which gives me hope. However, the simple stylesheet I 
> wrote takes ten times as long! I've tried with and without creating a 
> Templates instance -- Templates definitely helps but not enough.
> 
> The stylesheet will have modes for CSV output, html, and so on. I'm 
> testing with CSV:
> 
>   <xsl:output method="text"/>
> 
>   <xsl:template match="p">
>     <xsl:value-of select="."/><xsl:text>
> </xsl:text>
>   </xsl:template>
> 
> 
> In both cases (identity and the above xslt) I have set the "incremental 
> processing" boolean flag.
> 
> Is there a way I can restructure the stylesheet and/or sax output to 
> lessen the transform time? Or am I basically asking for too much?
> 
> [Originally the xml and template was much more complicated, paring it down 
> to this simple linear stream of "p" elements only made a slight 
> improvement].
> 
> I'm using xalan-j_2_4_D1 and sun solaris jre 1.3.0.
> 
> --
> Guy McArthur * email{guym@guymcarthur.com}
> 


=====
Kim

*************************
May the force be with you.
*************************

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

Re: speed up transform?

Posted by Guy McArthur <gu...@guymcarthur.com>.
Would 'explicitly invoking SAX' as described in the usage patterns make a 
difference?

On Fri, 9 Aug 2002, Guy McArthur wrote:

> Date: Fri, 9 Aug 2002 09:49:35 -0700 (MST)
> From: Guy McArthur <gu...@guymcarthur.com>
> To: xalan-j-users@xml.apache.org
> Subject: speed up transform?
> 
> I've got a certain set of data, the largest blocks of which are grids of
> about a quarter million points. If xslt can process the sax stream from
> one grid within about 30 seconds it will be suitable to use in this
> particular application. I've written a subclass of InputSource that parses
> it and sends out a stream of sax events. Which looks like this:
> 
> <points>
>  <p>1.234778</p>
>  <p>3.141159</p>
>  .
>  .
>  .
>  about a quarter million of 'em
> </points>
> 
> 
> The identity transform [Transformer t=tfactory.newTransformer()] takes 12 
> seconds to complete. Which gives me hope. However, the simple stylesheet I 
> wrote takes ten times as long! I've tried with and without creating a 
> Templates instance -- Templates definitely helps but not enough.
> 
> The stylesheet will have modes for CSV output, html, and so on. I'm 
> testing with CSV:
> 
>   <xsl:output method="text"/>
> 
>   <xsl:template match="p">
>     <xsl:value-of select="."/><xsl:text>
> </xsl:text>
>   </xsl:template>
> 
> 
> In both cases (identity and the above xslt) I have set the "incremental 
> processing" boolean flag.
> 
> Is there a way I can restructure the stylesheet and/or sax output to 
> lessen the transform time? Or am I basically asking for too much?
> 
> [Originally the xml and template was much more complicated, paring it down 
> to this simple linear stream of "p" elements only made a slight 
> improvement].
> 
> I'm using xalan-j_2_4_D1 and sun solaris jre 1.3.0.
> 
> --
> Guy McArthur * email{guym@guymcarthur.com}
> 

-- 
--
Guy McArthur * email{guym@guymcarthur.com} cell{520-869-7317}


speed up transform?

Posted by Guy McArthur <gu...@guymcarthur.com>.
I've got a certain set of data, the largest blocks of which are grids of
about a quarter million points. If xslt can process the sax stream from
one grid within about 30 seconds it will be suitable to use in this
particular application. I've written a subclass of InputSource that parses
it and sends out a stream of sax events. Which looks like this:

<points>
 <p>1.234778</p>
 <p>3.141159</p>
 .
 .
 .
 about a quarter million of 'em
</points>


The identity transform [Transformer t=tfactory.newTransformer()] takes 12 
seconds to complete. Which gives me hope. However, the simple stylesheet I 
wrote takes ten times as long! I've tried with and without creating a 
Templates instance -- Templates definitely helps but not enough.

The stylesheet will have modes for CSV output, html, and so on. I'm 
testing with CSV:

  <xsl:output method="text"/>

  <xsl:template match="p">
    <xsl:value-of select="."/><xsl:text>
</xsl:text>
  </xsl:template>


In both cases (identity and the above xslt) I have set the "incremental 
processing" boolean flag.

Is there a way I can restructure the stylesheet and/or sax output to 
lessen the transform time? Or am I basically asking for too much?

[Originally the xml and template was much more complicated, paring it down 
to this simple linear stream of "p" elements only made a slight 
improvement].

I'm using xalan-j_2_4_D1 and sun solaris jre 1.3.0.

--
Guy McArthur * email{guym@guymcarthur.com}


Re: Is some way read XML not from file but from String for DOMImpl?

Posted by Santiago Pericas-Geertsen <Sa...@sun.com>.
Evgeniy:

 It would be a lot easier if you were using the JAXP API instead of the Native API. However, if you still want to use the native API you need to use a SAXParser in both cases: string or file (calling setDocumentURI() is not enough). 

 You should write something like this for the string case:

     // Create a SAX parser 
     final SAXParserFactory factory = SAXParserFactory.newInstance();
     try {
          factory.setFeature(Constants.NAMESPACE_FEATURE,true);
     }
     catch (Exception e) {
          factory.setNamespaceAware(true);
     }
     final SAXParser parser = factory.newSAXParser();
     final XMLReader reader = parser.getXMLReader();

     // Set the DOM's builder as the XMLReader's SAX2 content handler
     final DOMImpl dom = new DOMImpl();
     reader.setContentHandler(dom.getBuilder());

     reader.parse(new InputSource(new StringReader(YOURSTRING)));

-- 
Santiago Pericas-Geertsen
Sun Microsystems

----- Original Message ----- 
From: "Evgeniy Strokin" <ev...@yahoo.com>
To: "Xalan-J Users" <xa...@xml.apache.org>
Sent: Friday, August 09, 2002 11:42 AM
Subject: Is some way read XML not from file but from String for DOMImpl?


> I'm running translet.
> In example, I've found, what I can parse XML from
> File:
> 
>     final DOMImpl dom = new DOMImpl();
>     dom.setDocumentURI(xmldocname);
> 
> But I have XML in String.
> How can I put String for parsing instead of file name?
> 
> Thanks,
> Jenya
>