OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: Order in an XML document

[ Lists Home | Date Index | Thread Index ]
  • From: Kay Michael <Michael.Kay@icl.com>
  • To: "'Michel Rodriguez'" <mrodrigu@ieee.org>, xml-dev@xml.org
  • Date: Wed, 24 May 2000 16:16:46 +0100

> My problem is simple: if I compare 2 elements A and B the 
> results can be
> 
> [1] A and B are not in the same document
> [2] A is before B
> [3] B is before A
> [4] A and B are equal
> [5] A is within B
> [6] B is within A
>

Relationships between nodes are determined using axes.

For clarity I'll use an is-subset() function that tests whether one nodeset
is a subset of
another. You can implement this test using count() and the union operator
but it gets difficult to read. Take "is-subset($X, $Y)" as a macro for
"count($X|$Y)=count($Y)".
 
<xsl:template name="compare">
   <xsl:param name="A"/>
   <xsl:param name="B"/>
   <xsl:choose>	
   	 <xsl:when test="is-subset($A, $B) and is-subset($B,
$A)">4</xsl:when>
	 <xsl:when test="is-subset($A, $B/preceding::*)">2</xsl:when>
	 <xsl:when test="is-subset($A, $B/following::*)">3</xsl:when>
	 <xsl:when test="is-subset($A, $B/descendant::*)">5</xsl:when>
	 <xsl:when test="is-subset($A, $B/ancestor::*)">6</xsl:when>
       <xsl:otherwise>1</xsl:otherwise>
   </xsl:choose>
</xsl:template>

Mike K

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************




 

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

Copyright 2001 XML.org. This site is hosted by OASIS