⚲
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.49 KB)
Support #3763
» sortForEachGroup.xsl
Test stylesheet demonstrating the grouping behaviour -
Andy Yar
, 2018-04-27 09:30
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
exclude-result-prefixes=
"xs f"
version=
"2.0"
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns:f=
"http://aimtec.cz/EDI"
>
<xsl:output
encoding=
"UTF-8"
indent=
"yes"
method=
"xml"
/>
<!-- document root -->
<xsl:template
match=
"root"
>
<root>
<!-- test the f:sort works -->
<sortTestOutput>
<xsl:sequence
select=
"f:sort(label)"
/>
</sortTestOutput>
<!--
create tuples from-to
expcted output: [1,4],[6,8],[10,12]
-->
<groupedOutput>
<xsl:for-each-group
select=
"f:sort(label)"
group-starting-with=
"label[preceding::label[1] + 1 != .]"
>
<element>
<from>
<xsl:value-of
select=
"current-group()[1]"
/>
</from>
<to>
<xsl:value-of
select=
"current-group()[last()]"
/>
</to>
</element>
</xsl:for-each-group>
</groupedOutput>
</root>
</xsl:template>
<xsl:function
name=
"f:sort"
>
<xsl:param
name=
"unsortedSequence"
/>
<xsl:perform-sort
select=
"$unsortedSequence"
>
<xsl:sort
select=
"."
data-type=
"number"
/>
</xsl:perform-sort>
</xsl:function>
</xsl:stylesheet>
« Previous
1
2
Next »
(1-1/2)
Loading...