source: main/trunk/ibisph-view/src/main/webapp/xslt/html/HTMLContentPage.xslt @ 22707

Last change on this file since 22707 was 22707, checked in by GarthBraithwaite_STG, 2 months ago

view - updated docs and internal workings of ibis.include.

File size: 14.4 KB
Line 
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:ibis="http://www.ibisph.org"
6
7        exclude-result-prefixes="ibis"
8>
9        <xsl:import href="Page.xslt"/>
10        <xsl:import href="SiteSpecific.xslt"/>
11
12
13        <ibis:doc>
14                <name>html/HTMLContentPage</name>
15                <summary>Core templates that handle the 'HTML_CONTENT' XML elements to
16                        produce an IBIS-PH HTML page.
17                </summary>
18                <description>
19                        Base XSLT that provides the templates to transform 'HTML_CONTENT' type
20                        XML content to IBISPH-View HTML pages.  This template and the 'HTML_CONTENT'
21                        XML data files form a simple mechanism to help keep all static type pages
22                        more easily maintained and consistent.  This framework provides the
23                        advantages of server side includes (SSI) while providing some extra
24                        value like being able to reference resources using a relative path.
25
26                        URL NOTE: This template contains a special way to handle IBIS type URLs.
27                        Instead of hard coding the link to include the application context and
28                        path, a relative type path can be used with an "ibis:" namespace.  This
29                        causes the web app context prefix to be added to the resource path so
30                        that the path is free of context deployment paths.  If the link is within
31                        the same 'folder' (as defined in with the resource mapping), then the
32                        'ibis:' is not needed.  However, if it is NOT, then it should be used.
33                        An example is the 'about/content_usage.html' page referencing a graphic
34                        image 'image/OH.gif'.  If the link is coded using relative addressing
35                        and the system is deployed to the webapp context of 'ibisph-view' then
36                        this link will not work because the server will look for the image with
37                        a path of: 'ibisph-view/about/image/DOH.gif'.  To work, the link would
38                        have to be coded as '/ibisph-view/image/DOH.gif' but what happens if this
39                        save system is deployed as the root application.  Then the link would
40                        have to be coded as '/image/DOH.gif' etc.  The processing of the link
41                        by this template automatically adds the appropriate webapp content prefix
42                        so that the resources can be relatively addressed.  Of couse if a relative
43                        address is really wanted then simply skip placing the 'ibis:' namespace
44                        prefix to the link's attribute.
45                </description>
46        </ibis:doc>
47
48
49        <!-- ~~~~~~~~~~~~~~~~~~~~~~~ PARAMS / VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~ -->
50        <xsl:param name="Page.pageTitle" select="HTML_CONTENT/TITLE"
51                ibis:doc="HTML API template implementation that provides the HTML page's title text."
52        />
53        <xsl:param name="Page.metaDescription" select="HTML_CONTENT/DESCRIPTION"
54                ibis:doc="HTML API template implementation that provides the HTML page's 'description' meta tag text.  Defaults to the 'HTML_CONTENT/DESCRIPTION' element."
55        />
56        <xsl:param name="Page.metaKeywords" select="HTML_CONTENT/KEYWORDS"
57                ibis:doc="HTML API template implementation that provides the HTML page's 'keyword' meta tag text.  Defaults to the 'HTML_CONTENT/KEYWORDS' element."
58        />
59        <xsl:param name="Page.htmlClass" select="HTML_CONTENT/HTML_CLASS"
60                ibis:doc="ability to specify the main html css class."
61        />
62
63
64        <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
65        <xsl:template name="Page.specificHeadContent" 
66                ibis:doc="HTML API template implementation that provides the ability to specify other HTML HEAD tag content.  Defaults to the 'HTML_CONTENT/OTHER_HEAD_CONTENT' element.">
67                <xsl:apply-templates select="HTML_CONTENT/OTHER_HEAD_CONTENT" mode="ibis.copyOnlyChildren"/>
68        </xsl:template>
69
70
71
72        <xsl:template name="Page.contentBody" ibis:doc="HTML API template implementation
73                that provides main HTML body content for the page.  Defaults to copying
74                all elements and attributes of the the 'HTML_CONTENT/CONTENT' element."
75        >
76                <!-- used an apply templates so that the ibis: elements are processed -->
77                <xsl:apply-templates select="HTML_CONTENT/CONTENT" mode="ibis.copyOnlyChildren"/>
78        </xsl:template>
79
80
81        <xsl:template match="ibis:ContentBlock" mode="ibis.copy"
82                ibis:doc="Provides ability to more easily embed a fixed content block   
83                        into the page's content.
84                "
85        >
86                <xsl:call-template name="ContentContainer.contentBlock">
87                        <xsl:with-param name="containerID" select="if(0 != string-length(@id)) then @id else NAME"/>
88                        <xsl:with-param name="contentContainerClass" select="@contentContainerClass"/>
89                        <xsl:with-param name="additionalClasses"     select="@additionalClasses"/>
90                        <xsl:with-param name="title"       select="TITLE"/>
91                        <xsl:with-param name="headingLevel"  select="if(exists(@headingLevel)) then @headingLevel else 3"/>     
92                        <xsl:with-param name="description" select="DESCRIPTION"/>
93                        <xsl:with-param name="help"        select="HELP"/>
94                        <xsl:with-param name="content">
95                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
96                        </xsl:with-param>
97                </xsl:call-template>
98        </xsl:template>
99
100
101
102        <xsl:template match="ibis:ExpandableContent" mode="ibis.copy"
103                ibis:doc="Provides ability to more easily embed an expandable content block
104                        into the page's content.  Note that the approp CSS will need to be included.
105                        The control and container require an 'id' attribute.  This ID uses the
106                        optional NAME sub element.  If NAME doesn't exist then postion() is used. 
107                        This will create unique ID's in most cases.  The CONTENT text() and
108                        sub elements will be ibis:copied into the assoc content container DIV.
109
110                        Dropdown content are is just as easily coded directly in the CONTENT
111                        so no template call/special processing is implemented as it just gets
112                        in the way.
113                "
114        >
115                <xsl:call-template name="ContentContainer.expandable">
116                        <xsl:with-param name="controlID"   select="@id"/>
117                        <xsl:with-param name="controlType" select="@controlType"/>
118                        <xsl:with-param name="additionalClasses" select="@additionalClasses"/>
119                        <xsl:with-param name="controlName" select="
120                                if(not(@controlName)) then NAME
121                                else @controlName
122                        "/>
123                        <xsl:with-param name="title"        select="TITLE"/>
124                        <xsl:with-param name="headingLevel" select="if(exists(@headingLevel)) then @headingLevel else 2"/>     
125                        <xsl:with-param name="description"  select="DESCRIPTION"/>
126                        <xsl:with-param name="help"         select="HELP"/>
127                        <xsl:with-param name="content">
128                                <xsl:apply-templates select="CONTENT" mode="ibis.copyOnlyChildren"/>
129                        </xsl:with-param>
130                        <xsl:with-param name="show"         select="exists(SHOW) or (string-length(@show) != 0)"/>
131                </xsl:call-template>
132        </xsl:template>
133
134
135
136        <xsl:template match="ibis:SelectionsList" mode="ibis.copy"
137                ibis:doc="Provides ability to more easily create a list structure based
138                        on the standard SELECTIONS/SELECTION structure.  The controlType and
139                        class controls indentured/expandable behavior.  Note that the approp
140                        CSS will need to be included.  This code handles sub ibis:includes
141                        so that a MENU structure can be included.  If the container element
142                        does NOT have a direct child element named SELECTIONS then the optional
143                        SELECTIONS_CONTAINER_ELEMENT_NAME can be used.  If the INCLUDE_SUB_LISTS
144                        element is present then the list will be processed for sub lists.
145                "
146        >
147                <!-- variable is needed to process any ibis:include statements -->
148                <xsl:param name="applyTemplatesContent">
149                        <xsl:apply-templates select="*" mode="ibis.copy"/>
150                </xsl:param>
151                <xsl:param name="selections"
152                        select="
153                                if(exists(SELECTIONS_CONTAINER_ELEMENT_NAME))
154                                        then $applyTemplatesContent//*[name()=$applyTemplatesContent/SELECTIONS_CONTAINER_ELEMENT_NAME]/*
155                                        else $applyTemplatesContent
156                        "
157                />
158
159                <xsl:call-template name="SelectionsList.processSelections">
160                        <xsl:with-param name="containerID"    select="@id"/>
161                        <xsl:with-param name="containerClass" select="concat('Selections ', @additionalClasses)"/>
162                        <xsl:with-param name="controlType"    select="@controlType"/>
163<!--
164                        <xsl:with-param name="headingLevel"   select="@headingLevel"/>
165-->
166                        <xsl:with-param name="showSelectionsTitle" select="true()"/>
167                        <xsl:with-param name="headingLevel"   select="if(0 != string-length(@headingLevel)) then @headingLevel else 0"/>
168                        <xsl:with-param name="selections"     select="$selections"/>
169                </xsl:call-template>
170        </xsl:template>
171
172
173
174        <xsl:template match="ibis:ContiditionalSection" mode="ibis.copy"
175                ibis:doc="Provides ability include/exclude certain sections of HTML
176                        CONTENT.  For this to work, an overriden callback type template
177                        is used.  This template is passed the section's ID.  The template
178                        must then determine if the section should be included.  The template
179                        determines this by XML, the passed in ID, and any other parameters
180                        that have been passed into the transformer process. 
181
182                        For working examples see repository for the user related XSLT and
183                        HTML_CONTENT ~May 2013.
184                "
185        >
186                <xsl:param name="test">
187                        <xsl:call-template name="HTMLContent.includeConditionalSection">
188                                <xsl:with-param name="sectionID" select="@id"/>
189                        </xsl:call-template>
190                </xsl:param>
191
192                <xsl:if test="ibis:isFirstLetter_T_or_Y_or_X($test)">
193                        <xsl:apply-templates select="(text() | *)" mode="ibis.copy"/>
194                </xsl:if>
195        </xsl:template>
196
197
198
199        <xsl:template name="HTMLContent.includeConditionalSection"
200                ibis:doc="Callback type template that controls if the section should be
201                        processed.  If the template returns 'T', 'X', or 'Y' then that
202                        content will be included.  If nothing or 'F', 'N' then that cotent
203                        will be omitted.  Default is to omit everything.  Sub XSLTs must
204                        override this template and determine if the content should be shown
205                        based on the XML, params passed in, and the section's ID attribute.
206                "
207        >
208                <xsl:param name="sectionID"/>
209        </xsl:template>
210
211
212        <xsl:template match="ibis:help" mode="ibis.copy"
213                ibis:doc="Provides a help button/popup.  1/2021 tried moving this to the
214                        help/include xslt.  Had to implement as a ibis:help element to more
215                        easily pick it up.  Doing so then keeps the ibis namespace which
216                        causes other issues even if matching and creating a new element name.
217                        If the ibis namespace is excluded then other ibis elements are
218                        skipped (like include and app prefix etc.).  As such decided to keep
219                        the processing clean and deal with specific elements CONTENT and
220                        HELP (which also has an optional CONTENT element to process).
221                "
222        >
223                <xsl:call-template name="Help.content">
224                        <xsl:with-param name="help" select="."/>
225                </xsl:call-template>
226        </xsl:template>
227
228
229        <xsl:template match="ibis:baseRequestPath" mode="ibis.copy"
230                ibis:doc="Provides access to the base req path for things like js ajax reqs."
231        ><xsl:value-of select="$ibis.baseRequestPath"/></xsl:template>
232
233
234        <xsl:template match="ibis:Popup" mode="#all">
235                <div id="{@id}" class="Popup {@additionalClasses}"> 
236                        <xsl:call-template name="SelectionsList.inputControl">
237                                <xsl:with-param name="inputID"    select="@controlID"/>
238                                <xsl:with-param name="inputName"  select="@controlName"/>
239                                <xsl:with-param name="inputType"  select="@controlType"/>
240                                <xsl:with-param name="labelClass" select="@controlClass"/>
241                                <xsl:with-param name="title"      select="@controlTitle"/>
242                                <xsl:with-param name="show"       select="'true' = @show"/>
243                                <xsl:with-param name="toggleRadioOnClick" select="'radio' = @controlType"/>
244                                <xsl:with-param name="headingLevel" select="@headingLevel"/>
245                                <xsl:with-param name="description" select="@description"/>
246                        </xsl:call-template>
247<!--
248                        <input id="{$controlName}" type="checkbox" checked="checked"
249                                name="{$controlName}" class="Control"
250                        />
251                        <label for="{$controlName}" title="Show/hide alerts"
252                                class="FontIcon" font-icon="{$fontIcon} &#xe403;"
253                        />
254                       
255                        id="{@containerID}"
256-->
257                        <div class="Container">
258                                <div class="Content">
259                                        <xsl:apply-templates select="* | text()" mode="ibis.copy"/>
260                                </div>
261                        </div>
262                </div>
263        </xsl:template>
264
265
266        <xsl:template match="ibis:SelectionsToJSONArray" mode="#all">
267
268                <xsl:variable name="selections">
269                        <xsl:apply-templates select="*" mode="ibis.copy"/>
270                </xsl:variable>
271
272                <script>
273var <xsl:value-of select="@variableName"/> = [
274                <xsl:for-each select="$selections//SELECTION[not(SELECTIONS)]">
275                        <xsl:sort select="TITLE"/>
276                        <xsl:if test="1 != position()">,</xsl:if>
277{
278        "name":            "<xsl:value-of select="if(0 != string-length(NAME)) then NAME else position()"/>"
279        ,"title":      "<xsl:value-of select="TITLE"/>"
280        ,"href" :      "<xsl:value-of select="ibis:getRequestURL(LOCAL_URL)"/>"
281        ,"group":      "<xsl:value-of select="substring(TITLE,1,1)"/>"
282}
283                </xsl:for-each>
284];
285                </script>
286        </xsl:template>
287
288<!--
289GARTH TODO: saxon 10.x has support for XSLT xpath evaluate
290        <xsl:template match="ibis:xsltParamContent" mode="ibis.copy"
291                ibis:doc="Provides access to XSLT param content."
292        ><xsl:value-of select="@content"/></xsl:template>
293       
294       
295                <script type="text/javascript" ibis:src="js/leaflet-src.js"/>
296                <script type="text/javascript" ibis:src="js/geostats.js"/>
297                <script type="text/javascript" ibis:src="js/jquery.leaflet.js"/>
298
299                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.js"/>
300                <script type="text/javascript" ibis:src="js/L.GeoJSON.Interactive.Choropleth.js"/>
301                <script type="text/javascript" ibis:src="js/L.LayerSets.js"/>
302                <script type="text/javascript" ibis:src="js/L.Control.LayerSets.js"/>
303                <script type="text/javascript" ibis:src="js/L.Control.Choropleth.js"/>
304                <script type="text/javascript" ibis:src="js/L.Control.Zoom.Min.js"/>
305                <script type="text/javascript" ibis:src="js/L.Map.ContextMenu.js"/>
306
307       
308                        $.ajax({
309                                type: "GET"
310                                ,url: "/nmibis-view/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
311//                              ,url: "/nm/query/definition/contentblocks/covid/COVIDRateCounty.html?DataVizContainerIDPrefix=sq1003"
312                                ,timeout: 1000*60*20    // in milli secs.
313                                ,success:
314                                        function(data)
315                                        {
316                                                $("#sq1003_script").html(  $(data).filter("#dataVizJavascript").html()  );
317                                                $("#sq1003_dataSources").html(  $(data).filter("#dataSources").html()  );
318                                                $("#sq1003_datasetModifiedDate").html(  $(data).filter("#datasetModifiedDate").html()  );
319                                        }
320                                ,error:
321                                        function(jqXHR, status, errorThrown)
322                                        {
323                                                console.warn("IBIS-PH Covid Ajax Query Request Error: " + status);
324                                                console.warn(errorThrown);
325                                                $("#sq1003_map").html("Sorry, content not available (" + status + ").");
326                                        }
327                        });
328       
329       
330-->
331</xsl:stylesheet>
332<!-- ============================= End of File ============================= -->
333
Note: See TracBrowser for help on using the repository browser.