xsl-list
[Top] [All Lists]

Re: [xsl] Dynamic pipelining in XSLT 2.0 w/ Saxon extensions

2007-06-18 22:25:42
Hey Wendell :)

On Mon, 18 Jun 2007 15:19:54 -0600, Wendell Piez <wapiez(_at_)mulberrytech(_dot_)com> wrote:

* This runs (tested under the current Saxon 8.9), but how will it scale? In particular, Mike Kay may be able to say whether compiled stylesheets are be cached when this is run over a set of documents. If not, wouldn't compiling each stylesheet anew for each input document be an impediment?

I'll wait to hear from Dr. Kay on this matter before writing any more code, but in theory one could easily use an extension function to implement each chain of the pipeline, using a Hashtable to store compiled transformation file if it's the first time it's been accessed. For example (using Saxon on .NET/C# as the sample, those this easily translates to Java as well),

[(_at_)http://extf.googlecode.com/svn/trunk/Xameleon/Function/XsltCompiledHashtable.cs]
using System;
using Saxon.Api;
using System.Collections;

namespace Xameleon {

    public class XsltCompiledHashtable {

        private Processor processor = new Processor();
        private Hashtable results;

        public XsltCompiledHashtable() {
            this.results = new Hashtable();
        }
        public XsltCompiledHashtable(Hashtable table) {
            this.results = table;
        }

        public XsltTransformer GetTransformer(string href, Uri baseUri) {

            foreach (DictionaryEntry entry in results) {
                string uri = (string)entry.Key;
                if (uri == href) {
                    return (XsltTransformer)results[uri];
                }
            }

XsltTransformer transformer = processor.NewXsltCompiler().Compile(new Uri(href)).Load();
            results[href] = transformer;
            return transformer;
        }
    }
}

While the focus is different, I've continued to work on the server-side portion of the Atomictalk project over the last few weeks, developing an XML sequence syntax to perform various operations based on user input passed to a URI endpoint. (e.g. [1,3,5] represent the operation sequence that outputs the result of [2,4,6]) I've been thinking about this same issue as of late, wondering how I might best go about loading transformation files dynamically from the PI of a given input file, so If it turns out this is a good and proper approach to solving this particular issue, I will extend this code to be utilized via an extension function for purpose of testing.

[1] http://personplacething-info.googlecode.com/svn/trunk/public_web/service/proxy/service.op [2] http://personplacething.info/service/proxy/?debug=true&return-xml-from-uri=http://www.w3.org/People/Berners-Lee/card&return-doc-id=i

[3] http://personplacething-info.googlecode.com/svn/trunk/public_web/service/semweb/service.op [4] http://personplacething.info/service/semweb/?debug=true&foaf-uri=http://www.w3.org/People/Berners-Lee/card

[5] http://personplacething-info.googlecode.com/svn/trunk/public_web/service/redirect/service.op [6] http://personplacething.info/service/redirect/?redirect=http://s3.amazonaws.com/m.david/test-index.xml&status-code=303

--
/M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354 | http://dev.aol.com/blog/3155

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--