W3C home > Mailing lists > Public > xproc-dev@w3.org > March 2012

RE: merging the content of 2 or more http-requests

From: Philip Fennell <Philip.Fennell@marklogic.com>
Date: Mon, 19 Mar 2012 23:46:59 -0700
To: Georges Schmitz <georges.schmitz@arcor.de>, XProc Dev <xproc-dev@w3.org>
Message-ID: <D20C296D14127D4EBD176AD949D8A75A20563CE6CD@EXCHG-BE.marklogic.com>
Georges,

> Should I merge multiple XML documents into 1

Yes, that is what I would do. I would wrap the result of one request in a container element and then insert the other request result as a child of the container before passing the 'package' to the transform(s).

Of course, if you wanted to get clever you could keep your original transforms as they are and instead of creating a container for the two documents you create a temporary XSLT transform that imports your original transform and inserts the result of the second request into a parameter declaration. You then invoke this temporary transform and the second piece of XML will appear as though it had been passed as a parameter, which of course it was.

Your generated transform would look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="xs"
    version="2.0">

  <xsl:import href="path/to/your/primary/transform.xsl"/>

  <!-This is where you embed the result of the 'other' response. -->
  <xsl:param name="ADDITIONAL_DATA" as="element()">
    <html xmlns="http://www.w3.org/1999/xhtml">
      ...
    </html>
  </xsl:param>


  <xsl:template match="/">
    <xsl:apply-templates select="." mode="some-mode-in-the-imported-transform"/>
  </xsl:template>

</xsl:transform>

The above parameter declaration would override that in the imported transform and the template would override the behaviour of the root template in your imported transform too.

In the pipeline you can create a step that takes the 'additional data' document as its source input to generate this transform as the output result. You could either do it with XSLT or with XProc. The resulting transform can be piped into the stylesheet port of your main transform.


Regards

Philip


From: Georges Schmitz [mailto:georges.schmitz@arcor.de]
Sent: Monday, March 19, 2012 7:41 PM
To: XProc Dev
Subject: merging the content of 2 or more http-requests

Hi,

I'm not sure which path to follow or even start with. Here is my scenario:

 1.  a WebService provides the main content for an HTML report wich will be styled with XSLT (this part works already in my pipeline)
 2.  a 2nd WebService call will provided additional data that should be weaved into the resulting report of step 1).

In the XSLT world (and being offline) I would read secondary or tertiary information from the harddisk into a variable with the document() function and pick the necessary data with the key() function (or whatever else is apropriate) to enrich my report.

But with XProc, how should I pass the result of 2 or more http-requests to the XSLT step? Should I merge multiple XML documents into 1 by using p:pack or p:insert?

The easiest for me would be to feed the stylesheet via parameters or options, but as far as I can see, this is not possible with XProc (it would keep my stylesheets compatible).

If I'm successful with whatever turns out to work, I would like to enhance the basic flow with further steps, namely analysing the content of the primary http-request and use this to formulate constraints for further http-requests. An illusion?

Any hints are welcome,
Georges
Received on Tuesday, 20 March 2012 06:47:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 20 March 2012 06:47:29 GMT