合并的文件如下所示
<?xml version="1.0" encoding="UTF-8"?>
<lineup>
<artists>
<artist id="124">
<name>Pascal & Pearce</name>
<genres>
<genre>dance</genre>
<genre>club</genre>
</genres>
<writeup>
After a chance meeting in 2007, Pascal Ellinas and Dave Pearce began the long winding road that is now the stellar production and DJ duo of Pascal & Pearce.
</writeup>
<gig>
<day>SUNDAY</day>
<time>
<starts>17:00</starts>
<ends>19:00</ends>
</time>
</gig>
<photo format="jpg">pascal-pierce</photo>
</artist>
<aritst id="101">
<name>Dan Patlansky</name>
<genres>
<genre>Blues</genre>
<genre>Rock</genre>
<genre>Jazz</genre>
</genres>
<writeup>
What Dan Patlansky can do with a six-string Fender Stratocaster at the age of 26, most critically acclaimed guitarists will never quite achieve in a lifetime.
</writeup>
<gig>
<day>Friday</day>
<time>
<starts>13:00</starts>
<ends>15:00</ends>
</time>
</gig>
<photo format="jpg">dan-patlansky</photo>
</aritst>
etc我需要按字母顺序对艺术家的名字进行排序,这是我到目前为止所得到的,但它没有产生任何结果。这是我的XSL文件。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" media-type="text/xml" />
<xsl:template match="/">
<lineup>
<artists>
<xsl:apply-templates select="artists/artist">
<xsl:sort select="name" order="ascending" />
</xsl:apply-templates>
</artists>
</lineup>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>我的输出只生成一个带有标记的空文件。我的合并文件是我的源文件。非常感谢你的帮助,谢谢。
发布于 2016-04-06 20:31:25
作为快速修复,将<xsl:apply-templates select="artists/artist">更改为<xsl:apply-templates select="lineup/artists/artist">。
它会更容易匹配
<xsl:template match="artists">
<xsl:copy>
<xsl:apply-templates select="artist">
<xsl:sort select="name"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>https://stackoverflow.com/questions/36461702
复制相似问题