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

Re: Problems sorting data

Subject: Re: Problems sorting data
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 4 Jul 2005 16:31:31 +0100
data stripping
  But I'm not quite sure what you meant by the xsl:strip-space and 
  inter-element space though. I's appreciate if you could explain that a 
  bit more.


your document looked like
<contents>

	<object type="standard">
....
	</object>

	<object type="standard">
...

so the first 4 child nodes of contents are
1) a text node with two newline characters (#10)
2) an object element
3) a text node with two newline characters (#10)
4) an object element


so if you do
<xsl:apply-templates/>

that is <xsl:apply-templates/ select="node()"/> and selects all four of
those nodes.

You then sort using <xsl:sort select="member[@name='idstring']"/> the
text nodes don't have a member child so they get the sort key of ""
so will all sort together (first in order, most likely)
Unles you have another template matching text() the default template
will be used which will copy these nodes to the output.
Look at your generated file: you should see a lot of blank lines.

You can avoid this problem be either just selecting the elementnodes, as
i suggested, or adding <xsl:strip-space elemenets="contents"/>
in which case the white space text nodes will be removed before the
process  starts, so in that case contents will only have object element
children.


The other isssue is, you have

		<xsl:sort select="member[@name='idstring']"/>

so the sort key for is the string value of memebr element which is all
the character content of its descendents which is

"
			Unique1
		"

that is, the string begins with a newline and three tab characters. If
your processor doesn't ignore thses (and nothing in the spec implies
that it should ignore them) then any element that is indented less will
sort earlier.

If instead you had gone

		<xsl:sort select="member[@name='idstring']/string"/>
then the sort key would be the string value of the string element which
is
"Unique1"
so the issue about indentation would not arrise.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.