不懂不懂还是不懂。写XSL,删除XML的子节点,并输出XML。在线求解!该如何处理

不懂不懂还是不懂。写XSL,删除XML的子节点,并输出XML。。在线求解!!
运行修改了好几次,都没有正确的输出!!!在线等高手求解,感激不敬 啊啊啊

这个是我的XSL文件:
<?xml version="1.0" encoding="UTF-8"?>

<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent ="yes"/>

<xsl:template match="book"> 
  <book>
  <author>
  <xsl:sequence select="author/text()"/>
  </author>
  <title>
  <xsl:sequence select="title/text()">
  </xsl:sequence>
  </title>
  <contents>
  <xsl:call-template name="removelast">
  <xsl:with-param name ="seq" select="contents/chapter" as="element(chapter)*"/>
  </xsl:call-template>
  </contents>
  </book>
 </xsl:template>

 
  <xsl:template match="chapter" >
  <xsl:call-template name="removelast">
  <xsl:with-param name="seq" select="chapter"
  as="element(chapter)*"/>
  </xsl:call-template>
  </xsl:template>

  <xsl:template name="removelast" >
  <xsl:param name="seq" as="element()*"/>
  <xsl:choose>
  <xsl:when test="empty($seq[position()])"/>
  <xsl:otherwise>
  <xsl:call-template name="removelast">
  <xsl:with-param name="seq" select="$seq[position()>1]"/>
  </xsl:call-template>
  </xsl:otherwise>
  </xsl:choose>
  </xsl:template>

</xsl:transform>

这个是原来的XML文件:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book SYSTEM "book.dtd">

<book>
  <author>Priscilla Walmsley</author>
  <title>Definitive XML Schema</title>
  <contents>
  <chapter title="Schema: An Introduction"/>
  <chapter title="A quick tour of XML Schema"/>
  <chapter title="Namespaces"/>
  <chapter title="Schema composition"/>
  <chapter title="Instances and schemas"/>
  </contents>
</book>
这个是通过XSL删除最后节点之后要求输出的XML文件:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book SYSTEM "book.dtd">

<book>
  <author>Priscilla Walmsley</author>
  <title>Definitive XML Schema</title>
  <contents>
  <chapter title="Schema: An Introduction"/>
  <chapter title="A quick tour of XML Schema"/>
  <chapter title="Namespaces"/>
  <chapter title="Schema composition"/>
  
  </contents>
</book>

这个是DTD文件:
<!ELEMENT book (author,title,contents)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT contents (chapter+)>

<!ELEMENT chapter EMPTY>
<!ATTLIST chapter title CDATA #REQUIRED>






------解决方案--------------------