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

Re: What is declarative XML? (And what's not)

  • From: Rick Jelliffe <rjelliffe@allette.com.au>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Mon, 01 Jun 2009 17:03:22 +1000

Re:  What is declarative XML? (And what's not)
Costello, Roger L. wrote:
> Do you agree that this stylesheet document is not a declarative XML document?
>   
I don't think the opposite of "declarative" is really "procedural".  The 
opposite of "procedural" is "functional".  XSLT considered functional, 
not procedural, because functions do not have side effects (variables' 
values cannot be updated.)

The opposite of "declarative" is "algorithmic": declarative says what 
you want, algorithmic says how you do it.

So I think XSLT is declarative when using the template and XPaths, but 
algorithmic when using recursion. You can see that the use of  
<xsl:when> rather than <xsl:if> betrays the concern to try to be as 
declarative as possible.

There are implementation distinctions. The more declarative some program 
is, the more that it can be parallelized and optimized and have 
evaluation re-ordered. This is the same benefit that pure "functional" 
languages have, but "declarative" is not the same as "functional" and 
"algorithmic" is not the same as "procedural".

In your example, I think it is declarative, because there is just an 
identity established, and there is nothing given about how it should be 
implemented. The following two are algorithmic however:
   (map 'sum xpath(  "/purchases/merchandise/cost" ))
or
   int cost[] = get-xpath( current-doc, "/purchases/merchandise/cost" );
   int value = 0;
   for-each (cost) {
         value += cost;
   }

In XSLT you cannot tell how a built-in function is implemented: just 
invoking a function is declarative IMHO.
 
Cheers
Rick Jelliffe


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.