1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
2 | |
---|
3 | <xsl:stylesheet version="3.0" |
---|
4 | xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:xs ="http://www.w3.org/2001/XMLSchema" |
---|
6 | xmlns:ibis="http://www.ibisph.org" |
---|
7 | |
---|
8 | exclude-result-prefixes="ibis xs xsl" |
---|
9 | > |
---|
10 | |
---|
11 | <ibis:doc> |
---|
12 | <name>ibis</name> |
---|
13 | <summary>Library of generic/common ibis specific functions</summary> |
---|
14 | <description> |
---|
15 | Library of generic/common IBIS specific global variables and functions. |
---|
16 | These functions are auto included in all pages because this file is |
---|
17 | imported by _main.xslt which is a part of all IBISPH-View system HTML |
---|
18 | output pages. |
---|
19 | </description> |
---|
20 | </ibis:doc> |
---|
21 | |
---|
22 | <xsl:import href="_ibis-format.xslt"/> |
---|
23 | <xsl:import href="_ibis-title.xslt"/> |
---|
24 | <xsl:import href="_ibis-path.xslt"/> |
---|
25 | <xsl:import href="_ibis-user.xslt"/> |
---|
26 | <xsl:import href="_ibis-include.xslt"/> |
---|
27 | |
---|
28 | |
---|
29 | <!-- ========================= M I S C P A R A M S / F U N C T I O N S --> |
---|
30 | <xsl:function name="ibis:isNumeric" as="xs:boolean" |
---|
31 | ibis:doc="Returns 'true' if the value numeric, 'false' otherwise." |
---|
32 | > |
---|
33 | <!-- Bunch of ways to do this: |
---|
34 | number($value) = 'NaN' - doesn't work because can't compare real number to string. |
---|
35 | string($value) != 'NaN' - requires value processed via number($value) first. |
---|
36 | ($value =0) and not(not($value) - requires number conversion first. |
---|
37 | $value*1 = $value - requires number conversion first. |
---|
38 | |
---|
39 | EASIEST: |
---|
40 | xmlns:xs ="http://www.w3.org/2001/XMLSchema" |
---|
41 | $value castable as xs:decimal |
---|
42 | <xsl:value-of select="$value castable as xs:decimal"/> |
---|
43 | NOTE: double and float are scientic notation and it doesn't pick |
---|
44 | up NaN so can't use that test. |
---|
45 | |
---|
46 | OTHERS: |
---|
47 | <xsl:value-of select="'NaN' != string($convertedValue)"/> |
---|
48 | <xsl:value-of select="(0 = $convertedValue) or not(not($convertedValue))"/> |
---|
49 | --> |
---|
50 | <xsl:param name="value" ibis:doc="Source value to be tested"/> |
---|
51 | <xsl:variable name="convertedValue" select="number($value)"/> |
---|
52 | <xsl:value-of select="ibis:_isNumeric($convertedValue)"/> |
---|
53 | </xsl:function> |
---|
54 | |
---|
55 | <xsl:function name="ibis:_isNumeric" as="xs:boolean" |
---|
56 | ibis:doc="Returns 'true' if the numeric value is numeric, 'false' otherwise." |
---|
57 | > |
---|
58 | <xsl:param name="numericValue" ibis:doc="Source value to be tested"/> |
---|
59 | <xsl:value-of select="($numericValue = 0) or not(not($numericValue))"/> |
---|
60 | </xsl:function> |
---|
61 | |
---|
62 | |
---|
63 | <xsl:function name="ibis:isFirstLetter_T_or_Y_or_X" as="xs:boolean" |
---|
64 | ibis:doc="Returns 'true' if the text is 'T'rue, 'Y'es, or 'x' - 'false' otherwise (case insensitive)." |
---|
65 | > |
---|
66 | <!-- can also be done by regexp --> |
---|
67 | <xsl:param name="text" ibis:doc="Source text to be tested"/> |
---|
68 | <xsl:variable name="firstLetter" select="lower-case(substring(normalize-space($text),1,1))"/> |
---|
69 | <xsl:value-of select="if(($firstLetter='y') or ($firstLetter='t') or ($firstLetter='x')) then true() else false()"/> |
---|
70 | </xsl:function> |
---|
71 | |
---|
72 | |
---|
73 | <xsl:param name="PrinterFriendly" ibis:doc="The 'PrinterFriendly' parameter |
---|
74 | controls which main root processing template is called. This enables the |
---|
75 | system to easily allow for all pages to be made printer friendly. This |
---|
76 | parameter is set via the Java controller code and comes from the HTTP |
---|
77 | request URL." |
---|
78 | /> |
---|
79 | <xsl:function name="ibis:isPrinterFriendly" as="xs:boolean" |
---|
80 | ibis:doc="localizes and hides the 'PrinterFriendly' parameter and isTYZ code." |
---|
81 | > |
---|
82 | <xsl:value-of select="ibis:isFirstLetter_T_or_Y_or_X($PrinterFriendly) or ($PrinterFriendly = 'bw') or ($PrinterFriendly = 'BW')"/> |
---|
83 | </xsl:function> |
---|
84 | |
---|
85 | |
---|
86 | <xsl:function name="ibis:getJavaScriptValue" as="xs:string" |
---|
87 | ibis:doc="If value exists then returns value otherwise null." |
---|
88 | > |
---|
89 | <xsl:param name="value" ibis:doc="Value to be tested."/> |
---|
90 | <xsl:value-of select="if((string-length($value) != 0) and (string(number($value)) != 'NaN')) then $value else 'null'"/> |
---|
91 | </xsl:function> |
---|
92 | |
---|
93 | |
---|
94 | <xsl:function name="ibis:textNodesToJSONArray" |
---|
95 | ibis:doc="Builds a quoted, comma separated values json string." |
---|
96 | > |
---|
97 | <xsl:param name="textNodes" ibis:doc="nodes to convert."/> |
---|
98 | <xsl:variable name="textNodesCount" select="count($textNodes)"/> |
---|
99 | <!-- GARTH TODO: |
---|
100 | <xsl:message select="$textNodesCount"/> |
---|
101 | --> |
---|
102 | <xsl:text>[</xsl:text> |
---|
103 | <xsl:if test="1 = $textNodesCount">"<xsl:value-of select="$textNodes"/>"</xsl:if> |
---|
104 | <xsl:if test="1 < $textNodesCount"> |
---|
105 | <xsl:for-each select="$textNodes/text()"> |
---|
106 | <xsl:text/><xsl:if test="position() != 1">,</xsl:if>"<xsl:value-of select="."/>"<xsl:text/> |
---|
107 | </xsl:for-each> |
---|
108 | </xsl:if> |
---|
109 | <xsl:text>]</xsl:text> |
---|
110 | </xsl:function> |
---|
111 | |
---|
112 | </xsl:stylesheet> |
---|
113 | |
---|
114 | <!-- ============================= End of File ============================= --> |
---|
115 | |
---|