[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath is a composable language ... does that mean

Subject: Re: XPath is a composable language ... does that mean I can create an XPath expression for a then-clause and simply plug it into an if-then-else?
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 4 Dec 2022 17:26:12 -0000
Re:  XPath is a composable language ... does that mean
Yes. "Composable" essentially means that expressions are built up from other
expressions, and where there is a slot for an expression, you can use any
expression you like. Of course there are some caveats: operator precedence
rules mean you might need to use parentheses, and type checking rules mean you
need to use an expression that delivers values of the right type. There might
be the odd exception (XPath 2.0 had an ugly rule that the first argument of
xs:QName had to be a string literal) but they are few and far between.

Michael Kay
Saxonica

> On 4 Dec 2022, at 17:11, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Folks,
>
> I have this English sentence:
>
> if the machine = "Intel 386 or later processors and compatible processors"
then ... else ... .
>
> I deliberately elided the then-clause and the else-clause.
>
> I need to turn that English sentence into XPath. I created this XPath:
>
> if (/Windows_Executable_File/Headers/File_Header/Machine = "Intel 386 or
later processors and compatible processors")
> then
>    ...
> else
>    ...
>
> Next, I created an XPath expression for the then-clause. I created the XPath
independent of its enveloping if-then-else. Let me denote the XPath expression
I created as: then-clause-XPath.
>
> I did the same for the else-clause.
>
> I then plugged then-clause-XPath and else-clause-XPath into the
if-then-else:
>
> if (/Windows_Executable_File/Headers/File_Header/Machine = "Intel 386 or
later processors and compatible processors")
> then
>    then-clause-XPath
> else
>    else-clause-XPath
>
> The XPath 3.0 specification says this:
>
>      XPath 3.0 is a composable language
>
> Does "composable language" mean I can do as I describe above and the result
will be a valid XPath expression?
>
> That is, can I develop an XPath expression for the then-clause completely
independent of its enveloping if-then-else and then simply plug the XPath into
the if-then-else? Ditto for the else-clause? Does "composable language" mean I
can do this kind of thing?
>
> /Roger

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.