From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: Thursday, February 19, 2009 10:49 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] 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.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--