W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > August 2010

Re: Possible new XProc 1.1 step: p:template

From: Norman Walsh <ndw@nwalsh.com>
Date: Thu, 26 Aug 2010 14:37:50 -0400
To: public-xml-processing-model-wg@w3.org
Message-ID: <m24oehw77l.fsf@nwalsh.com>
At today's telcon, I mumbled something about having planned to
investigate the XQuery solution. Here it is. It doesn't have the match
semantics that Henry described, but it might be less cumbersome than
several consecutive "add-attribute" and "string-replace" steps.
Sometimes.

<p:declare-step version='1.0' name="main"
                xmlns:c="http://www.w3.org/ns/xproc-step"
                xmlns:p="http://www.w3.org/ns/xproc">
<p:input port="source"/>
<p:output port="result"/>
<p:input port="parameters" kind="parameter"/>

<p:variable name="vname" select="'my value'"/>

<p:xquery>
  <p:input port="query">
    <p:inline>
      <c:query><![CDATA[
        declare variable $foo external;
        declare variable $bar external;

        <doc avalue="{$foo}">{$bar}</doc>
      ]]></c:query>
    </p:inline>
  </p:input>
  <p:with-param name="foo" select="'some value'"/>
  <p:with-param name="bar" select="$vname"/>
</p:xquery>

</p:declare-step>

Of course, it's equally easy in XSLT. (For whatever definition of "easy"
you think applies in this case.)

<p:declare-step version='1.0' name="main"
                xmlns:p="http://www.w3.org/ns/xproc">
<p:input port="source"/>
<p:output port="result"/>
<p:input port="parameters" kind="parameter"/>

<p:variable name="vname" select="'my value'"/>

<p:xslt template-name="start">
  <p:input port="stylesheet">
    <p:inline>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      version="2.0">

        <xsl:param name="foo" required="yes"/>
        <xsl:param name="bar" required="yes"/>

        <xsl:template name="start">
          <doc avalue="{$foo}">
            <xsl:value-of select="$bar"/>
          </doc>
        </xsl:template>
      </xsl:stylesheet>
    </p:inline>
  </p:input>
  <p:with-param name="foo" select="'some value'"/>
  <p:with-param name="bar" select="$vname"/>
</p:xslt>

</p:declare-step>

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
www.marklogic.com

Received on Thursday, 26 August 2010 18:38:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 August 2010 18:38:28 GMT