Project

Profile

Help

s9API - Caching

Added by Anonymous about 16 years ago

Legacy ID: #4825514 Legacy Poster: Jocelyn Raymond (jraymond67)

Hi, We are using saxon9 SA (purchased) and would like to ask some advise. We have an application where each user have one small XML Data structure. Each of those XML Data "model" is the same for every users but containing different data, off course. We maintain several small lookup xml documents as well which only few of those lookups are needed per user but different users may need different lookup set depending on their internal data. We don't want to create new "Tree" each time but rather would like to Cache those small XML Trees (TinyTree) and only one copy for everyone (done in Java; thus static structure). Those lookups are read-only i.e. no user need to change it, thus should be Thread safe. I am planing to use XSLT/XQuery API from "snappy" (s9API). So using s9API, should we keep into, say a HashMap, a reference to a XdmNode or NodeInfo for those small XML Lookup documents? If I want to Cache the XSLT as well, we should keep a reference of XsltExecutable (step 3 from your docs) into the static Cached structure; right? Similarly, we should cache an xquery by keeping a static reference of XQueryExecutable; right? In order to transform the xml data document, can we pass a List (Java) of XdmNode? NodeInfo? of our lookups to the tranformer (xslt)? (so the xslt param will see this as a sequence of "trees/nodes"). I guess my confusion is coming from what are the differences between XdmNode and NodeInfo (if any). Thanks, Jocelyn Raymond


Replies (2)

RE: s9API - Caching - Added by Anonymous about 16 years ago

Legacy ID: #4825908 Legacy Poster: Michael Kay (mhkay)

>So using s9API, should we keep into, say a HashMap, a reference to a XdmNode or NodeInfo for those small XML Lookup documents? On the whole, I would reference the XdmNode rather than the NodeInfo - though either is viable. The XdmNode is a very thin wrapper around the NodeInfo. I thought quite hard about making NodeInfo a "first class object" within s9api but decided against mainly so that I could get the class hierarchy right: an XdmNode is an XdmItem and also an XdmValue, so it can be used in all interfaces where an XdmItem or XdmValue is required; and you can always get the underlying NodeInfo if you need it. >If I want to Cache the XSLT as well, we should keep a reference of XsltExecutable (step 3 from your docs) into the static Cached structure; right? Similarly, we should cache an xquery by keeping a static reference of XQueryExecutable; right? Yes, and yes. >In order to transform the xml data document, can we pass a List (Java) of XdmNode? NodeInfo? of our lookups to the tranformer (xslt)? (so the xslt param will see this as a sequence of "trees/nodes"). The value passed to XsltTransformer.setParameter() must be an XdmValue. Unfortunately the first release of s9api provides rather limited facilities for constructing an XdmValue (to put it mildly): the only real way of doing it is to evaluate an XPath expression. This omission has already been pointed out, and the next Saxon release will have a constructor allowing you to construct an XdmValue from a list of XdmItems (for example, a list of XdmNodes). I was going to suggest that you work around this by using lower-level interfaces - getting the Controller object that underpins the XsltTransformer and calling its setParameter() method instead; unfortunately while most s9api object provide an escape hatch allowing you to get access to the underlying implementation objects, the XsltTransformer seems to be an exception. I don't normally like adding new functionality in a patch or maintenance release but this problem does seem sufficiently awkward that I think I'll make an exception. I'm hoping to produce a 9.0.0.4 release during the next week. Michael Kay Saxonica

RE: s9API - Caching - Added by Anonymous about 16 years ago

Legacy ID: #4827308 Legacy Poster: Jocelyn Raymond (jraymond67)

Thank you. I will try to create a XdmValue object by evaluating an XPath expression and see if I can make it work. Otherwise, I may simply use the older way where I can pass several NodeInfo's via a List object (through the Controller object). I will keep an eye on any new release of Saxon. Thanks again for your help, Jocelyn Raymond

    (1-2/2)

    Please register to reply