⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Saxon
Overview
Roadmap
Issues
Calendar
Blog
Documents
Forums
Files
Repository
Download (1.18 KB)
counting specific elements
» tab-list.xsl
XSLT 3 -
Mark Hutchinson
, 2025-01-13 22:07
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
xmlns:math=
"http://www.w3.org/2005/xpath-functions/math"
exclude-result-prefixes=
"xs math"
version=
"3.0"
>
<xsl:template
match=
"*"
>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template
match=
"entry"
>
<xsl:element
name=
"entry"
>
<xsl:copy-of
select=
"@* except @written"
/>
<xsl:apply-templates
select=
"node()"
mode=
"count"
/>
</xsl:element>
</xsl:template>
<xsl:template
match=
"*"
mode=
"count"
>
<xsl:copy-of
select=
"."
/>
</xsl:template>
<xsl:template
match=
"text()"
mode=
"count"
>
<xsl:copy-of
select=
"."
/>
</xsl:template>
<!-- Mode to count and set the c attribute -->
<xsl:template
match=
"p | ul | ol"
mode=
"count"
>
<xsl:variable
name=
"count"
select=
"count(preceding::p[ancestor::entry[1]] | preceding::ul[ancestor::entry[1]] | preceding::ol[ancestor::entry[1]]) + 1"
/>
<xsl:element
name=
"{name()}"
>
<xsl:attribute
name=
"c"
select=
"$count"
/>
<xsl:copy-of
select=
"@* except @written"
/>
<xsl:apply-templates
select=
"node()"
mode=
"count"
/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
« Previous
1
2
3
Next »
(1-1/3)
Loading...