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]
Are there invariants in XML processing?

Hi Folks,

I have read that it is good to identify relations -- invariants -- that should hold true throughout processing, and it is good to insert assertions throughout your code to check that the invariants are maintained during processing. 

I can see how programs that involve mathematics can have invariants, i.e., some mathematical relation must be true throughout the code's manipulations. 

Are there invariants in non-mathematical problems?

Are there invariants in processing XML?

Suppose the processing problem is to transform one XML vocabulary to another. Are there invariants in this problem? 

Let's take a specific example. The first XML vocabulary has an element TYPE whose value is A, B, C, or D. The second XML vocabulary has an element publicMilitaryIndicator whose value is Civil, Joint, Military, or Private. After reading the documentation it is determined that the mapping is as follows:

A maps to Civil.
B maps to Joint.
C maps to Military.
D has a different meaning than Private so whenever D is encountered an error should be generated.

Here is XSLT code to do the mapping:

<xsl:template match="publicMilitaryIndicator">
    <xsl:param name="ARPT_row" as="element(row)"/>
    <publicMilitaryIndicator>
        <xsl:variable name="ind" select="$ARPT_row/TYPE"/>
        <xsl:choose>
            <xsl:when test="$ind eq 'A'">Civil</xsl:when>
            <xsl:when test="$ind eq 'B'">Joint</xsl:when>
            <xsl:when test="$ind eq 'C'">Military</xsl:when>
            <xsl:when test="$ind eq 'D'">**error**</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="'Invalid TYPE'"/>
            </xsl:otherwise>
        </xsl:choose>
    </publicMilitaryIndicator>
</xsl:template>

Is there an invariant in that mapping?

When you process XML documents do you identify invariants and then insert assertions throughout your code to check that the invariants are maintained during processing?

/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