Determine result type of X-Path expression?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Determine result type of X-Path expression?

Emanuel Wlaschitz
Hi everyone!

We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).

How would we go about this to achieve something like that (simplified):

<axsl:template>
   <xsl:attribute name="match">
      <xsl:choose>
         <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
            <!-- write a modified version of $xpath, such as //*[$path] -->
         </xsl:when>
         <xsl:otherwise>
            <!-- write the expression as-is, since it can be used inside a template match -->
         </xsl:otherwise>
      </xsl:choose>
   </xsl:attribute>
   [...]
</axsl:template>

My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.

It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
It's Saxon 9.6 running on .NET, if it makes a difference.

Thanks in advance.

Regards, Emanuel

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Dimitre Novatchev
In XSLT 3.0 a template can match any item -- not only a node but also
an atomic item or a function.

Therefore the described problem doesn't exist with XSLT 3.0.

Certainly, not every XPath expression can be specified in the "match"
attribute of an <xsl:template> directive, because  "match patterns"
are a proper subset of the set of all XPath expressions.

The syntax of a "pattern" is defined here:

   http://www.w3.org/TR/xslt-30/#patterns


If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:

  http://www.w3.org/TR/xpath20/#id-castable



Cheers,
Dimitre




On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
<[hidden email]> wrote:

> Hi everyone!
>
> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>
> How would we go about this to achieve something like that (simplified):
>
> <axsl:template>
>    <xsl:attribute name="match">
>       <xsl:choose>
>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>             <!-- write a modified version of $xpath, such as //*[$path] -->
>          </xsl:when>
>          <xsl:otherwise>
>             <!-- write the expression as-is, since it can be used inside a template match -->
>          </xsl:otherwise>
>       </xsl:choose>
>    </xsl:attribute>
>    [...]
> </axsl:template>
>
> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>
> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
> It's Saxon 9.6 running on .NET, if it makes a difference.
>
> Thanks in advance.
>
> Regards, Emanuel
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Dimitre Novatchev
> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>
>   http://www.w3.org/TR/xpath20/#id-castable


Or just use the "instance of" operator:

  http://www.w3.org/TR/xpath20/#id-instance-of

Like this:

  $yourExpr instance of node()




Cheers,
Dimitre





On Wed, Nov 25, 2015 at 8:44 AM, Dimitre Novatchev <[hidden email]> wrote:

> In XSLT 3.0 a template can match any item -- not only a node but also
> an atomic item or a function.
>
> Therefore the described problem doesn't exist with XSLT 3.0.
>
> Certainly, not every XPath expression can be specified in the "match"
> attribute of an <xsl:template> directive, because  "match patterns"
> are a proper subset of the set of all XPath expressions.
>
> The syntax of a "pattern" is defined here:
>
>    http://www.w3.org/TR/xslt-30/#patterns
>
>
> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>
>   http://www.w3.org/TR/xpath20/#id-castable
>
>
>
> Cheers,
> Dimitre
>
>
>
>
> On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
> <[hidden email]> wrote:
>> Hi everyone!
>>
>> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
>> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
>> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>>
>> How would we go about this to achieve something like that (simplified):
>>
>> <axsl:template>
>>    <xsl:attribute name="match">
>>       <xsl:choose>
>>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>>             <!-- write a modified version of $xpath, such as //*[$path] -->
>>          </xsl:when>
>>          <xsl:otherwise>
>>             <!-- write the expression as-is, since it can be used inside a template match -->
>>          </xsl:otherwise>
>>       </xsl:choose>
>>    </xsl:attribute>
>>    [...]
>> </axsl:template>
>>
>> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>>
>> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
>> It's Saxon 9.6 running on .NET, if it makes a difference.
>>
>> Thanks in advance.
>>
>> Regards, Emanuel
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Dave Pawson-2
In reply to this post by Dimitre Novatchev
Dimitre, I'm not certain, but last time I checked, no one had started
work on Schematron using XSLT 3.0.
  That may or may not be relevant here
regards

On 25 November 2015 at 16:44, Dimitre Novatchev <[hidden email]> wrote:

> In XSLT 3.0 a template can match any item -- not only a node but also
> an atomic item or a function.
>
> Therefore the described problem doesn't exist with XSLT 3.0.
>
> Certainly, not every XPath expression can be specified in the "match"
> attribute of an <xsl:template> directive, because  "match patterns"
> are a proper subset of the set of all XPath expressions.
>
> The syntax of a "pattern" is defined here:
>
>    http://www.w3.org/TR/xslt-30/#patterns
>
>
> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>
>   http://www.w3.org/TR/xpath20/#id-castable
>
>
>
> Cheers,
> Dimitre
>
>
>
>
> On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
> <[hidden email]> wrote:
>> Hi everyone!
>>
>> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
>> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
>> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>>
>> How would we go about this to achieve something like that (simplified):
>>
>> <axsl:template>
>>    <xsl:attribute name="match">
>>       <xsl:choose>
>>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>>             <!-- write a modified version of $xpath, such as //*[$path] -->
>>          </xsl:when>
>>          <xsl:otherwise>
>>             <!-- write the expression as-is, since it can be used inside a template match -->
>>          </xsl:otherwise>
>>       </xsl:choose>
>>    </xsl:attribute>
>>    [...]
>> </axsl:template>
>>
>> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>>
>> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
>> It's Saxon 9.6 running on .NET, if it makes a difference.
>>
>> Thanks in advance.
>>
>> Regards, Emanuel
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Michael Kay
In reply to this post by Emanuel Wlaschitz
There seem to be two separate questions here:

(a) is a given string a valid XSLT (2.0?) pattern?

(b) given a string that is a valid XPath (2.0?) expression, does it return a node-set?

They aren't the same, for example "x except y" satisfies (b) but not (a).

Although you say you want (b), I think you really want (a).

You can check whether a string is a valid Pattern by calling XPathCompiler.compilePattern() and catching the exception.

Michael Kay
Saxonica




> On 25 Nov 2015, at 15:43, Emanuel Wlaschitz <[hidden email]> wrote:
>
> Hi everyone!
>
> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>
> How would we go about this to achieve something like that (simplified):
>
> <axsl:template>
>   <xsl:attribute name="match">
>      <xsl:choose>
>         <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>            <!-- write a modified version of $xpath, such as //*[$path] -->
>         </xsl:when>
>         <xsl:otherwise>
>            <!-- write the expression as-is, since it can be used inside a template match -->
>         </xsl:otherwise>
>      </xsl:choose>
>   </xsl:attribute>
>   [...]
> </axsl:template>
>
> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>
> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
> It's Saxon 9.6 running on .NET, if it makes a difference.
>
> Thanks in advance.
>
> Regards, Emanuel
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Dimitre Novatchev
In reply to this post by Dave Pawson-2
Dave,

Maybe I am wrong, but my understanding is that the XSLT we are talking
about is generated as **result** -- then the transformation can be
performed with any XSLT processor.

To quote Emanuel Wlaschitz  the OP:

     "It'd need to work on Saxon-HE as well, so we cannot rely on
saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. "

On Wed, Nov 25, 2015 at 8:57 AM, Dave Pawson <[hidden email]> wrote:

> Dimitre, I'm not certain, but last time I checked, no one had started
> work on Schematron using XSLT 3.0.
>   That may or may not be relevant here
> regards
>
> On 25 November 2015 at 16:44, Dimitre Novatchev <[hidden email]> wrote:
>> In XSLT 3.0 a template can match any item -- not only a node but also
>> an atomic item or a function.
>>
>> Therefore the described problem doesn't exist with XSLT 3.0.
>>
>> Certainly, not every XPath expression can be specified in the "match"
>> attribute of an <xsl:template> directive, because  "match patterns"
>> are a proper subset of the set of all XPath expressions.
>>
>> The syntax of a "pattern" is defined here:
>>
>>    http://www.w3.org/TR/xslt-30/#patterns
>>
>>
>> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>>
>>   http://www.w3.org/TR/xpath20/#id-castable
>>
>>
>>
>> Cheers,
>> Dimitre
>>
>>
>>
>>
>> On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
>> <[hidden email]> wrote:
>>> Hi everyone!
>>>
>>> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
>>> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
>>> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>>>
>>> How would we go about this to achieve something like that (simplified):
>>>
>>> <axsl:template>
>>>    <xsl:attribute name="match">
>>>       <xsl:choose>
>>>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>>>             <!-- write a modified version of $xpath, such as //*[$path] -->
>>>          </xsl:when>
>>>          <xsl:otherwise>
>>>             <!-- write the expression as-is, since it can be used inside a template match -->
>>>          </xsl:otherwise>
>>>       </xsl:choose>
>>>    </xsl:attribute>
>>>    [...]
>>> </axsl:template>
>>>
>>> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>>>
>>> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
>>> It's Saxon 9.6 running on .NET, if it makes a difference.
>>>
>>> Thanks in advance.
>>>
>>> Regards, Emanuel
>>>
>>> ------------------------------------------------------------------------------
>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>> Use one codebase in this all-in-one HTML5 development environment.
>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>
>> --
>> Cheers,
>> Dimitre Novatchev
>> ---------------------------------------
>> Truly great madness cannot be achieved without significant intelligence.
>> ---------------------------------------
>> To invent, you need a good imagination and a pile of junk
>> -------------------------------------
>> Never fight an inanimate object
>> -------------------------------------
>> To avoid situations in which you might make mistakes may be the
>> biggest mistake of all
>> ------------------------------------
>> Quality means doing it right when no one is looking.
>> -------------------------------------
>> You've achieved success in your field when you don't know whether what
>> you're doing is work or play
>> -------------------------------------
>> To achieve the impossible dream, try going to sleep.
>> -------------------------------------
>> Facts do not cease to exist because they are ignored.
>> -------------------------------------
>> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
>> write all patents, too? :)
>> -------------------------------------
>> Sanity is madness put to good use.
>> -------------------------------------
>> I finally figured out the only reason to be alive is to enjoy it.
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> Docbook FAQ.
> http://www.dpawson.co.uk
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Dave Pawson-2
"We're generating Schematron from a different source format which
contains X-Path expressions, and then transform this Schematron file
using the ISO Schematron XSLTs "
So it pre Schematron? So o/p needs to be valid XSLT 1.0
to go into the two stage ISO implementation?
http://www.schematron.com/iso/P5.html#T4

regards

On 25 November 2015 at 17:53, Dimitre Novatchev <[hidden email]> wrote:

> Dave,
>
> Maybe I am wrong, but my understanding is that the XSLT we are talking
> about is generated as **result** -- then the transformation can be
> performed with any XSLT processor.
>
> To quote Emanuel Wlaschitz  the OP:
>
>      "It'd need to work on Saxon-HE as well, so we cannot rely on
> saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. "
>
> On Wed, Nov 25, 2015 at 8:57 AM, Dave Pawson <[hidden email]> wrote:
>> Dimitre, I'm not certain, but last time I checked, no one had started
>> work on Schematron using XSLT 3.0.
>>   That may or may not be relevant here
>> regards
>>
>> On 25 November 2015 at 16:44, Dimitre Novatchev <[hidden email]> wrote:
>>> In XSLT 3.0 a template can match any item -- not only a node but also
>>> an atomic item or a function.
>>>
>>> Therefore the described problem doesn't exist with XSLT 3.0.
>>>
>>> Certainly, not every XPath expression can be specified in the "match"
>>> attribute of an <xsl:template> directive, because  "match patterns"
>>> are a proper subset of the set of all XPath expressions.
>>>
>>> The syntax of a "pattern" is defined here:
>>>
>>>    http://www.w3.org/TR/xslt-30/#patterns
>>>
>>>
>>> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>>>
>>>   http://www.w3.org/TR/xpath20/#id-castable
>>>
>>>
>>>
>>> Cheers,
>>> Dimitre
>>>
>>>
>>>
>>>
>>> On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
>>> <[hidden email]> wrote:
>>>> Hi everyone!
>>>>
>>>> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
>>>> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
>>>> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>>>>
>>>> How would we go about this to achieve something like that (simplified):
>>>>
>>>> <axsl:template>
>>>>    <xsl:attribute name="match">
>>>>       <xsl:choose>
>>>>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>>>>             <!-- write a modified version of $xpath, such as //*[$path] -->
>>>>          </xsl:when>
>>>>          <xsl:otherwise>
>>>>             <!-- write the expression as-is, since it can be used inside a template match -->
>>>>          </xsl:otherwise>
>>>>       </xsl:choose>
>>>>    </xsl:attribute>
>>>>    [...]
>>>> </axsl:template>
>>>>
>>>> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>>>>
>>>> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
>>>> It's Saxon 9.6 running on .NET, if it makes a difference.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Regards, Emanuel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>>> Use one codebase in this all-in-one HTML5 development environment.
>>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>>>> _______________________________________________
>>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Dimitre Novatchev
>>> ---------------------------------------
>>> Truly great madness cannot be achieved without significant intelligence.
>>> ---------------------------------------
>>> To invent, you need a good imagination and a pile of junk
>>> -------------------------------------
>>> Never fight an inanimate object
>>> -------------------------------------
>>> To avoid situations in which you might make mistakes may be the
>>> biggest mistake of all
>>> ------------------------------------
>>> Quality means doing it right when no one is looking.
>>> -------------------------------------
>>> You've achieved success in your field when you don't know whether what
>>> you're doing is work or play
>>> -------------------------------------
>>> To achieve the impossible dream, try going to sleep.
>>> -------------------------------------
>>> Facts do not cease to exist because they are ignored.
>>> -------------------------------------
>>> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
>>> write all patents, too? :)
>>> -------------------------------------
>>> Sanity is madness put to good use.
>>> -------------------------------------
>>> I finally figured out the only reason to be alive is to enjoy it.
>>>
>>> ------------------------------------------------------------------------------
>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>> Use one codebase in this all-in-one HTML5 development environment.
>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>
>> --
>> Dave Pawson
>> XSLT XSL-FO FAQ.
>> Docbook FAQ.
>> http://www.dpawson.co.uk
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Emanuel Wlaschitz
Now thats some interresting replies right there, let me sort thru those...

