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

Re: Saxon-CE -- Passing Data to a JS Function

Subject: Re: Saxon-CE -- Passing Data to a JS Function
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 Jul 2016 13:48:15 -0000
Re:  Saxon-CE -- Passing Data to a JS Function
Glad it's going well. We've been working hard on a successor product,
Saxon-JS, which hopefully will retain all the good things in Saxon-CE and fix
some of the problems.

> On 20 Jul 2016, at 13:56, Chris Despopoulos despopoulos_chriss@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I wanted to provide an update on my experience with Saxon-CE.  The bottom
line is, I'm getting transforms as strings out of the processor -- it looks
like I can use it to integrate DITA content into a product GUI.  This is truly
awesome -- Many thanks to Dr. Kay.
> I get a new processor with an XSLT file set to it, and then call
> var result = proc.transformToDocument(myXml).
> The XSLT starts like so:
> <xsl:template match="topic">
>     <xsl:copy>
>         <xsl:apply-templates/>
>     </xsl:copy>
> </xsl:template>
> and then calls whatever other templates I need.  The COPY passes the result
out through the processor.
> Chances are, people who know XSLT better than I would say I'm doing this in
a bone-headed way. It works -- I definitely need a string result, either as
JSON, or I need HTML that I can then process further...  Say execute an API
call to stitch real-time data into the content.  So this is something that
works for what I need.

transformToDocument() returns an XML document node containing the result of
the transformation. The most trivial example of an XML document is where
there's a document node owning a single text node, which for most practical
purposes you can treat as string output.
> I need to learn more about caching and life cycle for the processor.  I'm
wondering if I should create a singleton for the processor and then set
properties as needed for each invocation.

The Xslt20Processor holds the compiled stylesheet, so you can reuse it to run
multiple transformations provided they use the same stylesheet. However, it
also holds per-transformation state, so you shouldn't start a new
transformation while another one is still active. Normally our approach has
been to fire off new tasks in response to user events from within the
stylesheet itself, and that works fine.

> Also, I wonder if the browser caches XSLT files that I get via
Saxon.requestXML.  If not, I need to do my own caching.  Anyway, I still have
homework to do, but Saxon-CE is looking very nice!

Yes, I'm no expert on the internals of browsers but I think it's safe to
assume that the browser will cache such resources whenever it can. Even when
you would prefer it not to...

Michael Kay

Current Thread


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.
First Name
Last Name
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.