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

xsl:sort for the first child element

Subject: xsl:sort for the first child element
From: Maik Stührenberg <Maik.Stuehrenberg@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 03 Jun 2003 11:55:07 +0200
xsl first child
Hello,

I have a problem regarding xsl:sort. Using an XML element like this.

<Bibitem Type="Book" Label="TEI">
	<Editor>
		<Given>C.M.</Given>
		<Family>Sperberg-McQueen</Family>
	</Editor>
	<Editor>
		<Given>L.</Given>
		<Family>Burnard</Family>
	</Editor>
	<Title>TEI P4: Guidelines for Electronic Text Encoding and Interchange</Title>
	<Address>XML Version: Oxford, Providence, Charlottesville, Bergen</Address>
	<Year>2002</Year>
</Bibitem>

it is no problem to sort the Bibitems according their Author or Editor elements with this stylesheet template:

...
<xsl:if test="Bibitem/@Type='Book'">
	<xsl:for-each select="Bibitem[@Type='Book']">
		<xsl:sort select="Author[1]/Family | Editor[1]/Family | Organization"/>
		<p>
			<xsl:apply-templates select="."/>
		</p>
	</xsl:for-each>
</xsl:if>
...

Note that all three elements are allowed as 'author' of a Bibitem: Author, Editor and Organization.
The problem is that if I use a Bibitem with both an Author or Editor element and an Organization element as well (which is also allowed according to the DTD), the xsl:sort breaks ("a sequence of more than one item is not allowed here" - of course). XSLT processor is Saxon 7.5.1


<Bibitem Type="Book" Label="TEI">
	<Editor>
		<Given>C.M.</Given>
		<Family>Sperberg-McQueen</Family>
	</Editor>
	<Editor>
		<Given>L.</Given>
		<Family>Burnard</Family>
	</Editor>
	<Title>TEI P4: Guidelines for Electronic Text Encoding and Interchange</Title>
	<Organization>Text Encoding Initiative Consortium</Organization>
	<Address>XML Version: Oxford, Providence, Charlottesville, Bergen</Address>
	<Year>2002</Year>
</Bibitem>

I tried to use xsl:sort as child element of xsl:choose/xsl:when, but it's not allowed. What I need is to check that the xsl:sort is only used on the first child element of Bibitem - regardless if it is Author, Editor or Organization. I tried the following without any success
<xsl:sort select="child::Author[1]/Family[position()=1] | child::Editor[1]/Family[position()=1] | child::Organization[position()=1]"/>
I know there were a lot of questions about getting the first child element, but I found none regarding xsl:sort. I had a look at Dave Pawson's FAQ too.
Any help would be appreciated.


Kind regards,

Maik Stührenberg


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

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