ebeshero / DHClass-Hub

a repository to help introduce and orient students to the GitHub collaboration environment, and to support DH classes.
GNU Affero General Public License v3.0
27 stars 27 forks source link

XSLT 6: Sorting #724

Closed ajw120 closed 4 years ago

ajw120 commented 4 years ago

So I have started working on XSLT 6 and I figured out how to create links. But now I am currently stuck on as to where I am supposed to place the sequence in order to sort the table of contents. Everywhere that I place the sequence it comes up as an error. It basically tells me that the <xsl:sort select="@number ! number()"/> cannot be used there. I'm just stuck and confused.

ebeshero commented 4 years ago

Hi @ajw120! I just realized I didn't push my code from today's class this evening, so I'll do that. In the meantime, though, the place you want to put <xsl:sort select="some XPath"/> is inside an opened-up <xsl:apply-templates/>, like this:

<xsl:apply-templates select="descendant::something">
      <xsl:sort select="some XPath"/>
</xsl:apply-templates>

You want to do the sorting when you call apply-templates to process the nodes that you want to sort. I'll push my example from class today in a few minutes so you can see how it works and where I've placed the sort.

ebeshero commented 4 years ago

@ajw120 and class: I've just pushed my examples with this commit: https://github.com/ebeshero/DHClass-Hub/commit/30d4ef8fd81be5584c946eb1793893bab9b79d97