I meant the Implementation (XSLTs) provided by www.schematron.com (with the Namespace http://purl.oclc.org/dsdl/schematron). But that’s not actually the point; I only intended to provide this as context on why I'd need to determine whether I need to know if it's valid as a template match expression.
Two stages earlier, one of *my* XSLTs runs to create the base Schematron - that's where I'd need to know this already and take action to make sure it won't fail later.

I'll take a look into whether "instance of" and "castable as" would help here; thanks for those references!

I'll also look at XPathCompiler.compilePattern - I believe "Pattern" is the key word I was missing here.

Thanks for the replies so far!
- Emanuel

-----Original Message-----
From: Dave Pawson [mailto:[hidden email]]
Sent: Mittwoch, 25. November 2015 19:06
To: Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>
Subject: Re: [saxon] Determine result type of X-Path expression?

"We're generating Schematron from a different source format which
contains X-Path expressions, and then transform this Schematron file
using the ISO Schematron XSLTs "
So it pre Schematron? So o/p needs to be valid XSLT 1.0
to go into the two stage ISO implementation?
http://www.schematron.com/iso/P5.html#T4

regards

On 25 November 2015 at 17:53, Dimitre Novatchev <[hidden email]> wrote:

> Dave,
>
> Maybe I am wrong, but my understanding is that the XSLT we are talking
> about is generated as **result** -- then the transformation can be
> performed with any XSLT processor.
>
> To quote Emanuel Wlaschitz  the OP:
>
>      "It'd need to work on Saxon-HE as well, so we cannot rely on
> saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. "
>
> On Wed, Nov 25, 2015 at 8:57 AM, Dave Pawson <[hidden email]> wrote:
>> Dimitre, I'm not certain, but last time I checked, no one had started
>> work on Schematron using XSLT 3.0.
>>   That may or may not be relevant here
>> regards
>>
>> On 25 November 2015 at 16:44, Dimitre Novatchev <[hidden email]> wrote:
>>> In XSLT 3.0 a template can match any item -- not only a node but also
>>> an atomic item or a function.
>>>
>>> Therefore the described problem doesn't exist with XSLT 3.0.
>>>
>>> Certainly, not every XPath expression can be specified in the "match"
>>> attribute of an <xsl:template> directive, because  "match patterns"
>>> are a proper subset of the set of all XPath expressions.
>>>
>>> The syntax of a "pattern" is defined here:
>>>
>>>    http://www.w3.org/TR/xslt-30/#patterns
>>>
>>>
>>> If constrained to XSLT 2..0, one can use the XPath 2.0 "castable as" operator:
>>>
>>>   http://www.w3.org/TR/xpath20/#id-castable
>>>
>>>
>>>
>>> Cheers,
>>> Dimitre
>>>
>>>
>>>
>>>
>>> On Wed, Nov 25, 2015 at 7:43 AM, Emanuel Wlaschitz
>>> <[hidden email]> wrote:
>>>> Hi everyone!
>>>>
>>>> We're generating Schematron from a different source format which contains X-Path expressions, and then transform this Schematron file using the ISO Schematron XSLTs (which outputs a XSLT to be used on the files that need validation) for further use.
>>>> We cannot really control the source format and might run into the issue that generating a Schematron Rule for "//foo[@bar]" works (since it returns a node-set), while "//foo[someCond] and //bar" does not (returns a xs:Boolean which cannot be used as template match). The error however only appears when the ISO Schematron XSLTs are done with their work, generating the final XSLT for validation.
>>>> Currently, we have some simple string-based matching that catches some common patterns and rewrites them; but it doesn't work for every case there is (and might even create false positives).
>>>>
>>>> How would we go about this to achieve something like that (simplified):
>>>>
>>>> <axsl:template>
>>>>    <xsl:attribute name="match">
>>>>       <xsl:choose>
>>>>          <xsl:when test="not(magic-func:is-valid-as-template-match($xpath))">
>>>>             <!-- write a modified version of $xpath, such as //*[$path] -->
>>>>          </xsl:when>
>>>>          <xsl:otherwise>
>>>>             <!-- write the expression as-is, since it can be used inside a template match -->
>>>>          </xsl:otherwise>
>>>>       </xsl:choose>
>>>>    </xsl:attribute>
>>>>    [...]
>>>> </axsl:template>
>>>>
>>>> My naïve idea of magic-func:is-valid-as-template-match($xpath) would simply return if the result type of the passed expression evaluates to node-set, item()* or whatever the appropriate type is in that context.
>>>>
>>>> It'd need to work on Saxon-HE as well, so we cannot rely on saxon:evaluate (or xsl:evaluate from 3.0) for an XSLT-only solution. However, we already add some ("integrated") extension functions of our own; so it makes no real difference to adding another one that for that purpose.
>>>> It's Saxon 9.6 running on .NET, if it makes a difference.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Regards, Emanuel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>>> Use one codebase in this all-in-one HTML5 development environment.
>>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>>>> _______________________________________________
>>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Dimitre Novatchev
>>> ---------------------------------------
>>> Truly great madness cannot be achieved without significant intelligence.
>>> ---------------------------------------
>>> To invent, you need a good imagination and a pile of junk
>>> -------------------------------------
>>> Never fight an inanimate object
>>> -------------------------------------
>>> To avoid situations in which you might make mistakes may be the
>>> biggest mistake of all
>>> ------------------------------------
>>> Quality means doing it right when no one is looking.
>>> -------------------------------------
>>> You've achieved success in your field when you don't know whether what
>>> you're doing is work or play
>>> -------------------------------------
>>> To achieve the impossible dream, try going to sleep.
>>> -------------------------------------
>>> Facts do not cease to exist because they are ignored.
>>> -------------------------------------
>>> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
>>> write all patents, too? :)
>>> -------------------------------------
>>> Sanity is madness put to good use.
>>> -------------------------------------
>>> I finally figured out the only reason to be alive is to enjoy it.
>>>
>>> ------------------------------------------------------------------------------
>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>> Use one codebase in this all-in-one HTML5 development environment.
>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>
>> --
>> Dave Pawson
>> XSLT XSL-FO FAQ.
>> Docbook FAQ.
>> http://www.dpawson.co.uk
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Determine result type of X-Path expression?

Emanuel Wlaschitz
Hm, "instance of" and "castable as" don't really help here, since my Input is an X-Path string; not the result of an X-Path expression.

XPathCompiler.compilePattern in an extension function works like a charm; altho I had to reference the Java classes directly, rather than going through Saxon.Api. Unsurprisingly, its exception has the same message that would occur two stages later when trying to apply the Schematron-generated XSLT.

Thanks again!
- Emanuel

-----Original Message-----
From: Emanuel Wlaschitz [mailto:[hidden email]]
Sent: Donnerstag, 26. November 2015 08:00
To: Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>
Subject: Re: [saxon] Determine result type of X-Path expression?

Now thats some interresting replies right there, let me sort thru those...

I meant the Implementation (XSLTs) provided by www.schematron.com (with the Namespace http://purl.oclc.org/dsdl/schematron). But that’s not actually the point; I only intended to provide this as context on why I'd need to determine whether I need to know if it's valid as a template match expression.
Two stages earlier, one of *my* XSLTs runs to create the base Schematron - that's where I'd need to know this already and take action to make sure it won't fail later.

I'll take a look into whether "instance of" and "castable as" would help here; thanks for those references!

I'll also look at XPathCompiler.compilePattern - I believe "Pattern" is the key word I was missing here.

Thanks for the replies so far!
- Emanuel
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help