-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.xsl
More file actions
74 lines (69 loc) · 4.11 KB
/
utils.xsl
File metadata and controls
74 lines (69 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8"?>
<?modxslt-stylesheet type="text/xsl" media="fuffa, screen and $GET[stylesheet]" href="./%24GET%5Bstylesheet%5D" alternate="no" title="Translation using provided stylesheet" charset="ISO-8859-1" ?>
<?modxslt-stylesheet type="text/xsl" media="screen" alternate="no" title="Show raw source of the XML file" charset="ISO-8859-1" ?>
<xsl:stylesheet xmlns:yaslt="http://www.mod-xslt2.com/ns/2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" extension-element-prefixes="yaslt" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:local="http://www.example.com/functions/local" exclude-result-prefixes="local xs">
<!-- -->
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- function that truncate strings to 132 chars and adding '...' to mark the truncation -->
<xsl:function name="local:truncatestring" as="xs:string">
<xsl:param name="longstring" as="xs:string"/>
<xsl:variable name="size" as="xs:integer" select="string-length($longstring)"/>
<xsl:variable name="truncsize" as="xs:integer" select="132"/>
<xsl:choose>
<xsl:when test="$size > $truncsize">
<xsl:value-of select="concat(substring($longstring,1,($truncsize)-3),'...')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$longstring"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<!-- function that breaks long strings into smaller ones over several lines (adding specified character at the end and begin of each new lines) -->
<xsl:function name="local:breakstring" as="xs:string">
<xsl:param name="longstring" as="xs:string"/>
<xsl:param name="breakchar" as="xs:string"/>
<xsl:variable name="cursize" as="xs:integer" select="string-length($longstring)"/>
<xsl:variable name="breaksize" as="xs:integer" select="130"/>
<xsl:variable name="breakseq" as="xs:string" select="concat($breakchar,' ',$breakchar)"/>
<xsl:choose>
<xsl:when test="$cursize > $breaksize">
<xsl:value-of select="concat(substring($longstring,1,$breaksize),$breakseq,local:breakstring(substring($longstring,$breaksize+1,$cursize),$breakchar))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$longstring"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<!-- function that breaks long strings into smaller continuation lines to respect the 132 chars limit of the Fortran standard -->
<xsl:function name="local:continuedstring" as="xs:string">
<xsl:param name="longstring" as="xs:string"/>
<xsl:variable name="breakchar" as="xs:string" select="'&'"/>
<xsl:variable name="cursize" as="xs:integer" select="string-length($longstring)"/>
<xsl:variable name="breaksize" as="xs:integer" select="130"/>
<xsl:variable name="breakseq" as="xs:string" select="concat($breakchar,' ',$breakchar)"/>
<xsl:choose>
<xsl:when test="$cursize > $breaksize">
<xsl:value-of select="concat(substring($longstring,1,$breaksize),$breakseq,local:breakstring(substring($longstring,$breaksize+1,$cursize),$breakchar))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$longstring"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<!-- function that breaks long strings for comments that respects the 132 chars limit of the Fortran standard -->
<xsl:function name="local:commentstring" as="xs:string">
<xsl:param name="longstring" as="xs:string"/>
<xsl:variable name="breakchar" as="xs:string" select="'!'"/>
<xsl:variable name="cursize" as="xs:integer" select="string-length($longstring)"/>
<xsl:variable name="breaksize" as="xs:integer" select="130"/>
<xsl:variable name="breakseq" as="xs:string" select="concat($breakchar,' ',$breakchar)"/>
<xsl:choose>
<xsl:when test="$cursize > $breaksize">
<xsl:value-of select="concat(substring($longstring,1,$breaksize),$breakseq,local:breakstring(substring($longstring,$breaksize+1,$cursize),$breakchar))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$longstring"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>