 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 10th, 2007, 05:11 PM
|
|
Registered User
|
|
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Stumped on XSLT template
Thanks for your help Bill.
|
|

August 10th, 2007, 05:37 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
First, make sure you're using an XSLT 2.0 processor (Saxon or Altova).
Then it's just
<xsl:variable name="sorted_status" as="element()">
<xsl:perform-sort select="STATUS">
<xsl:sort select="xs:date(@_Date)"/>
</xsl:perform-sort>
</xsl:variable>
then you can access $sorted_status[last()]
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

August 10th, 2007, 05:38 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Sorry, typo there, should be as="element()*".
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

August 11th, 2007, 10:02 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
You need to understand the concept of "context". The select expression for xsl:sort is evaluated once for each node being sorted, with that node as the context node. If the expression starts with "//" then it's going to return the same value each time, regardless what node you're starting at.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

August 14th, 2007, 10:33 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
As I said before, the path expression used in xsl:sort needs to select starting at the context node. An absolute path expression starting with "/" is almost invariably wrong.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

August 14th, 2007, 07:05 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
If you read the specs (or any book or tutorial) you will see that path expressions beginning with "/" or "//" both select relative to the root of the document, so they suffer from the same problem.
If you don't read any spec or book or tutorial, then you will remain forever stumped - you won't even understand the answers when you ask a technical question.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

October 16th, 2007, 03:44 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Since you've deleted the comments that I was replying to, and since it was months ago, I can't recall what was said that caused me to become so irritated. But judging from the time I devoted to explaining the simplest of concepts found in the first few pages of any textbook, I strongly suspect that I was being extremely patient.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

December 19th, 2007, 01:55 PM
|
|
Registered User
|
|
Join Date: Dec 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Michael Kay,
I saw the original messages. Working in Biztalk, the fellow's questions were quite justified as your responses didn't apply. You should consider being kinder to people new in XSLT. Just because they are struggling with an issue doesn't mean they haven't done their homework and read a book.
Sam
|
|

December 19th, 2007, 02:14 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Sam,
Sorry, but as the record of one half of the conversation has been deleted, presumably by the originator, I cannot comment on whether my responses were reasonable or not.
I actually think it's pretty discourteous to delete your questions from the forum once they have been answered. It means the information I've taken trouble to provide is no use to anyone else, which in effect means I was wasting my time in providing it.
I freely admit I have off days; when you've answered the same question dozens of times, it's easy to forget that you're not teaching the same class of students, but that each questioner is arriving independently with the same baseline of zero knowledge. I don't often get irritated unless people are blatantly ignoring my responses. But I do often answer tersely, on the theory that any answer is better than none, and some people take that the wrong way.
If you like, I'll stop answering them.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
 |