xsl-list
[Top] [All Lists]

[xsl] Sorting XML data by <entry ID="">

2022-01-04 22:31:53
My dictionary data has the below basic format (simplified here):

<entry ID="c8fc4">
  <pron>
  <sense>
  <refs>
</entry>
<entry ID="c8f00">
  <pron>
  <sense>
  <refs>
</entry>
<entry ID="c8f25">
  <pron>
  <sense>
  <refs>
</entry>

...which I want to sort by @ID.

The below XSLT seems to work, but despite the xsl:output method="xml" declaration, the files come out as .html (even though the contents are fine). What am I missing?


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="dealt">
 <xsl:copy>
  <xsl:apply-templates select="@*"/>
  <xsl:apply-templates select="entry">
   <xsl:sort select="@ID" order="ascending"/>
  </xsl:apply-templates>
 </xsl:copy>
</xsl:template>

<xsl:template match="@* | node()">
 <xsl:copy>
  <xsl:apply-templates select="@* | node()"/>
 </xsl:copy>
</xsl:template>


Regards,

Chuck



---------------------------
A. Charles Muller, Professor

Buddhist Culture Research Center
Musashino University
1-1-20 Shinmachi, Nishitokyo-shi
Tokyo 202-8585, Japan
Office Phone: 042-468-3145

(University of Tokyo, Professor Emeritus)
Web Site: Resources for East Asian Language and Thought
http://www.acmuller.net

Twitter: @ACharlesMuller
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>