Subject: Re: [xsl] xslt 2, grouping and more on indexing. From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 27 Aug 2004 12:18:23 +0100 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dp="data:,dp" exclude-result-prefixes="dp" > <xsl:output indent="yes"/> <xsl:variable name="index" select="index"/> <xsl:template match="index"> <xsl:variable name="x"> <xsl:for-each select="*"> <xsl:copy> <xsl:apply-templates mode="x"/> </xsl:copy> </xsl:for-each> </xsl:variable> <head>INDEX</head> <xsl:for-each-group select="$x/*" group-starting-with="ientry1" > <ientry1> <xsl:copy-of select="dp:sep(.)"/> <xsl:for-each-group select="current-group()[position()>1]" group-starting-with="ientry2"> <ientry2><xsl:copy-of select="dp:sep(text()[1])"/> <xsl:for-each-group select="current-group()[position()>1]" group-starting-with="ientry3"> <ientry3><xsl:copy-of select="dp:sep(text()[1])"/> </ientry3> </xsl:for-each-group> </ientry2> </xsl:for-each-group> </ientry1> </xsl:for-each-group> </xsl:template> <xsl:function name="dp:sep"> <xsl:param name="ientry" as="node()*"/> <ent> <xsl:analyze-string select="$ientry" regex="([0-9][.0-9\-]*)" flags="s"> <xsl:matching-substring> <r><xsl:value-of select="regex-group(1)"/></r> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:analyze-string select="." regex="(Appendix .*$)" flags="s"> <xsl:matching-substring> <r> <xsl:analyze-string select="." regex="\[@@@@@@\]" flags="s"> <xsl:matching-substring> <xsl:variable name="p" select="position()"/> <xsl:copy-of select="$index/*[count($ientry/preceding-sibling::*)+1]/node()[$p]"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </r> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:analyze-string select="." regex="\[@@@@@@\]" flags="s"> <xsl:matching-substring> <xsl:variable name="p" select="position()"/> <xsl:copy-of select="$index/*[count($ientry/preceding-sibling::*)+1]/node()[$p]"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:non-matching-substring> </xsl:analyze-string> </ent> </xsl:function> <xsl:template match="*" mode="x"> <xsl:text>[@@@@@@]</xsl:text> </xsl:template> </xsl:stylesheet> $ saxon8 index.xml index.xsl <?xml version="1.0" encoding="UTF-8"?> <head>INDEX</head> <ientry1> <ent>INDEX</ent> </ientry1> <ientry1> <ent>abbreviation point</ent> <ientry2> <ent>and use of letter sign, <r>5.6.2</r>, <r>5.6.6</r> </ent> </ientry2> <ientry2> <ent>in abbreviations, <r>7.1.1-2</r> </ent> </ientry2> <ientry2> <ent>in designations, <r>5.6.14</r> </ent> </ientry2> <ientry2> <ent>in italicized abbreviations, <r>5.5.16</r> </ent> </ientry2> <ientry2> <ent>in personal initials, <r>7.1.6</r> </ent> </ientry2> <ientry2> <ent>in postcodes, <r>7.1.6</r> </ent> </ientry2> <ientry2> <ent>in reference abbreviations, <r>7.3.2-3</r>, <r>7.3.6</r> </ent> </ientry2> <ientry2> <ent>in references, <r>7.3.1-4</r>, <r>7.3.6</r> </ent> </ientry2> <ientry2> <ent>in Welsh, <r>Appendix I (E)</r> </ent> <ientry3> <ent>and elided vowels, <r>5.1.7</r> </ent> </ientry3> <ientry3> <ent>French, <r>Appendix II (A)</r> </ent> </ientry3> <ientry3> <ent>German, <r>Appendix II (B)</r> </ent> </ientry3> <ientry3> <ent>in foreign ordinal terminations, <r>6.6.2</r>, <r>6.7.5</r> </ent> </ientry3> </ientry2> </ientry1> <ientry1> <ent>French, <r>Appendix II (A); see also <i>accented letters</i>; <i>accent sign</i>; <i>foreign, words and names</i> </r> </ent> </ientry1> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xslt 2, grouping and more on , David . Pawson | Thread | RE: [xsl] xslt 2, grouping and more, Michael Kay |
[xsl] xslt 2, grouping and more on , David . Pawson | Date | RE: [xsl] xslt 2, grouping and more, Michael Kay |
Month |