1
votes

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ak="http://www.bilibili.com/namespace" version="2.0">
  <xsl:template match="/">
    <html>
      <body>
        <h1>Contracts of book name</h1>
        <xsl:for-each-group select="/ak:bookstore/ak:book" group-by="fuck:title">
          <xsl:sort select="current-group-key()"/>
          <p>The book name is 
            <b><xsl:value-of select="current-group-key()"/></b>
            <ul>
              <xsl:apply-templates select="current-group-key()">
                <xsl:sort select="ak:author"/>
              </xsl:apply-templates>
            </ul>
          </p>
        </xsl:for-each-group>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="ak:book">
    <li>
      <xsl:value-of select="ak:author"/>
    </li>
  </xsl:template>
</xsl:stylesheet>`

Shell:

C:\Users\Administrator\Desktop\xml\try>java -jar D:\saxon\saxon9he.jar -o:try.html book.xml try.xslt

Errors:

Static error in {current-group-key()} in expression in xsl:sort/@select on line11 column 47 of try.xslt:XPST0017: Unknown system function current-group-key()

Static error in {current-group-key()} in expression in xsl:value-of/@select on line 13 column 55 of try.xslt:XPST0017: Unknown system function current-group-key()

Static error in {current-group-key()} in expression in xsl:apply-templates/@select on line 15 column 59 of try.xslt:XPST0017: Unknown system function current-group-key()

Errors were reported during stylesheet compilation.


This is my code and shell. Why can't Saxon9-HomeEdition analyze it?

1

1 Answers

2
votes

The function is called current-grouping-key() (https://www.w3.org/TR/xslt20/#current-grouping-key), not current-group-key(). And the <xsl:apply-templates select="current-group-key()"> should be <xsl:apply-templates select="current-group()"> (https://www.w3.org/TR/xslt20/#current-group), I guess.