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

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

db, java, xslt - cleaned up the dims to iv sql. Based inserts on actual IVV records because had duplicates. Also based on active records which does not quite line up with production NM data but it appears to check out.

File size: 26.6 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:choose>
252                        <xsl:when test="1 = count($value)">
253                                <xsl:value-of select="if((string(number($value)) = 'NaN') or (string-length($value) = 0))then 'null' else $value"/>
254                        </xsl:when>
255                        <xsl:otherwise>null</xsl:otherwise>
256                </xsl:choose>
257        </xsl:function>
258
259
260
261        <xsl:function name="ibis:getFormattedNumber" as="xs:string"
262                ibis:doc="Numeric formatter that localizes the handling of numeric values.
263                If a format is not specified then the common.defaultFormat is used."
264        >
265                <xsl:param name="number" ibis:doc="Value to be formatted.  If the value is
266                        non numeric then that value will be returned.  Otherwise the format
267                        picture will be applied."
268                />
269                <xsl:param name="picture" ibis:doc="Format to be applied.  If '' is specified
270                        then the ibis.defaultNumericPicture is used.  If 'none' is specified then
271                        the actual value passed in will be used."
272                />
273                <xsl:value-of select="ibis:getFormattedValue($number, $picture, '')"/>
274        </xsl:function>
275
276
277        <xsl:function name="ibis:getFormattedValue" as="xs:string"
278                ibis:doc="Numeric formatter that localizes the handling of numeric values
279                        with a default null value.  If a format is not specified then the
280                        common.defaultFormat is used.
281                "
282        >
283                <xsl:param name="number" ibis:doc="Value to be formatted.  If the value is
284                        non numeric then that value will be returned.  Otherwise the format
285                        picture will be applied."
286                />
287                <xsl:param name="picture" ibis:doc="Format to be applied.  If '' is specified
288                        then the ibis.defaultNumericPicture is used.  If 'none' is specified then
289                        the actual value passed in will be used."
290                />
291                <xsl:param name="valueIfNull" 
292                        ibis:doc="Value to use if the number param value is not something."
293                />
294
295<!--
296<xsl:message select="'using the picture'"/>
297<xsl:message select="'when percent'"/>
298<xsl:message select="'otherwise using default picture'"/>
299<xsl:message select="concat('ibis:getFormattedValue - number: ', $number, ', value: ', $value, ', Picture: ', $picture, ', valueIfNull: ', $valueIfNull)"/>
300-->
301                <xsl:variable name="value">
302                        <xsl:choose>
303                                <xsl:when test="count($number) &gt; 1">
304<!--
305<xsl:message select="'ibis:getFormattedValue - number is a sequence of the following values: '"/>
306<xsl:message select="$number"/>
307-->
308                                        -999999
309                                </xsl:when>
310                                <xsl:when test="(string-length(string($number)) != 0) or not($valueIfNull)">
311                                        <xsl:value-of select="$number"/>
312                                </xsl:when>
313                                <xsl:otherwise>
314                                        <xsl:value-of select="$valueIfNull"/>
315                                </xsl:otherwise>
316                        </xsl:choose>
317                </xsl:variable>
318                <xsl:choose>
319                        <xsl:when test="$picture='none'"><xsl:value-of select="$value"/></xsl:when>
320
321                        <xsl:when test="string(number($value))='NaN'"><xsl:value-of select="$value"/></xsl:when>
322
323                        <!-- put this in because UT had some messed up QM configurations -->
324                        <xsl:when test="count($picture) &gt; 1">
325                                <xsl:message select="'***ibis:getFormattedValue - TOO MANY XSLT FORMATS***, picture:'"/> 
326                                <xsl:message select="$picture"/>
327                                <xsl:value-of select="'CONTENT ERROR - TOO MANY XSLT FORMATS - PLEASE CONTACT US!!!'"/>
328                        </xsl:when>
329
330                        <!-- if format string was passed in, then check for the '%' string.
331                                If found then need to replace with a null and add the % to the
332                                end.  See comments about about how XSLT 2.0 does not allow for
333                                literals that match one of the defined format control chars
334                                without effecting formatting.
335
336                                Else if the string doesn't contain the special percent character
337                                suffix signature then simply use as is.
338                        -->
339                        <xsl:when test="string-length($picture) != 0">
340                                <xsl:choose>
341                                        <xsl:when test="contains($picture, $ibis.numberFormatQuotedPercentString)">
342                                                <xsl:value-of select="concat(format-number($value, replace($picture,$ibis.numberFormatQuotedPercentString,''), 'ibis.defaultDecimalNumberFormat'), '%')"/>
343                                        </xsl:when>
344                                        <xsl:otherwise>
345                                                <xsl:value-of select="format-number($value, $picture, 'ibis.defaultDecimalNumberFormat')"/>
346                                        </xsl:otherwise>
347                                </xsl:choose>
348                        </xsl:when>
349
350                        <xsl:otherwise>
351                                <xsl:value-of select="format-number($value, $ibis.defaultNumericPicture, 'ibis.defaultDecimalNumberFormat')"/>
352                        </xsl:otherwise>
353                </xsl:choose>
354        </xsl:function>
355
356
357        <!-- See: http://stackoverflow.com/questions/16892344/convert-a-string-to-date-format-in-xslt -->
358        <xsl:function name="ibis:getFormattedDateTime" as="xs:string" 
359                ibis:doc="Localizes date and time formatting.  Uses the ibis.dateTimeFormatPicture param."
360        >
361                <xsl:param name="dateTime" ibis:doc="DateTime value to be formatted. 
362                        Call with current-dateTime() to get current system date and time."
363                />
364                <xsl:value-of select="format-dateTime($dateTime, $ibis.dateTimeFormatPicture)"/>
365        </xsl:function>
366        <xsl:function name="ibis:getFormattedDate" as="xs:string" 
367                ibis:doc="Localizes date formatting.  Uses the ibis.dateFormatPicture param."
368        >
369                <xsl:param name="date" ibis:doc="Date value to be formatted.  Call with
370                        current-date() to get current system date."
371                />
372                <xsl:value-of select="format-date($date, $ibis.dateFormatPicture)"/>
373        </xsl:function>
374        <xsl:function name="ibis:getFormattedTime" as="xs:string" 
375                ibis:doc="Localizes time formatting.  Uses the ibis.timeFormatPicture param."
376        >
377                <xsl:param name="time" ibis:doc="Time value to be formatted.  Call with
378                        current-time() to get current system time."
379                />
380                <xsl:value-of select="format-time($time, $ibis.timeFormatPicture)"/>
381        </xsl:function>
382
383
384<xsl:function name="ibis:getCompleteIndicatorViewTitle" as="xs:string"
385        ibis:doc="Builds a complete view title."
386>
387        <xsl:param name="indicatorView" ibis:doc="Indicator Profile View to be used to build the title from."/>
388        <xsl:value-of select="concat($indicatorView/TITLE, ' complete IPV title func ', $indicatorView/PERIOD_TITLE)"/> 
389</xsl:function>
390<xsl:function name="ibis:getPartialIndicatorViewTitle" as="xs:string"
391        ibis:doc="Builds the view's partial, most specific title."
392>
393        <xsl:param name="indicatorView" ibis:doc="Indicator Profile View to be used to build the title from."/>
394        <xsl:value-of select="concat($indicatorView/TITLE, ' this is IP IPV struct ', $indicatorView/DIMENSIONS/PERIOD/DIMENSION/TITLE)"/> 
395</xsl:function>
396
397
398
399        <!-- ===================================== M A T C H   C O P Y   M O D E -->
400        <xsl:template match="*" mode="ibis.copy"
401                ibis:doc="Provides the ability to do an apply-templates to a copy-of of
402                        an element (some call this an 'identity transformation').  This
403                        allows for a deep copy with processing (which also allows ibis.include
404                        to be processed)."
405        >
406                <!-- Used the new element and copied the attributes, text, and sub
407                        elements so that any namespace attributes would not be copied.
408                        <xsl:apply-templates select="@*" mode="ibis.copy"/>
409<xsl:message>IBIS.COPY</xsl:message>
410                -->
411                <xsl:element name="{local-name()}">
412                        <xsl:apply-templates select="current()/@* | current()/text() | current()/*"  mode="ibis.copy"/>
413                </xsl:element>
414        </xsl:template>
415
416
417        <xsl:template match="text()" mode="ibis.copy" ibis:doc="copies the text.">
418<!-- trims the text - not really needed for wiki - biggest issue with weird text
419        was page indent on and extra line spacing etc.
420                <xsl:value-of select="replace(., '^\s+|\s+$', '')"/>
421-->
422                <xsl:value-of select="."/>
423        </xsl:template>
424
425        <!-- Match Copy Mode was lifted from the page.xslt in 4/2007.  That code has a note
426                about 4-18-06: removed template code and replaced with the mode="ibis.copy"
427                templates above because the namespace was being copied into some HTML elements.
428                See: http://www.stylusstudio.com/xsllist/200008/post50850.html
429        -->
430
431        <!-- The following templates are used to help page developers avoid having to
432                hard code the deployment specific context into the URL path of IBIS related
433                web pages.  Example: If the app is deployed into a context called "ibisph-view"
434                and your page is "http://localhost/ibisph-view/about/welcome.html" and it
435                references an image that is under the "webapps/ibisph-view/image" directory
436                it would need a url like "src='/ibisph-view/image/the_image.gif'" to properly
437                get the correct resource.  A relative path of "src='image/the_image.gif'"
438                would cause the browser to request "http://localhost/ibisph-view/about/image/the_image.gif",
439                while a path of "src='/image/the_image.gif'" would request this resource
440                "http://localhost/image/the_image.gif" both of which are wrong.  If the context
441                path is coded so that the resource's URL is explicitly defined then a dependency
442                exists between the web pages and the context which makes the deployment not
443                as portable.  Since the web app context path is needed by the XSLTs to build
444                the correct HTML code it is implemented here to help static page development.
445                Relative links work fine if the resource it within the same directory e.g.
446                if the "about/welcome.html" page contains a relative link to the "about/content_usage.html"
447                page then all is well.  The "about/welcome.html" page can NOT contains a relative
448                link to the "indicator/introduction.html" as it will not find the correct
449                directory.
450        -->
451
452        <!-- Local IBIS URL adjustment templates.  These templates simply add the web application's
453                context path as a prefix to the link reference attribute.
454        -->
455        <xsl:template match="@ibis:href" mode="ibis.copy" ibis:doc="Inner 'ibis:href' template that adds the 'WebAppURLContextPrefix' to the 'href' attribute.">
456                <xsl:attribute name="href" select="concat($ibis.urlPrefix, .)"/>
457        </xsl:template>
458        <xsl:template match="@ibis:src" mode="ibis.copy" ibis:doc="Inner 'ibis:src' template that adds the 'WebAppURLContextPrefix' to the 'src' attribute.">
459                <xsl:attribute name="src" select="concat($ibis.urlPrefix, .)"/>
460        </xsl:template>
461        <xsl:template match="@ibis:action" mode="ibis.copy" ibis:doc="Inner 'ibis:action' template that adds the 'WebAppURLContextPrefix' to the 'action' attribute.">
462                <xsl:attribute name="action" select="concat($ibis.urlPrefix, .)"/>
463        </xsl:template>
464
465        <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.">
466                <xsl:value-of select="$ibis.urlPrefix"/>
467        </xsl:template>
468
469        <xsl:template match="@*" mode="ibis.copy" ibis:doc="Inner '@*' template that copies the non ibis: namespace attributes">
470                <xsl:copy-of select="."/>
471        </xsl:template>
472
473        <xsl:template match="@ibis:doc" mode="ibis.copy" ibis:doc="Eats ibis:doc attribute"/>
474        <xsl:template match="ibis:doc"  mode="ibis.copy" ibis:doc="Eats ibis:doc element"/>
475
476
477
478        <!-- =============================== I B I S   I N C L U D E   M A T C H -->
479        <xsl:template match="ibis:include" mode="#all"
480                ibis:doc="
481                        'ibis:' namespace specific match template which opens
482                        the document via the 'href' attribute and does an 'apply-template'
483                        operation on its contents to process sub 'ibis:include' statements
484                        and to copy its text, attributes, and processing instructions.
485
486                        Provides the IBISPH system the ability to do simple xinclude
487                        type operations.  As of 6-2004 the xerces parser 2.6.x has xinclude support
488                        but it must be configured when starting the Java JVM or with Java system
489                        properties.  Since this might not be an option for some deployments (like
490                        Utah's state wide ITS app server) the system wide property solution is not
491                        an option.  To handle being able to deploy into environments where we don't
492                        know which XSL engine is being used this two step xinclude processing
493                        was developed.  This option is not nearly as seamless and requires that
494                        the java controller do 2 transformations - the first being this xinclude
495                        type transformation with the second being the normal desired page type
496                        transformation.  Another option was to do the xinclude template inside the
497                        XSLT as a variable then use that variable for all XML nodes.  This option
498                        appears to be somewhat slow but it is seamless.
499
500                        See: http://www.sagehill.net/docbookxsl/Xinclude.html
501
502                        This page simply copies the contents of the base document and when it
503                        hits the ibis:include element it opens the document with an XSLT document
504                        call based on the href attribute of the xi:include element.  These
505                        elements are then copied into the source document.
506
507                        NOTE: the included document MUST be a valid XML file e.g. well
508                        formed with a root/master/parent element.
509
510                        If an children-only-flag attribute exists in the element then only
511                        only the sub elements and child text are included and processed.
512                        This is useful for including an element's text without having to
513                        include its root element.
514                "
515        >
516<!-- this only copies child content - skips container element.
517                <xsl:copy>
518                        <xsl:apply-templates select="document(@href, /)" mode="ibis.include"/>
519                </xsl:copy>
520<xsl:message select="document(@href, /)"/>
521<xsl:message select="concat('FOUND IBIS INCLUDE: ', @href)"/>
522
523                <xsl:choose>
524                        <xsl:when test="exists(@include-children-only)">
525                                <xsl:apply-templates select="document(@href, /)/(text() | *)" mode="ibis.copy"/>
526                        </xsl:when>
527                        <xsl:otherwise>
528                                <xsl:apply-templates select="document(@href, /)" mode="ibis.copy"/>
529                        </xsl:otherwise>
530                </xsl:choose>
531 -->
532                <xsl:apply-templates select=
533                        "if(exists(@children-only-flag))
534                                then document(@href, /)/(text() | *)
535                                else document(@href, /)
536                        "
537                        mode="ibis.copy"
538                />
539        </xsl:template>
540
541</xsl:stylesheet>
542
543
544
545<!-- left here for posterity - a way to totally replace an element...
546        <xsl:template match="ibis:a">
547                <xsl:element name="a">
548                        <xsl:attribute name="href"><xsl:value-of select="concat($ibis.urlPrefix, @href)"/></xsl:attribute>
549                        <xsl:copy-of select="attribute::*[name() != 'href']"/>
550                        <xsl:apply-templates select="current()/text() | current()/*"/>
551                </xsl:element>
552        </xsl:template>
553-->
554<!-- img elements do not contain any text or other elements so it doesn't need
555                to process/worry about anything other than it's attributes.
556        <xsl:template match="ibis:img">
557                <img>
558                        <xsl:attribute name="src"><xsl:value-of select="concat($ibis.urlPrefix, @src)"/></xsl:attribute>
559                        <xsl:copy-of select="attribute::*[name() != 'src']"/>
560                </img>
561        </xsl:template>
562-->
563<!-- Since the a element can contain images, divs etc need to process text
564                and elements contained within.
565        <xsl:template match="ibis:form">
566                <xsl:element name="form">
567                        <xsl:attribute name="action"><xsl:value-of select="concat($ibis.urlPrefix, @action)"/></xsl:attribute>
568                        <xsl:copy-of select="attribute::*[name() != 'action']"/>
569                        <xsl:apply-templates select="current()/text() | current()/*"/>
570                </xsl:element>
571        </xsl:template>
572-->
573
574<!-- ============================= End of File ============================= -->
575
Note: See TracBrowser for help on using the repository browser.