Hi all,
Looking through all Saxon-CE examples online, i can't find a basic example of a pipeline: 1. load xml, transform with xsl sheet 2. load second xsl sheet, transform result of first transformation Can anyone post a link or some code that shows how to do this? It would be a good addition to the online documentation. Best regards, - Myles Institute Molecular Medicine Finland ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
Hy Myles,
Here is one I wrote, but it is my first. It runs a XML file through a series of stems, splits it into alphabetical segments, and outputs HTML. I have asked on the XProc list why the HTML is bad (XProc turns it out without the DOCTYPE statement included in the xsl:output element). but you are welcome to review it. I execute it using an Oxygen scenario. Regards, Mark <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="catalogs" version="1.0"> <p:input port="source"> <p:document href="../data/index.xml"/> </p:input> <p:output port="result" sequence="true"> <p:empty/> </p:output> <p:xslt name="select-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/10CatalogSelect.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="sort-catalogs"> <p:input port="source"> <p:pipe port="result" step="select-catalogs"/> </p:input> <p:input port="stylesheet"> <p:document href="../xslt/11CatalogsSort.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="dedupe-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/12CatalogDedupe.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="xml-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/13CatalogsByName.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:sink> <p:input port="source"/> </p:sink> <p:for-each name="xml-generator"> <p:iteration-source> <p:pipe port="secondary" step="xml-catalogs"/> </p:iteration-source> <p:xslt name="htm-generator"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/14CatalogsToXHTML.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:store> <p:with-option name="href" select="concat('work/htm', substring-before(substring-after(base-uri(*), 'work'), '.'), '.htm')"/> </p:store> </p:for-each> </p:declare-step> On 18/02/2013 00:56, [hidden email] wrote: > Hi all, > > Looking through all Saxon-CE examples online, i can't find a basic > example of a pipeline: > > 1. load xml, transform with xsl sheet > 2. load second xsl sheet, transform result of first transformation > > Can anyone post a link or some code that shows how to do this? It > would be a good addition to the online documentation. > > Best regards, > - Myles > Institute Molecular Medicine Finland > > > ------------------------------------------------------------------------------ > The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, > is your hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials, tech docs, > whitepapers, evaluation guides, and opinion stories. Check out the most > recent posts - join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > -- Mark Wilson Knihtisk Publishing ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
In reply to this post by mbyrne-2
Thank you very much for the reply and the XPROC, Mark. Very helpful as an example of pipelining .. i've set up XSL pipelines using Cocoon, and see that i can do the same using your code and e.g. Calabash. However, what i'm after is an even simple and easy XSL pipeline, using only Saxon-CE, JS, and HTML5. Saxon-CE seems to hold out this promise, yet i can find no examples of this. It should be simple to chain Saxon.run calls into such a pipeline. Does anyone have an example of that? Best regards, - Myles Institute Molecular Medicine Finland (FIMM.fi) Message: 7 Date: Mon, 18 Feb 2013 06:03:14 -0700 From: Mark Wilson <[hidden email]> Subject: Re: [saxon] Saxon-CE pipeline examples To: Mailing list for the SAXON XSLT and XQuery processor <[hidden email]> Message-ID: <[hidden email]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hy Myles, Here is one I wrote, but it is my first. It runs a XML file through a series of stems, splits it into alphabetical segments, and outputs HTML. I have asked on the XProc list why the HTML is bad (XProc turns it out without the DOCTYPE statement included in the xsl:output element). but you are welcome to review it. I execute it using an Oxygen scenario. Regards, Mark <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="catalogs" version="1.0"> <p:input port="source"> <p:document href="../data/index.xml"/> </p:input> <p:output port="result" sequence="true"> <p:empty/> </p:output> <p:xslt name="select-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/10CatalogSelect.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="sort-catalogs"> <p:input port="source"> <p:pipe port="result" step="select-catalogs"/> </p:input> <p:input port="stylesheet"> <p:document href="../xslt/11CatalogsSort.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="dedupe-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/12CatalogDedupe.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="xml-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/13CatalogsByName.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:sink> <p:input port="source"/> </p:sink> <p:for-each name="xml-generator"> <p:iteration-source> <p:pipe port="secondary" step="xml-catalogs"/> </p:iteration-source> <p:xslt name="htm-generator"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/14CatalogsToXHTML.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:store> <p:with-option name="href" select="concat('work/htm', substring-before(substring-after(base-uri(*), 'work'), '.'), '.htm')"/> </p:store> </p:for-each> </p:declare-step> On 18/02/2013 00:56, [hidden email] wrote: > Hi all, > > Looking through all Saxon-CE examples online, i can't find a basic > example of a pipeline: > > 1. load xml, transform with xsl sheet > 2. load second xsl sheet, transform result of first transformation > > Can anyone post a link or some code that shows how to do this? It > would be a good addition to the online documentation. > > Best regards, > - Myles > Institute Molecular Medicine Finland > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
In reply to this post by mbyrne-2
(Resending this message due to mangling of previous version by webmail.) Thank you very much for the reply and the XPROC, Mark. Very helpful as an example of pipelining .. i've set up XSL pipelines using Cocoon, and see that i can do the same using your code and e.g. Calabash. However, what i'm after is an even simpler and easier XSL pipeline, using only Saxon-CE, JS, and HTML5. Saxon-CE seems to hold out this promise, yet i can find no examples of this. It should be simple to chain Saxon.run calls into such a pipeline. Does anyone have an example of that? Best regards, - Myles Institute Molecular Medicine Finland (FIMM.fi) Message: 7 Date: Mon, 18 Feb 2013 06:03:14 -0700 From: Mark Wilson <[hidden email]> Subject: Re: [saxon] Saxon-CE pipeline examples To: Mailing list for the SAXON XSLT and XQuery processor <[hidden email]> Message-ID: <[hidden email]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hy Myles, Here is one I wrote, but it is my first. It runs a XML file through a series of stems, splits it into alphabetical segments, and outputs HTML. I have asked on the XProc list why the HTML is bad (XProc turns it out without the DOCTYPE statement included in the xsl:output element). but you are welcome to review it. I execute it using an Oxygen scenario. Regards, Mark <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="catalogs" version="1.0"> <p:input port="source"> <p:document href="../data/index.xml"/> </p:input> <p:output port="result" sequence="true"> <p:empty/> </p:output> <p:xslt name="select-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/10CatalogSelect.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="sort-catalogs"> <p:input port="source"> <p:pipe port="result" step="select-catalogs"/> </p:input> <p:input port="stylesheet"> <p:document href="../xslt/11CatalogsSort.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="dedupe-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/12CatalogDedupe.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:xslt name="xml-catalogs"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/13CatalogsByName.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:sink> <p:input port="source"/> </p:sink> <p:for-each name="xml-generator"> <p:iteration-source> <p:pipe port="secondary" step="xml-catalogs"/> </p:iteration-source> <p:xslt name="htm-generator"> <p:input port="source"/> <p:input port="stylesheet"> <p:document href="../xslt/14CatalogsToXHTML.xsl"/> </p:input> <p:input port="parameters"> <p:empty/> </p:input> </p:xslt> <p:store> <p:with-option name="href" select="concat('work/htm', substring-before(substring-after(base-uri(*), 'work'), '.'), '.htm')"/> </p:store> </p:for-each> </p:declare-step> On 18/02/2013 00:56, [hidden email] wrote: > Hi all, > > Looking through all Saxon-CE examples online, i can't find a basic > example of a pipeline: > > 1. load xml, transform with xsl sheet > 2. load second xsl sheet, transform result of first transformation > > Can anyone post a link or some code that shows how to do this? It > would be a good addition to the online documentation. > > Best regards, > - Myles > Institute Molecular Medicine Finland > -- Myles Byrne IT Specialist The Institute for Molecular Medicine Finland http://www.fimm.fi +358 (0)50 415 6799 [hidden email] ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
In reply to this post by mbyrne-2
Sorry, I can't lay my hands on an example. You'll need to use the Javascript API, which is closely modelled on the Sarissa API widely used with XSLT 1.0 processors in the browser. The documentation is here: http://www.saxonica.com/ce/doc/api/intro.xml Basically, you parse the stylesheet into a document object; call Saxon.newXslt20Transformer() to compile the stylesheet to an Xslt20Transformer; then call Xslt20Transformer.transformToDocument() to transform a source document; the result returned is a Document object which can then be used as input to the next step in the pipeline. Michael Kay Saxonica On 18/02/2013 07:56, [hidden email] wrote: > Hi all, > > Looking through all Saxon-CE examples online, i can't find a basic > example of a pipeline: > > 1. load xml, transform with xsl sheet > 2. load second xsl sheet, transform result of first transformation > > Can anyone post a link or some code that shows how to do this? It > would be a good addition to the online documentation. > > Best regards, > - Myles > Institute Molecular Medicine Finland > > > ------------------------------------------------------------------------------ > The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, > is your hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials, tech docs, > whitepapers, evaluation guides, and opinion stories. Check out the most > recent posts - join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help > ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
An example in the wild is the Unicode presentation that I gave at
Stuttgart XML User Group: http://publishinggeekly.com/wp-content/uploads/2012/07/dr_strangechar.html#/ipa_regex It’s an XPath 2 evaluation form. I don’t remember exactly how I did it, but I remember that it wasn’t trivial. Forensic investigation shows that it must have been along the lines of: Include the following script/stylesheet: <script type="text/javascript" language="javascript" src="generate.js"></script> <script type="application/xslt+xml" language="xslt2.0" src="xslt/evaluation.xsl" data-source="xslt/evaluation.xsl"></script> The latter, http://publishinggeekly.com/wp-content/uploads/2012/07/xslt/evaluation.xsl, contains a template that matches the button’s click event. It then recreates the div where the textarea and the button are in. It fills it with copies of the textarea and the button, plus the result of evaluating the XPath expression against the HTML document (try this by evaluating, for example, /*/name() ⇒ HTML). In order to be able to evaluate the XPath expression, you have to generate an XSLT stylesheet first (evaluating an XPath expression against a document could/should probably be made available as another API function, but it hasn’t yet). This is done by passing the XPath expression to the JS function gerrit.generate_xpath_2_evaluator(), defined in http://publishinggeekly.com/wp-content/uploads/2012/07/generate.js This stylesheet-generating JS is called from the original stylesheet by means of the XPath extension function ixsl:eval(). gerrit.generate_xpath_2_evaluator() takes the XPath as a string argument and passes it to another XSLT stylesheet (http://publishinggeekly.com/wp-content/uploads/2012/07/xslt/xpath-2-evaluator.xsl) whose main template generates an XSLT stylesheet that, once applied to the HTML document, creates an HTML div. This div’s content is just <xsl:sequence select="EXPRESSION"/> This generated stylesheet is then passed as the second argument to gerrit.apply_template_for_page_inclusion (also defined in http://publishinggeekly.com/wp-content/uploads/2012/07/generate.js, using the Saxon.run API function). The first argument is the HTML file, to which the stylesheet is applied, and there you go. I think this should give you a practical example to build your own pipelined evaluation upon. And I hope that I didn’t make it unnecessarily complicated. Most of the folks in Stuttgart probably didn’t appreciate or imagine the enormous apparatus that was erected behind the scenes in order to make an XPath2 form available in an HTML presentation. [Advertisement: The next Stuttgart XML User Group meeting will take place on Feb. 27 although it apparently hasn’t been announced yet on http://xugs.de/. I think Andreas Kämmerle of pagina GmbH will discuss EPUB3 and KF8.] Gerrit On 18.02.2013 22:29, Michael Kay wrote: > > Sorry, I can't lay my hands on an example. You'll need to use the > Javascript API, which is closely modelled on the Sarissa API widely used > with XSLT 1.0 processors in the browser. The documentation is here: > > http://www.saxonica.com/ce/doc/api/intro.xml > > Basically, you parse the stylesheet into a document object; call > Saxon.newXslt20Transformer() to compile the stylesheet to an > Xslt20Transformer; then call Xslt20Transformer.transformToDocument() to > transform a source document; the result returned is a Document object > which can then be used as input to the next step in the pipeline. > > Michael Kay > Saxonica > > > On 18/02/2013 07:56, [hidden email] wrote: >> Hi all, >> >> Looking through all Saxon-CE examples online, i can't find a basic >> example of a pipeline: >> >> 1. load xml, transform with xsl sheet >> 2. load second xsl sheet, transform result of first transformation >> >> Can anyone post a link or some code that shows how to do this? It >> would be a good addition to the online documentation. >> >> Best regards, >> - Myles >> Institute Molecular Medicine Finland >> >> >> ------------------------------------------------------------------------------ >> The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, >> is your hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials, tech docs, >> whitepapers, evaluation guides, and opinion stories. Check out the most >> recent posts - join the conversation now. http://goparallel.sourceforge.net/ >> _______________________________________________ >> saxon-help mailing list archived at http://saxon.markmail.org/ >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/saxon-help >> > > > ------------------------------------------------------------------------------ > The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, > is your hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials, tech docs, > whitepapers, evaluation guides, and opinion stories. Check out the most > recent posts - join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help > -- Gerrit Imsieke Geschäftsführer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 [hidden email], http://www.le-tex.de Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschäftsführer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vöckler ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
On 19/02/2013 00:06, Imsieke, Gerrit, le-tex wrote: > An example in the wild is the Unicode presentation that I gave at > Stuttgart XML User Group: > http://publishinggeekly.com/wp-content/uploads/2012/07/dr_strangechar.html#/ipa_regex > > It’s an XPath 2 evaluation form. > > I don’t remember exactly how I did it, but I remember that it wasn’t > trivial. It's possible this was before we added the Javascript API (and may have been one of the examples that motivated us to do it). We still don't have an API for doing XPath 2.0 directly from Javascript, although that's clearly a requirement and an opportunity. Michael Kay Saxonica ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
On 19.02.2013 09:43, Michael Kay wrote: > > On 19/02/2013 00:06, Imsieke, Gerrit, le-tex wrote: >> An example in the wild is the Unicode presentation that I gave at >> Stuttgart XML User Group: >> http://publishinggeekly.com/wp-content/uploads/2012/07/dr_strangechar.html#/ipa_regex >> >> It’s an XPath 2 evaluation form. >> >> I don’t remember exactly how I did it, but I remember that it wasn’t >> trivial. > It's possible this was before we added the Javascript API (and may have > been one of the examples that motivated us to do it). I used the API*, but I found it to be non-trivial nonetheless. Now that I revisited the files and understood what I did, I think it’s quite straightforward. But if you look at the comments in http://publishinggeekly.com/wp-content/uploads/2012/07/xslt/xpath-2-evaluator.xsl, it becomes evident that I hard a hard time figuring it out. For example, I discovered (but didn’t report until now) that I couldn’t define functions (in some namespace) in a generated stylesheet because the namespace declarations in the generated stylesheet seem to get discarded. Gerrit * For example, Saxon.run({ stylesheet: stylesheet, source: document, method: "transformToDocument" }).getResultDocument(); ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
On 19/02/2013 09:48, Imsieke, Gerrit, le-tex wrote: > > On 19.02.2013 09:43, Michael Kay wrote: >> On 19/02/2013 00:06, Imsieke, Gerrit, le-tex wrote: >>> An example in the wild is the Unicode presentation that I gave at >>> Stuttgart XML User Group: >>> http://publishinggeekly.com/wp-content/uploads/2012/07/dr_strangechar.html#/ipa_regex >>> >>> It’s an XPath 2 evaluation form. >>> >>> I don’t remember exactly how I did it, but I remember that it wasn’t >>> trivial. >> It's possible this was before we added the Javascript API (and may have >> been one of the examples that motivated us to do it). > I used the API*, but I found it to be non-trivial nonetheless. Now that > I revisited the files and understood what I did, I think it’s quite > straightforward. > > But if you look at the comments in > http://publishinggeekly.com/wp-content/uploads/2012/07/xslt/xpath-2-evaluator.xsl, > it becomes evident that I hard a hard time figuring it out. For example, > I discovered (but didn’t report until now) that I couldn’t define > functions (in some namespace) in a generated stylesheet because the > namespace declarations in the generated stylesheet seem to get discarded. our tests are writing to the HTML DOM, rather than returning an XML DOM. Michael Kay Saxonica > > Gerrit > > * For example, > Saxon.run({ > stylesheet: stylesheet, > source: document, > method: "transformToDocument" > }).getResultDocument(); > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
In reply to this post by mbyrne-2
Here's a simple HTML file with JavaScript that runs an XSLT
transformation pipeline with 3 style sheets, stage1.xsl, stage2.xsl and stage 3.xsl: <!DOCTYPE html> <html> <head> <title>cepipe</title> <script type="text/javascript" language="javascript" src="../Saxonce/Saxonce.nocache.js"></script> <script type="text/javascript" language="javascript"> onSaxonLoad = function() { var proc1 = Saxon.newXSLT20Processor(Saxon.requestXML("stage1.xsl")); var proc2 = Saxon.newXSLT20Processor(Saxon.requestXML("stage2.xsl")); proc1.transformToDocument(Saxon.requestXML("input.xml")); var rd1URI = proc1.getResultDocuments()[0]; var rd1Doc = proc1.getResultDocument(rd1URI); proc2.transformToDocument(rd1Doc); var rd2URI = proc2.getResultDocuments()[0]; var rd2Doc = proc2.getResultDocument(rd2URI); var proc3 = Saxon.run( { stylesheet: "stage3.xsl", source: rd2Doc } ); } </script> </head> <body> <h1>Saxon-CE sample</h1> <p>Pipelines</p> <div id="main"></div> </body> </html> Note that for the output from stage1 and stage2 I've exploited a single xsl:result-document output rather than the principal output. The output from the stage3 transform is directed to the HTML DOM. API Issue: The result of transformToDocument() should be the principal output document. Also, getResultDocument("") called on an XSLT20Processor instance should return the principal output (for use with asynchronous calls). However, there's currently an API bug (first reported at: https://saxonica.plan.io/issues/1511 - but not resolved as stated) that means that the 1st result-document is returned instead in both cases. ---------- Phil Fearon On Mon, Feb 18, 2013 at 1:28 PM, <[hidden email]> wrote: > > Thank you very much for the reply and the XPROC, Mark. Very helpful as > an example of pipelining .. i've set up XSL pipelines using Cocoon, > and see that i can do the same using your code and e.g. Calabash. > > However, what i'm after is an even simple and easy XSL pipeline, using > only Saxon-CE, JS, and HTML5. Saxon-CE seems to hold out this promise, > yet i can find no examples of this. > > It should be simple to chain Saxon.run calls into such a pipeline. > Does anyone have an example of that? > > Best regards, > - Myles > Institute Molecular Medicine Finland (FIMM.fi) > > > Message: 7 > Date: Mon, 18 Feb 2013 06:03:14 -0700 > From: Mark Wilson <[hidden email]> > Subject: Re: [saxon] Saxon-CE pipeline examples > To: Mailing list for the SAXON XSLT and XQuery processor > <[hidden email]> > Message-ID: <[hidden email]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hy Myles, > Here is one I wrote, but it is my first. It runs a XML file through a > series of stems, splits it into alphabetical segments, and outputs HTML. > I have asked on the XProc list why the HTML is bad (XProc turns it out > without the DOCTYPE statement included in the xsl:output element). but > you are welcome to review it. I execute it using an Oxygen scenario. > Regards, > Mark > > <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="catalogs" > version="1.0"> > > <p:input port="source"> > <p:document href="../data/index.xml"/> > </p:input> > <p:output port="result" sequence="true"> > <p:empty/> > </p:output> > > <p:xslt name="select-catalogs"> > <p:input port="source"/> > <p:input port="stylesheet"> > <p:document href="../xslt/10CatalogSelect.xsl"/> > </p:input> > <p:input port="parameters"> > <p:empty/> > </p:input> > </p:xslt> > > <p:xslt name="sort-catalogs"> > <p:input port="source"> > <p:pipe port="result" step="select-catalogs"/> > </p:input> > > <p:input port="stylesheet"> > <p:document href="../xslt/11CatalogsSort.xsl"/> > </p:input> > <p:input port="parameters"> > <p:empty/> > </p:input> > </p:xslt> > > > <p:xslt name="dedupe-catalogs"> > <p:input port="source"/> > <p:input port="stylesheet"> > <p:document href="../xslt/12CatalogDedupe.xsl"/> > </p:input> > <p:input port="parameters"> > <p:empty/> > </p:input> > </p:xslt> > > <p:xslt name="xml-catalogs"> > <p:input port="source"/> > <p:input port="stylesheet"> > <p:document href="../xslt/13CatalogsByName.xsl"/> > </p:input> > <p:input port="parameters"> > <p:empty/> > </p:input> > </p:xslt> > > <p:sink> > <p:input port="source"/> > </p:sink> > > <p:for-each name="xml-generator"> > <p:iteration-source> > <p:pipe port="secondary" step="xml-catalogs"/> > </p:iteration-source> > <p:xslt name="htm-generator"> > <p:input port="source"/> > <p:input port="stylesheet"> > <p:document href="../xslt/14CatalogsToXHTML.xsl"/> > </p:input> > <p:input port="parameters"> > <p:empty/> > </p:input> > </p:xslt> > <p:store> > <p:with-option name="href" select="concat('work/htm', > substring-before(substring-after(base-uri(*), 'work'), '.'), '.htm')"/> > </p:store> > </p:for-each> > > </p:declare-step> > > On 18/02/2013 00:56, [hidden email] wrote: >> Hi all, >> >> Looking through all Saxon-CE examples online, i can't find a basic >> example of a pipeline: >> >> 1. load xml, transform with xsl sheet >> 2. load second xsl sheet, transform result of first transformation >> >> Can anyone post a link or some code that shows how to do this? It >> would be a good addition to the online documentation. >> >> Best regards, >> - Myles >> Institute Molecular Medicine Finland >> > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
This post was updated on .
Seems I can't get this example working.
I am using Saxon CE 1.1. and noted that the API bug https://saxonica.plan.io/issues/1511 has now been resolved in Saxon CE 1.1. So, should now work right? Or is there another way to do pipelines in Saxon CE 1.1? --- Linc Update: Got it working. In the confusion I neglected set up the stage1.xsl, stage2.xsl and stage3.xsl for Saxon CE. For other newbies, your xslt files should look something like this: <xsl:transform xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT" xmlns:prop="http://saxonica.com/ns/html-property" xmlns:style="http://saxonica.com/ns/html-style-property" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs prop" extension-element-prefixes="ixsl" version="2.0" > <xsl:template name="main" match="/"> <xsl:result-document href="#main" method="append-content"> ...Some html... </xsl:result-document> </xsl:template> </xsl:transform> FANTASTIC! I now have XSLT Pipelines - Long live Saxon CE. No need for complex Cocoon anymore (I think). |
Hi Lincoln,
May I try and help you on this one. I am new to this thread topic so I had to catch on the details. In any case I managed to run the pipeline example outlined by Phil Fearon eithout any problems. Just to state the obvious things. Have you created the required stylesheets: stage1.xsl, stage2.xsl and stage3.xsl? Please may you give some more information on the problem(s) or error message(s) reported? kind regards, O'Neil On 24/05/2013 08:39, Lincoln wrote: > Seems I can't get this example working. > I am using Saxon CE 1.1. and noted that the API bug > https://saxonica.plan.io/issues/1511 has now been resolved in Saxon CE > 1.1. > So, should now work right? Or is there another way to do pipelines in Saxon > CE 1.1? > > > --- > Linc > > > > -- > View this message in context: http://saxon-xslt-and-xquery-processor.13853.n7.nabble.com/Saxon-CE-pipeline-examples-tp9997p11864.html > Sent from the saxon-help mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [hidden email] > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2013.0.3343 / Virus Database: 3184/6352 - Release Date: 05/23/13 > > ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help |
Thanks for the offer. Actually, I have already fixed the issue and edited the post. It was as you said an issue with the stage#.xsl files. Apologies for the error on my part. Sent from my iPhone On 24/05/2013, at 5:09 PM, "O'Neil Delpratt [via Saxon XSLT and XQuery Processor]" <[hidden email]> wrote:
|
In reply to this post by Lincoln
I have worked out what the stage1.xsl... files needed to look like. So something now appear from stage3.xsl.
But I realised that it still is not working as expected. The results of each transform is not being appended to "main" as expected given my code: <xsl:template name="main" match="/"> <xsl:result-document href="#main" method="append-content"> ...Some html... </xsl:result-document> </xsl:template> Also... It would be great to not only append/replace the content to <div id="main">, but to also append/replace content generated in stage1 and stage2. ie <div id="main">...<div id="stage1element">...<div id="stage2element">... I have been playing with this and can't get examples in the doc to work, like: <xsl:result-document href="?select=//table[1]/tbody/tr[1]/td[2]"> I will need an example or 2 I think. Hope thats clear enough Many thx for any help on this. Regards, Link |
Free forum by Nabble | Edit this page |