[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Integrated sort using different elements
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx] > Sent: Thursday, February 19, 2009 10:49 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: Integrated sort using different elements > > > > > > > <xsl:sort select=" > > > monogr/author | > > > self::*[not(monogr/author)]/analytic/author | > > > self::*[not(monogr/author | analytic/author)]/monogr/editor | > > > self::*[not(monogr/author | analytic/author | > > > monogr/editor)]/monogr/title"/> > > > > I think for XSLT 1.0 you can simplify that select to: > > > > <xsl:sort select="(monogr/author|analytic/author)[1]"/> > > > > I don't think so. That will select the first in document order, not the > first in the order of precedence defined in the requirement statement. Maybe I misunderstood the requirements, but I thought it said that under the biblStruct element you wanted the first one that occurred to be sorted. So given: <?xml version="1.0" ?> <document> <biblStruct> <analytic> <author>Author Name 2</author> <title>Article Name 2</title> </analytic> <monogr> <author>Author Name 0</author> <title>Journal Title 0</title> <editor>Editor Name 0</editor> </monogr> </biblStruct> <biblStruct> <monogr> <author>Author Name 1</author> <title>Journal Title 1</title> <editor>Editor Name 1</editor> </monogr> </biblStruct> </document> and: <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="biblStruct"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="document"> <xsl:copy> <xsl:apply-templates select="biblStruct"> <xsl:sort order="ascending" data-type="text" select="(monogr/author|analytic/author)[1]"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:apply-templates select="*[1]/self::document"/> </xsl:template> </xsl:transform> it should result in: <?xml version="1.0" encoding="UTF-8"?> <document> <biblStruct> <monogr> <author>Author Name 1</author> <title>Journal Title 1</title> <editor>Editor Name 1</editor> </monogr> </biblStruct> <biblStruct> <analytic> <author>Author Name 2</author> <title>Article Name 2</title> </analytic> <monogr> <author>Author Name 0</author> <title>Journal Title 0</title> <editor>Editor Name 0</editor> </monogr> </biblStruct> </document> So what did I misunderstand about the problem? Andy.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|