source: main/trunk/ibisph-view/src/main/webapp/xslt/ibis.xslt @ 13450

Last change on this file since 13450 was 13450, checked in by Garth Braithwaite, 3 years ago

admin, view, db, java - temp commit.

File size: 26.4 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet version="2.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
21                <author>Garth Braithwaite</author>
22                <company>Software Technology Group/CDC/Ut Department of Health</company>
23        </ibis:doc>
24
25
26        <!-- ========================= P A R A M E T E R S   and   V A R I A B L E S
27                The java servlet controller code adds ALL URL query request parameters
28                to the XSLT transformation's parameters.  Other special parameters are
29                added as well. 
30
31                Many of the global type parameters are defined within this XSLT file. 
32                The parameters are passed in via the Java XSLT transformation parameter
33                map (and thus are nameed according to the Java model map key value). 
34                For ease of XSLT code maintenance these global XSLT parameters are
35                wrapped within an "ibis." prefix so that it is shown which XSLT file
36                contains the definition.
37        -->
38        <xsl:param name="ibis.adopterTitle" select="'State'"
39                ibis:doc="Value to be used when the XSLT code needs a title usage example
40                        is CP reports that compare community, state, and US.  This should be
41                        overridden in the main ss.xslt with values like 'Utah', 'New Mexico' etc.
42                "
43        />
44
45        <!-- RESOURCE ADDRESSING: The "WebAppURLContextPrefix" parameter is used to
46                explicitly build URL addresses to site related resources.  The value is
47                typically pulled from the servlet context.  The resource's path is relative
48                to the application's root.  The prefix and the relative root address are
49                then concatenated together (along with a separator) to build a complete,
50                explicit path for the resource.  This value can either be hard coded as an
51                XSLT variable or in this case is set as a parameter passed in from the
52                XML/XSLT transformer.
53
54                This full context path value is needed because relative paths do not work
55                for sites that have resources under different directory paths.  E.g. the
56                browser tries to get the resource based on the current resource's path.
57                Relative paths work well with sites that deliver dynamic content using a
58                servlet call that is located at the root level of the application's context.
59                Addressing anything within a site like this using a relative address path
60                works since the current resource's path is the root directory.
61
62                The resource could also be explicitly coded for a given application context
63                (or as the default application - without any context path) but then the code
64                is context deployment dependent and would need changing based on the context
65                the app was deployed under.  So the root "/" can't be used either...
66
67                This solution is messier from an XSLT perspective and in making sure that the
68                XML/XSLT transformer is passed the correct value and inserts the value in as
69                the "WebAppURLContextPrefix" parameter.  However, this is a safe way to ensure
70                that the resources are found while remaining deployment context independent.
71
72                OLDER SOLUTIONS:
73                If the apps context is the root then this value should be '/'.  If it's
74                not then it should be something like: '/ibisph-view/'
75                <xsl:variable name="webappURLContextPrefix" select="'/ibisph-view/'"/>
76                <xsl:variable name="webappURLContextPrefix" select="concat('/', SystemServlet:System.getWebAppContextName(), '/')" xmlns:SystemServlet="org.ibisph.servlets.view"/>
77
78                WORKS - should be a little faster than system properties...
79                <xsl:variable name="webappURLContextPrefix" select="concat('/', SystemServlet:System.getWebAppContextName(), '/')" xmlns:SystemServlet="org.ibisph.servlet.view"/>
80
81                ALSO WORKS:
82                <xsl:variable name="webappURLContext" select="org.ibisph:SystemProperties.getProperty('WebAppContextName')" xmlns:org.ibisph="org.ibisph"/>
83                <xsl:variable name="webappURLContextPrefix" select="concat('/', $webappURLContext, '/')"/>
84
85                TRIED:
86                doesn't blow but doesn't have the correct content path either...
87                select="concat(java:org.springframework.web.context.support.StaticWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, '/')" xmlns:java="http://xml.apache.org/xslt/java"
88
89                ONE LINE PROPERTY CALL - WORKS:
90                <xsl:variable name="webappURLContextPrefix" select="concat('/', org.ibisph:SystemProperties.getProperty('WebAppContextName'), '/')" xmlns:org.ibisph="org.ibisph"/>
91                <xsl:variable name="webappURLContextPrefix" select="org.ibisph:SystemProperties.getProperty('WebAppURLContextPrefix')" xmlns:org.ibisph="org.ibisph"/>
92        -->
93        <xsl:param name="WebAppContextURLPrefix" 
94                ibis:doc="Prefix used/needed for referencing resources within the site."
95        />
96        <xsl:variable name="ibis.urlPrefix" select="$WebAppContextURLPrefix"
97                ibis:doc="WebAppContextURLPrefix access variable that all pages should use. 
98                        Has the 'ibis.' prefix to know what XSLT the variable/param is defined in.
99                "
100        />
101
102        <xsl:param name="WebAppRemoteURLPrefix" select="$ibis.urlPrefix" 
103                ibis:doc="
104                        Prefix used/needed for referencing this apps resources outside the
105                        site.  This value is primarily used for the site search.
106                "
107        />
108        <xsl:variable name="ibis.remoteURLPrefix" select="$WebAppRemoteURLPrefix"
109                ibis:doc="WebAppRemoteURLPrefix access variable that any pages could use. 
110                        Has the 'ibis.' prefix to know what XSLT the variable/param is defined in.
111                "
112        />
113
114        <xsl:param name="UserProfile"
115                ibis:doc="User's XML Profile document.  Must provide a default node type
116                        value so that $UserProfile//AUTHORITIES will work when no user profile
117                        doc is injected.  Otherwise the following type of check is needed:
118                        xsl:with-param name='userAuthorities' select='if(boolean($UserProfile))then $UserProfile//AUTHORITIES else ''
119                "
120        />
121        <xsl:variable name="ibis.userProfile" 
122                ibis:doc="User Profile XML variable that all pages should use.  Has the
123                        'ibis.' prefix to know what XSLT the variable/param is defined in.
124                "
125        >
126                <xsl:choose>
127                        <xsl:when test="not($UserProfile)">
128                                <FULL_NAME>Not Authenticated</FULL_NAME>
129                        </xsl:when>
130                        <xsl:when test="exists($UserProfile/USER)">
131                                <xsl:copy-of select="$UserProfile/USER/*"/>
132                        </xsl:when>
133                        <xsl:when test="exists($UserProfile)">
134                                <xsl:copy-of select="$UserProfile"/>
135                        </xsl:when>
136                        <xsl:otherwise>
137                                <FULL_NAME>Not Authenticated</FULL_NAME>
138                        </xsl:otherwise>
139                </xsl:choose>
140        </xsl:variable>
141        <xsl:param name="ibis.userAuthorities" select="$ibis.userProfile/AUTHORITIES"
142                ibis:doc="Variable used by the ibis:hasAuthority function or can be used directly."
143        />
144
145
146        <xsl:param name="XMLModifedDate"
147                ibis:doc="Parameter which is set via the Java model code so that the
148                        resultant page can display the XML file's modified date/time."
149        />
150        <xsl:variable name="ibis.XMLModifedDate" 
151                select="if(string-length($XMLModifedDate) = 0) then //ibis:doc/versions/version[1]/date else $XMLModifedDate"
152                ibis:doc="Variable that wraps the 'XMLModifedDate' parameter so that we
153                        know where this variable/parameter is defined.  If the parameter
154                        value is not specified then the parameter defaults to selecting the
155                        XML document's ibis:doc version date."
156        />
157
158
159        <!-- tried all sorts of patterns for time zone [ZN,*-3] [ZMST], [ZN,MST] etc... -->
160        <xsl:param name="ibis.dateTimeFormatPicture" select="'[FNn,*-3], [D01] [MNn] [Y0001] [H]:[m]:[s]'"/>
161        <xsl:param name="ibis.dateFormatPicture"     select="'[FNn,*-3], [D01] [MNn] [Y0001]'"/>
162        <xsl:param name="ibis.timeFormatPicture"     select="'[H]:[m]:[s]'"/>
163
164
165        <!-- ===================================================== G E N E R A L -->
166        <xsl:function name="ibis:isFirstLetter_T_or_Y_or_X" as="xs:boolean" 
167                ibis:doc="Returns 'true' if the text is 'T'rue, 'Y'es, or 'x' - 'false' otherwise (case insensitive)."
168        >
169                        <!-- can also be done by regexp -->
170                        <xsl:param name="text" ibis:doc="Source text to be tested"/>
171                        <xsl:variable name="firstLetter" select="lower-case(substring(normalize-space($text),1,1))"/>
172                        <xsl:value-of select="if(($firstLetter='y') or ($firstLetter='t') or ($firstLetter='x')) then true() else false()"/>
173        </xsl:function>
174
175        <xsl:function name="ibis:isAuthenticated" as="xs:boolean"
176                ibis:doc="localizes checking the UserProfile param exists as a node. 
177                        Note the not not is needed to handle string vs node xslt problem. 
178                        Exists returns true for any/all defined variables/params.  not
179                        handles a null or zero len string as false and also handles an
180                        empty node set as false.
181                "
182        >
183                <xsl:value-of select="not(not($UserProfile))"/>
184        </xsl:function>
185
186        <xsl:function name="ibis:hasAuthorities" as="xs:boolean"
187                ibis:doc="localizes checking if the user is authenticated and if so if
188                        they have an authority (secure type user).
189                "
190        >
191                <xsl:value-of select="if(ibis:isAuthenticated()) then exists($ibis.userAuthorities/AUTHORITY) else false()"/>
192        </xsl:function>
193
194        <xsl:function name="ibis:hasAuthority" as="xs:boolean"
195                ibis:doc="localizes checking the user authorities against the passed in
196                        AUTHORITY.  If an AUTHORITY's text() matches one of the user's
197                        AUTHORITY values then true is returned.  Else false is returned. 
198                        This function is dependent on the global UserAuthorities param
199                        which needs to be injected via the java controller/transformer code.
200                "
201        >
202                <xsl:param name="authority" ibis:doc="AUTHORITY value to be tested for."/>
203                <xsl:value-of select="not(exists($authority)) or exists($ibis.userAuthorities[AUTHORITY = $authority])"/>
204        </xsl:function>
205
206
207
208        <!-- =========================== F O R M A T T I N G   F U N C T I O N S -->
209        <xsl:decimal-format name="ibis.defaultDecimalNumberFormat" NaN=" * " zero-digit="0"
210                ibis:doc="Default format for the 'ibis:formatNumber function."
211        />
212        <xsl:param name="ibis.defaultNumericPicture" select="',##0.##'"
213                ibis:doc="default number picture format.  Done as a variable so that
214                site specefic templates can override."
215        />
216
217        <!-- XSLT 2.0 does NOT provide for any literals inside the picture string that are
218        defined as a format character.  So to embed a "%" sign without actually multiplying
219        the value by 100 a format picture in XSLT 1.0 could simply be "#.#'%'".  In XSLT 2
220        it shows the #.#'%' with the value multiplied.  The way to get around this is to
221        change the % character with the decimal numeric format.  However some value will
222        need to be multiplied so the easiest way to deal with this is to simply replace
223        '%' with '' and add the % character to the end of the string.
224        See: http://www.w3.org/TR/xslt20/#defining-decimal-format.
225
226        Below is an example of how to redefine the % character:
227        <xsl:decimal-format name="ibis.percentSuffixDecimalNumberFormat" NaN=" * " zero-digit="0" percent="^"
228                ibis:doc="Decimal format that redefines the % character so it doesn't interfere with the
229                        format picture string."
230        />
231        -->
232        <xsl:param name="ibis.numberFormatQuotedPercentString" ibis:doc="Percentage
233                suffix signature to be searched and replaced with null and which signals
234                to concat the % sign to the end of the formatted value.  This value should
235                match the value used by the admin system to signify that a % should be
236                added as a numeric suffix.  If the % is standalone then the value should
237                be of the form 0.xx which will then cause the format number code to mult
238                by 100 and add the %.  Otherwise the value will be displayed 100x's too
239                large (xx00.00%)."
240        >'%'</xsl:param>
241
242
243
244        <xsl:function name="ibis:getJavaScriptValue" as="xs:string"
245                ibis:doc="If value exists then returns value otherwise null."
246        >
247                <xsl:param name="value" ibis:doc="Value to be tested."/>
248<!--
249                <xsl:value-of select="if(starts-with($value, '*') or (string-length($value) = 0))then 'null' else $value"/>
250-->
251                <xsl:value-of select="if((string(number($value)) = 'NaN') or (string-length($value) = 0))then 'null' else $value"/>
252        </xsl:function>
253
254
255
256        <xsl:function name="ibis:getFormattedNumber" as="xs:string"
257                ibis:doc="Numeric formatter that localizes the handling of numeric values.
258                If a format is not specified then the common.defaultFormat is used."
259        >
260                <xsl:param name="number" ibis:doc="Value to be formatted.  If the value is
261                        non numeric then that value will be returned.  Otherwise the format
262                        picture will be applied."
263                />
264                <xsl:param name="picture" ibis:doc="Format to be applied.  If '' is specified
265                        then the ibis.defaultNumericPicture is used.  If 'none' is specified then
266                        the actual value passed in will be used."
267                />
268                <xsl:value-of select="ibis:getFormattedValue($number, $picture, '')"/>
269        </xsl:function>
270
271
272        <xsl:function name="ibis:getFormattedValue" as="xs:string"
273                ibis:doc="Numeric formatter that localizes the handling of numeric values
274                        with a default null value.  If a format is not specified then the
275                        common.defaultFormat is used.
276                "
277        >
278                <xsl:param name="number" ibis:doc="Value to be formatted.  If the value is
279                        non numeric then that value will be returned.  Otherwise the format
280                        picture will be applied."
281                />
282                <xsl:param name="picture" ibis:doc="Format to be applied.  If '' is specified
283                        then the ibis.defaultNumericPicture is used.  If 'none' is specified then
284                        the actual value passed in will be used."
285                />
286                <xsl:param name="valueIfNull" 
287                        ibis:doc="Value to use if the number param value is not something."
288                />
289
290<!--
291<xsl:message select="'using the picture'"/>
292<xsl:message select="'when percent'"/>
293<xsl:message select="'otherwise using default picture'"/>
294<xsl:message select="concat('ibis:getFormattedValue - number: ', $number, ', value: ', $value, ', Picture: ', $picture, ', valueIfNull: ', $valueIfNull)"/>
295-->
296                <xsl:variable name="value">
297                        <xsl:choose>
298                                <xsl:when test="count($number) &gt; 1">
299<xsl:message select="'ibis:getFormattedValue - number is a sequence of the following values: '"/>
300<xsl:message select="$number"/>
301                                        -999999
302                                </xsl:when>
303                                <xsl:when test="(string-length(string($number)) != 0) or not($valueIfNull)">
304                                        <xsl:value-of select="$number"/>
305                                </xsl:when>
306                                <xsl:otherwise>
307                                        <xsl:value-of select="$valueIfNull"/>
308                                </xsl:otherwise>
309                        </xsl:choose>
310                </xsl:variable>
311                <xsl:choose>
312                        <xsl:when test="$picture='none'"><xsl:value-of select="$value"/></xsl:when>
313
314                        <xsl:when test="string(number($value))='NaN'"><xsl:value-of select="$value"/></xsl:when>
315
316                        <!-- put this in because UT had some messed up QM configurations -->
317                        <xsl:when test="count($picture) &gt; 1">
318                                <xsl:message select="'***ibis:getFormattedValue - TOO MANY XSLT FORMATS***, picture:'"/> 
319                                <xsl:message select="$picture"/>
320                                <xsl:value-of select="'CONTENT ERROR - TOO MANY XSLT FORMATS - PLEASE CONTACT US!!!'"/>
321                        </xsl:when>
322
323                        <!-- if format string was passed in, then check for the '%' string.
324                                If found then need to replace with a null and add the % to the
325                                end.  See comments about about how XSLT 2.0 does not allow for
326                                literals that match one of the defined format control chars
327                                without effecting formatting.
328
329                                Else if the string doesn't contain the special percent character
330                                suffix signature then simply use as is.
331                        -->
332                        <xsl:when test="string-length($picture) != 0">
333                                <xsl:choose>
334                                        <xsl:when test="contains($picture, $ibis.numberFormatQuotedPercentString)">
335                                                <xsl:value-of select="concat(format-number($value, replace($picture,$ibis.numberFormatQuotedPercentString,''), 'ibis.defaultDecimalNumberFormat'), '%')"/>
336                                        </xsl:when>
337                                        <xsl:otherwise>
338                                                <xsl:value-of select="format-number($value, $picture, 'ibis.defaultDecimalNumberFormat')"/>
339                                        </xsl:otherwise>
340                                </xsl:choose>
341                        </xsl:when>
342
343                        <xsl:otherwise>
344                                <xsl:value-of select="format-number($value, $ibis.defaultNumericPicture, 'ibis.defaultDecimalNumberFormat')"/>
345                        </xsl:otherwise>
346                </xsl:choose>
347        </xsl:function>
348
349
350        <!-- See: http://stackoverflow.com/questions/16892344/convert-a-string-to-date-format-in-xslt -->
351        <xsl:function name="ibis:getFormattedDateTime" as="xs:string" 
352                ibis:doc="Localizes date and time formatting.  Uses the ibis.dateTimeFormatPicture param."
353        >
354                <xsl:param name="dateTime" ibis:doc="DateTime value to be formatted. 
355                        Call with current-dateTime() to get current system date and time."
356                />
357                <xsl:value-of select="format-dateTime($dateTime, $ibis.dateTimeFormatPicture)"/>
358        </xsl:function>
359        <xsl:function name="ibis:getFormattedDate" as="xs:string" 
360                ibis:doc="Localizes date formatting.  Uses the ibis.dateFormatPicture param."
361        >
362                <xsl:param name="date" ibis:doc="Date value to be formatted.  Call with
363                        current-date() to get current system date."
364                />
365                <xsl:value-of select="format-date($date, $ibis.dateFormatPicture)"/>
366        </xsl:function>
367        <xsl:function name="ibis:getFormattedTime" as="xs:string" 
368                ibis:doc="Localizes time formatting.  Uses the ibis.timeFormatPicture param."
369        >
370                <xsl:param name="time" ibis:doc="Time value to be formatted.  Call with
371                        current-time() to get current system time."
372                />
373                <xsl:value-of select="format-time($time, $ibis.timeFormatPicture)"/>
374        </xsl:function>
375
376
377<xsl:function name="ibis:getCompleteIndicatorViewTitle" as="xs:string"
378        ibis:doc="Builds a complete view title."
379>
380        <xsl:param name="indicatorView" ibis:doc="Indicator Profile View to be used to build the title from."/>
381        <xsl:value-of select="concat($indicatorView/TITLE, ' complete IPV title func ', $indicatorView/PERIOD_TITLE)"/> 
382</xsl:function>
383<xsl:function name="ibis:getPartialIndicatorViewTitle" as="xs:string"
384        ibis:doc="Builds the view's partial, most specific title."
385>
386        <xsl:param name="indicatorView" ibis:doc="Indicator Profile View to be used to build the title from."/>
387        <xsl:value-of select="concat($indicatorView/TITLE, ' this is IP IPV struct ', $indicatorView/DIMENSIONS/PERIOD/DIMENSION/TITLE)"/> 
388</xsl:function>
389
390
391
392        <!-- ===================================== M A T C H   C O P Y   M O D E -->
393        <xsl:template match="*" mode="ibis.copy"
394                ibis:doc="Provides the ability to do an apply-templates to a copy-of of
395                        an element (some call this an 'identity transformation').  This
396                        allows for a deep copy with processing (which also allows ibis.include
397                        to be processed)."
398        >
399                <!-- Used the new element and copied the attributes, text, and sub
400                        elements so that any namespace attributes would not be copied.
401                        <xsl:apply-templates select="@*" mode="ibis.copy"/>
402<xsl:message>IBIS.COPY</xsl:message>
403                -->
404                <xsl:element name="{local-name()}">
405                        <xsl:apply-templates select="current()/@* | current()/text() | current()/*"  mode="ibis.copy"/>
406                </xsl:element>
407        </xsl:template>
408
409
410        <xsl:template match="text()" mode="ibis.copy" ibis:doc="copies the text.">
411<!-- trims the text - not really needed for wiki - biggest issue with weird text
412        was page indent on and extra line spacing etc.
413                <xsl:value-of select="replace(., '^\s+|\s+$', '')"/>
414-->
415                <xsl:value-of select="."/>
416        </xsl:template>
417
418        <!-- Match Copy Mode was lifted from the page.xslt in 4/2007.  That code has a note
419                about 4-18-06: removed template code and replaced with the mode="ibis.copy"
420                templates above because the namespace was being copied into some HTML elements.
421                See: http://www.stylusstudio.com/xsllist/200008/post50850.html
422        -->
423
424        <!-- The following templates are used to help page developers avoid having to
425                hard code the deployment specific context into the URL path of IBIS related
426                web pages.  Example: If the app is deployed into a context called "ibisph-view"
427                and your page is "http://localhost/ibisph-view/about/welcome.html" and it
428                references an image that is under the "webapps/ibisph-view/image" directory
429                it would need a url like "src='/ibisph-view/image/the_image.gif'" to properly
430                get the correct resource.  A relative path of "src='image/the_image.gif'"
431                would cause the browser to request "http://localhost/ibisph-view/about/image/the_image.gif",
432                while a path of "src='/image/the_image.gif'" would request this resource
433                "http://localhost/image/the_image.gif" both of which are wrong.  If the context
434                path is coded so that the resource's URL is explicitly defined then a dependency
435                exists between the web pages and the context which makes the deployment not
436                as portable.  Since the web app context path is needed by the XSLTs to build
437                the correct HTML code it is implemented here to help static page development.
438                Relative links work fine if the resource it within the same directory e.g.
439                if the "about/welcome.html" page contains a relative link to the "about/content_usage.html"
440                page then all is well.  The "about/welcome.html" page can NOT contains a relative
441                link to the "indicator/introduction.html" as it will not find the correct
442                directory.
443        -->
444
445        <!-- Local IBIS URL adjustment templates.  These templates simply add the web application's
446                context path as a prefix to the link reference attribute.
447        -->
448        <xsl:template match="@ibis:href" mode="ibis.copy" ibis:doc="Inner 'ibis:href' template that adds the 'WebAppURLContextPrefix' to the 'href' attribute.">
449                <xsl:attribute name="href" select="concat($ibis.urlPrefix, .)"/>
450        </xsl:template>
451        <xsl:template match="@ibis:src" mode="ibis.copy" ibis:doc="Inner 'ibis:src' template that adds the 'WebAppURLContextPrefix' to the 'src' attribute.">
452                <xsl:attribute name="src" select="concat($ibis.urlPrefix, .)"/>
453        </xsl:template>
454        <xsl:template match="@ibis:action" mode="ibis.copy" ibis:doc="Inner 'ibis:action' template that adds the 'WebAppURLContextPrefix' to the 'action' attribute.">
455                <xsl:attribute name="action" select="concat($ibis.urlPrefix, .)"/>
456        </xsl:template>
457
458        <xsl:template match="ibis:urlPrefix" mode="ibis.copy" ibis:doc="Mechanism that allows the HTML_CONTENTN PAGE type XML content to get the ibis:urlPrefix value.  This is useful for pages that have javascript that need this value.">
459                <xsl:value-of select="$ibis.urlPrefix"/>
460        </xsl:template>
461
462        <xsl:template match="@*" mode="ibis.copy" ibis:doc="Inner '@*' template that copies the non ibis: namespace attributes">
463                <xsl:copy-of select="."/>
464        </xsl:template>
465
466        <xsl:template match="@ibis:doc" mode="ibis.copy" ibis:doc="Eats ibis:doc attribute"/>
467        <xsl:template match="ibis:doc"  mode="ibis.copy" ibis:doc="Eats ibis:doc element"/>
468
469
470
471        <!-- =============================== I B I S   I N C L U D E   M A T C H -->
472        <xsl:template match="ibis:include" mode="#all"
473                ibis:doc="
474                        'ibis:' namespace specific match template which opens
475                        the document via the 'href' attribute and does an 'apply-template'
476                        operation on its contents to process sub 'ibis:include' statements
477                        and to copy its text, attributes, and processing instructions.
478
479                        Provides the IBISPH system the ability to do simple xinclude
480                        type operations.  As of 6-2004 the xerces parser 2.6.x has xinclude support
481                        but it must be configured when starting the Java JVM or with Java system
482                        properties.  Since this might not be an option for some deployments (like
483                        Utah's state wide ITS app server) the system wide property solution is not
484                        an option.  To handle being able to deploy into environments where we don't
485                        know which XSL engine is being used this two step xinclude processing
486                        was developed.  This option is not nearly as seamless and requires that
487                        the java controller do 2 transformations - the first being this xinclude
488                        type transformation with the second being the normal desired page type
489                        transformation.  Another option was to do the xinclude template inside the
490                        XSLT as a variable then use that variable for all XML nodes.  This option
491                        appears to be somewhat slow but it is seamless.
492
493                        See: http://www.sagehill.net/docbookxsl/Xinclude.html
494
495                        This page simply copies the contents of the base document and when it
496                        hits the ibis:include element it opens the document with an XSLT document
497                        call based on the href attribute of the xi:include element.  These
498                        elements are then copied into the source document.
499
500                        NOTE: the included document MUST be a valid XML file e.g. well
501                        formed with a root/master/parent element.
502
503                        If an children-only-flag attribute exists in the element then only
504                        only the sub elements and child text are included and processed.
505                        This is useful for including an element's text without having to
506                        include its root element.
507                "
508        >
509<!-- this only copies child content - skips container element.
510                <xsl:copy>
511                        <xsl:apply-templates select="document(@href, /)" mode="ibis.include"/>
512                </xsl:copy>
513<xsl:message select="document(@href, /)"/>
514<xsl:message select="concat('FOUND IBIS INCLUDE: ', @href)"/>
515
516                <xsl:choose>
517                        <xsl:when test="exists(@include-children-only)">
518                                <xsl:apply-templates select="document(@href, /)/(text() | *)" mode="ibis.copy"/>
519                        </xsl:when>
520                        <xsl:otherwise>
521                                <xsl:apply-templates select="document(@href, /)" mode="ibis.copy"/>
522                        </xsl:otherwise>
523                </xsl:choose>
524 -->
525                <xsl:apply-templates select=
526                        "if(exists(@children-only-flag))
527                                then document(@href, /)/(text() | *)
528                                else document(@href, /)
529                        "
530                        mode="ibis.copy"
531                />
532        </xsl:template>
533
534</xsl:stylesheet>
535
536
537
538<!-- left here for posterity - a way to totally replace an element...
539        <xsl:template match="ibis:a">
540                <xsl:element name="a">
541                        <xsl:attribute name="href"><xsl:value-of select="concat($ibis.urlPrefix, @href)"/></xsl:attribute>
542                        <xsl:copy-of select="attribute::*[name() != 'href']"/>
543                        <xsl:apply-templates select="current()/text() | current()/*"/>
544                </xsl:element>
545        </xsl:template>
546-->
547<!-- img elements do not contain any text or other elements so it doesn't need
548                to process/worry about anything other than it's attributes.
549        <xsl:template match="ibis:img">
550                <img>
551                        <xsl:attribute name="src"><xsl:value-of select="concat($ibis.urlPrefix, @src)"/></xsl:attribute>
552                        <xsl:copy-of select="attribute::*[name() != 'src']"/>
553                </img>
554        </xsl:template>
555-->
556<!-- Since the a element can contain images, divs etc need to process text
557                and elements contained within.
558        <xsl:template match="ibis:form">
559                <xsl:element name="form">
560                        <xsl:attribute name="action"><xsl:value-of select="concat($ibis.urlPrefix, @action)"/></xsl:attribute>
561                        <xsl:copy-of select="attribute::*[name() != 'action']"/>
562                        <xsl:apply-templates select="current()/text() | current()/*"/>
563                </xsl:element>
564        </xsl:template>
565-->
566
567<!-- ============================= End of File ============================= -->
568
Note: See TracBrowser for help on using the repository browser.