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

RE: Order in an XML document

  • From: Kay Michael <Michael.Kay@i...>
  • To: "'Michel Rodriguez'" <mrodrigu@i...>, xml-dev@x...
  • Date: Wed, 24 May 2000 16:16:46 +0100

reorder xml by date
> 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@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

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.