Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Problems sorting data

From: David Carlisle <davidc@--------->
To:
Date: 7/4/2005 3:32:00 PM
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
________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent