XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] What is declarative XML? (And what's not)

 
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


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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS