Using tokens to refer to the context step...

Whilst writing a number of XProc steps it has occurred to me that an XSLT 2.0 style #current token might be useful when referring to the step your current step. An example:

<p:declare-step name="foo" type="x:foo">
  <p:input port="source" primary="true"/>
  <p:input port="config"/>
  <p:output port="result"/>
  
  <p:wrap match="/*" wrapper="c:body"/>
  <p:add-attribute match="/c:body" attribute-name="content-type" 
      attribute-value="application/xml"/>
  <p:wrap match="/c:body" wrapper="c:request"/>
  <p:add-attribute match="/c:request" attribute-name="method" 
      attribute-value="post"/>
  
  <p:add-attribute match="/c:request" attribute-name="href">
    <p:with-option name="attribute-value" select="/*/@href">
      <p:pipe port="config" step="foo"/>
    </p:with-option>
  </p:add-attribute>

  <p:http-request indent="false" method="xml" encoding="utf-8" 
      media-type="application/xml"/>
</p:declare-step>

In the above example, I obtain the URI for the request from an href attribute that is present on the context step's 'config' port.

I know it's 'small potatoes', but it would be nice if, rather than having to uniquely name the step declaration, you could just use '#current' instead, like this:

<p:add-attribute match="/c:request" attribute-name="href">
  <p:with-option name="attribute-value" select="/*/@href">
    <p:pipe port="config" step="#current"/>
  </p:with-option>
</p:add-attribute>

Now, some might argue to which step I'm referring to as being 'current'; do I mean the p:add-attribute or the x:foo step I'm declaring? The choice of token name and its semantics is up to those that like to debate such issues. I just thought it might be a useful short-hand.


Regards


Philip Fennell
Consultant

Mark Logic Corporation

Received on Tuesday, 17 November 2009 12:24:44 UTC