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

Re: Yet Another V2 Request: Extension Functions via XSLT 2

From: Alex Milowski <alex@milowski.com>
Date: Wed, 7 Aug 2013 17:36:10 -0700
Message-ID: <CABp3FNL2Yy=rLPpCuHmm1QSw=gYu4=AFs9CudaxRfzH0YsK+6A@mail.gmail.com>
To: XProc WG <public-xml-processing-model-wg@w3.org>
Let me explain the use case a bit better.  I have documents that are typed,
often on the root element, with specific RDFa types.  The derived type is
computed against the @vocab attribute (and others) along with the @typeof
attribute.  I want to expose an extension function so I can do something
like this:

<p:choose>
<p:when test="rdfa:is-type(/*,'http://example.com/Book')">
...
</p:when>
<p:otherwise>...</p:otherwise>
</p:choose>

In reality, these functions are very easy to implement in XSLT 2.0:

   <xsl:function name="rdfa:type">

      <xsl:param name="n"/>
      <xsl:variable name="vocab" select="$n/ancestor-or-self::*/@vocab[1]"/>
      <xsl:sequence select="for $t in tokenize($n/@typeof,'\s+') return
resolve-uri($t,$vocab)"/>
   </xsl:function>

   <xsl:function name="rdfa:is-type">
      <xsl:param name="n"/>
      <xsl:param name="uri" as="xs:string"/>
      <xsl:sequence select="exists(index-of(rdfa:type($n),$uri))"/>
   </xsl:function>

So, I really just want a way in p:library to declare these functions.  I
could imagine just importing an XSLT library directly but I wonder whether
that is technical feasible given existing implementations.


On Wed, Aug 7, 2013 at 2:15 PM, Alex Milowski <alex@milowski.com> wrote:

> It sure would be handy to be able to define functions that can be used in
> step expressions via XSLT 2.  Specifically, I'm thinking of things that
> control p:choose alternatives.
>
> My use case is simply calculating the type URIs for an RDFa typeof
> attribute.  I want to process a document differently depending on an RDFa
> typeof attribute.  The type value is a resolved by a number of operations
> that neatly fit into an XSLT function definition.
>
> Right now I have to wrap this in an p:xslt step that outputs a coded
> document that I can use the p:choose step.  If I just had the function
> available, I could run it directly.
>
> The feature could only be available if an implementation supported XSLT 2.
>
> Thoughts?
>
> --
> --Alex Milowski
> "The excellence of grammar as a guide is proportional to the paucity of the
> inflexions, i.e. to the degree of analysis effected by the language
> considered."
>
> Bertrand Russell in a footnote of Principles of Mathematics
>



-- 
--Alex Milowski
"The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered."

Bertrand Russell in a footnote of Principles of Mathematics
Received on Thursday, 8 August 2013 00:36:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:32:52 UTC