Created
June 11, 2012 06:30
-
-
Save halloffame/2908739 to your computer and use it in GitHub Desktop.
Problem sorting by seg number when number is like this: 240.15-01 (it will stick all the lines with XX.XX-XX in the back behind all the ones without the '-')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" | |
xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="#all"> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- Copy everything unless matched by another template --> | |
<xsl:template match="@*|node()|comment() " priority="-1"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()|comment()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="/"> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="tei:teiHeader"> | |
<teiHeader xmlns="http://www.tei-c.org/ns/1.0"> | |
<xsl:apply-templates/> | |
</teiHeader> | |
</xsl:template> | |
<xsl:template match="tei:text"> | |
<text xmlns="http://www.tei-c.org/ns/1.0"> | |
<xsl:apply-templates select="tei:front"/> | |
<body xmlns="http://www.tei-c.org/ns/1.0"> | |
<p xmlns="http://www.tei-c.org/ns/1.0"> | |
<xsl:for-each-group select="tei:group/tei:text//tei:seg" group-by="@n"> | |
<xsl:element name="seg"> | |
<xsl:attribute name="n"> | |
<xsl:value-of select="@n"/> | |
</xsl:attribute> | |
<app xmlns="http://www.tei-c.org/ns/1.0"> | |
<xsl:apply-templates select="current-group()"/> | |
</app> | |
</xsl:element> | |
</xsl:for-each-group> | |
</p> | |
</body> | |
</text> | |
</xsl:template> | |
<xsl:template match="tei:seg"> | |
<rdg wit="#{../../@n}" xmlns="http://www.tei-c.org/ns/1.0"> | |
<xsl:apply-templates/> | |
</rdg> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment