Subject: Re: [xsl] Integrated sort using different elements From: Quinn Dombrowski <qdombrow@xxxxxxxx> Date: Thu, 19 Feb 2009 10:13:03 -0600 |
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: Thursday, February 19, 2009 10:49 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Integrated sort using different elements
I don't think so. That will select the first in document order, not the<xsl:sort select="I think for XSLT 1.0 you can simplify that select to:
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"/>
<xsl:sort select="(monogr/author|analytic/author)[1]"/>
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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Integrated sort using dif, Houghton,Andrew | Thread | RE: [xsl] Integrated sort using dif, Houghton,Andrew |
Re: [xsl] XSL-FO: Background text s, Florent Georges | Date | Re: [xsl] XSL-FO: Background text s, G. Ken Holman |
Month |