Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] What is declarative XML? (And what's not)

From: "Costello, Roger L." <costello@-----.--->
To: "'xml-dev@-----.---.---'" <-------@-----.---.--->
Date: 6/2/2009 11:02:00 PM
 
Rick Jelliffe wrote:

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


Rick also wrote:

> 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.


Alan Danziger wrote:

> Passive documents specify information but do not 
> specify in-band or out-of-band anything about 
> how that information should be used.

> Active documents contains in-band or out-of-band
> processing rules for its use. 

Ah ha!

So there are discernable differences in XML documents.

I want to capture those differences.

I want to identify those characteristics that make an XML document declarative and those characteristics that make an XML document passive.

I want to be able to take an XML document and measure its declarativity and passivity.


Assertion: declarativity is a quality that is good and desirable and should be maximized.

Assertion: passivity is a quality that is good and desirable and should be maximized.

Assertion: by measuring its declarativity and passivity we can assess the goodness of an XML document. 

Assertion: the goodness of an XML document is a function of its declarativity and passivity.


Rick and Dan identified one characteristic:

     A declarative XML document has the characteristic
     that its order can be changed without impact to
     processing.

I think this may also be a characteristic of passive documents.



This document is declarative but not passive (i.e. it's declarative & active):
----------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">

    <xsl:variable name="total-cost" 
                  select="sum(/purchases/merchandise/cost)" />

</xsl:stylesheet>
----------------------------------------------------------



This document is not declarative and not passive (i.e. it's algorithmic & active):
----------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

    <xsl:template match="purchases">
 
        <xsl:variable name="result">
            <xsl:call-template name="SumCosts">
                 <xsl:with-param name="costList" select="//cost"/>
            </xsl:call-template>
        </xsl:variable>

        sum = <xsl:value-of select="$result" />

    </xsl:template>

    <xsl:template name="SumCosts">
        <xsl:param name="costList"/>
        <xsl:param name="sum" select="0"/>

        <xsl:if test="not($costList)">
            <xsl:value-of select="$sum"/>
        </xsl:if>

        <xsl:if test="$costList">
            <xsl:call-template name="SumCosts">
                 <xsl:with-param name="costList" select="$costList[position() &gt; 1]"/>
                 <xsl:with-param name="sum" select="$sum + $costList[1]"/>
            </xsl:call-template>
        </xsl:if>

    </xsl:template>

</xsl:stylesheet>
----------------------------------------------------------




This document is both declarative and passive:
----------------------------------------------------------
<purchases date="2009-05">
    <merchandise>
        <name>Sony HT-IS100 BRAVIA Home Theater Micro System</name>
        <cost currency="USD">299.00</cost>
    </merchandise>
    <merchandise>
        <name>ASUS Eee PC 1000HE Netbook Computer</name>
        <cost currency="USD">379.00</cost>
    </merchandise>
    <merchandise>
        <name>Sony ICD-PX720 Digital Voice Recorder</name>
        <cost currency="USD">49.00</cost>
    </merchandise>
</purchases>
----------------------------------------------------------



By my "calculations" the third document has the most goodness and the second document has the least goodness. Therefore the third document is the best XML document and the second document is the worst XML document.


What are the other characteristics of declarative XML documents?

What are the other characteristics of passive XML documents?

/Roger
_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent