source: main/branches/2.1/src/main/webapps/ibisph-view/xslt/html/HTMLContentPage.xslt @ 3599

Last change on this file since 3599 was 3599, checked in by Garth Braithwaite, 10 years ago

view webapp - more security cleanup

File size: 11.1 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:ibis="http://www.ibisph.org"
6
7        exclude-result-prefixes="ibis"
8>
9        <xsl:import href="Page.xslt"/>
10        <xsl:import href="SelectionTree.xslt"/>
11        <xsl:import href="SelectionList.xslt"/>
12
13
14        <ibis:doc>
15                <name>html/HTMLContentPage</name>
16                <summary>Core templates that handle the 'HTML_CONTENT' XML elements to
17                        produce an IBIS-PH HTML page.
18                </summary>
19                <description>
20                        Base XSLT that provides the templates to transform 'HTML_CONTENT' type
21                        XML content to IBISPH-View HTML pages.  This template and the 'HTML_CONTENT'
22                        XML data files form a simple mechanism to help keep all static type pages
23                        more easily maintained and consistant.  This framework provides the
24                        advantages of server side indlucdes (SSI) while providing some extra
25                        value like being able to reference resources using a relative path.
26                        <br/><br/>
27
28                        URL NOTE: This template contains a special way to handle IBIS type URLs.
29                        Instead of hard coding the link to include the application context and
30                        path, a relative type path can be used with an "ibis:" namespace.  This
31                        causes the web app context prefix to be added to the resource path so
32                        that the path is free of context deployment paths.  If the link is within
33                        the same 'folder' (as defined in with the resource mapping), then the
34                        'ibis:' is not needed.  However, if it is NOT, then it should be used.
35                        An example is the 'home/content_usage.html' page referencing a graphic
36                        image 'image/OH.gif'.  If the link is coded using relative addressing
37                        and the system is deployed to the webapp context of 'ibisph-view' then
38                        this link will not work because the server will look for the image with
39                        a path of: 'ibisph-view/home/image/DOH.gif'.  To work, the link would
40                        have to be coded as '/ibisph-view/image/DOH.gif' but what happens if this
41                        save system is deployed as the root application.  Then the link would
42                        have to be coded as '/image/DOH.gif' etc.  The processing of the link
43                        by this template automatically adds the appropriate webapp content prefix
44                        so that the resources can be relatively addressed.  Of couse if a relative
45                        address is really wanted then simply skip placing the 'ibis:' namespace
46                        prefix to the link's attribute.
47                </description>
48
49                <author>Garth Braithwaite</author>
50                <company>Software Technology Group/CDC/Utah Department of Health</company>
51        </ibis:doc>
52
53
54
55        <!-- ~~~~~~~~~~~~~~~~~~~~~~~ PARAMS / VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~ -->
56        <xsl:param name="UserAuthorities"
57                ibis:doc="User's Role(s)/Authorities that controls if the selection should
58                        be included in the output e.g. controls if the user can see the
59                        selection.  Injected by the transformation process as a parameter map.
60                "
61        />
62
63        <xsl:param name="Page.pageTitle" select="HTML_CONTENT/TITLE"
64                ibis:doc="HTML API template implementation that provides the HTML page's title text."
65        />
66
67        <xsl:param name="Page.sectionsTitle" select="$Page.pageTitle"
68                ibis:doc="Returns the value of the 'HTML_CONTENT/TITLE' element."
69        />
70
71
72
73        <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
74        <xsl:template name="Page.metaDescription" ibis:doc="HTML API template implementation that provides the HTML page's 'description' meta tag text.  Defaults to the 'HTML_CONTENT/DESCRIPTION' element.">
75                <xsl:value-of select="HTML_CONTENT/DESCRIPTION"/>
76        </xsl:template>
77
78        <xsl:template name="Page.metaKeywords" ibis:doc="HTML API template implementation that provides the HTML page's 'keyword' meta tag text.  Defaults to the 'HTML_CONTENT/KEYWORDS' element.">
79                <xsl:value-of select="HTML_CONTENT/KEYWORDS"/>
80        </xsl:template>
81
82        <xsl:template name="Page.otherHeadContent" 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.">
83                <xsl:apply-templates select="HTML_CONTENT/OTHER_HEAD_CONTENT/* | HTML_CONTENT/OTHER_HEAD_CONTENT/text() | HTML_CONTENT/OTHER_HEAD_CONTENT/@*" mode="ibis.copy"/>
84        </xsl:template>
85
86        <xsl:template name="Page.specificCSS" ibis:doc="HTML API template
87                implementation that provides the ability to specify other HTML HEAD CSS
88                links and style definitions. Defaults to the 'HTML_CONTENT/OTHER_CSS' element.
89                Note that this element is NOT wrapped between 'style' tags - the contents
90                are simply dumped into the HTML/HEAD element as is - by default."
91        >
92                <xsl:apply-templates select="HTML_CONTENT/OTHER_CSS/* | HTML_CONTENT/OTHER_CSS/text() | HTML_CONTENT/OTHER_CSS/@*" mode="ibis.copy"/>
93        </xsl:template>
94
95        <xsl:template name="Page.specificScript" ibis:doc="HTML API template
96                implementation that provides the ability to specify other HTML HEAD
97                Javascript links and inline code.  Defaults to the 'HTML_CONTENT/OTHER_SCRIPT'
98                element.  Note that this element is NOT wrapped between 'javascript' tags
99                - the contents are simply dumped into the HTML/HEAD element as is - by default.
100                If tree or expandables are being used javascript object declarations are
101                automatically handled.  If this behavior is not desired then this template
102                MUST be overridden.  Likewise if this template is overridden then these
103                declarations MUST be included if any tree or exapandable lists are to be
104                included."
105        >
106                <xsl:apply-templates select="HTML_CONTENT/OTHER_SCRIPT/* | HTML_CONTENT/OTHER_SCRIPT/text() | HTML_CONTENT/OTHER_SCRIPT/@*" mode="ibis.copy"/>
107                <xsl:if test="exists(HTML_CONTENT/CONTENT[//ibis:ExpandableSection or //ibis:SelectionList])">
108                        <script type="text/javascript">
109                                var sectionControl = new ShowHideBlockControl("control", "ExpandableSectionControlOpen", "container", "ExpandableSectionContainerShow");
110                        </script>
111                </xsl:if>
112                <xsl:if test="exists(HTML_CONTENT/CONTENT//ibis:SelectionTree)">
113                        <script type="text/javascript">
114                                var treeControl = new ShowHideBlockControl("control", "Open", "container", null);
115                        </script>
116                </xsl:if>
117        </xsl:template>
118
119
120
121        <xsl:template name="Page.sectionsContent" ibis:doc="HTML API template implementation
122                that provides main HTML body content for the page.  Defaults to copying
123                all elements and attributes of the the 'HTML_CONTENT/CONTENT' element."
124        >
125                <!-- used an apply templates so that the ibis: stuff would be handled -->
126                <div class="Content">
127                        <xsl:apply-templates select="HTML_CONTENT/CONTENT/(text() | *)" mode="ibis.copy"/>
128                </div>
129        </xsl:template>
130
131
132
133        <xsl:template match="HTML_CONTENT/CONTENT//ibis:ExpandableSection" mode="ibis.copy"
134                ibis:doc="Provides ability to more easily embed an expandable content block
135                        into the CONTENT.  Note that the approp CSS and JS will need to be
136                        included and initialized.  Code creates a control element with an ID
137                        based on the optional NAME sub element.  If NAME doesn't exist then
138                        the postion() is used.  This will create unique ID's in most cases.
139                        The CONTENT text() and sub elements will be ibis:copied into the assoc
140                        content container DIV.
141                "
142        >
143                <xsl:param name="id" select="if(exists(NAME)) then NAME else position()"/>
144                <a name="control{$id}" id="control{$id}" 
145                        href="javascript:sectionControl.toggle('{$id}');" 
146                        class="ExpandableSectionControl {if(exists(SHOW)) then 'ExpandableSectionControlOpen' else ''}" 
147                        title="control for {TITLE}"
148                ><span class="Icon"/><xsl:value-of select="TITLE"/></a>
149                <div id="container{$id}" class="ExpandableSectionContainer {if(exists(SHOW)) then 'ExpandableSectionContainerShow' else ''}">
150                        <xsl:apply-templates select="CONTENT/(text() | *)" mode="ibis.copy"/>
151                </div><br/>
152        </xsl:template>
153
154
155
156
157        <xsl:template match="HTML_CONTENT/CONTENT//ibis:SelectionList" mode="ibis.copy"
158                ibis:doc="Provides ability to more easily embed an expandable content list.
159                        The initial SELECTIONS/SELECTIONs are the container control with sub
160                        SELECTIONS/SELECTIONs being turned into a unordered list.  Note that
161                        the approp CSS and JS will need to be included and initialized.  Code
162                        creates a control element with an ID based on the optional NAME sub
163                        element + position() looping value.  This will create unique ID's in
164                        most cases.
165                "
166        >
167                <xsl:for-each select="SELECTIONS/SELECTION">
168                        <xsl:variable name="id" select="concat(NAME, position())"/>
169                        <a name="control{$id}" id="control{$id}" 
170                                href="javascript:sectionControl.toggle('{$id}');" 
171                                class="ExpandableSectionControl {if(exists(SHOW)) then 'ExpandableSectionControlOpen' else ''}" 
172                                title="control for {TITLE}"
173                        ><span class="Icon"/><xsl:value-of select="TITLE"/></a>
174                        <div id="container{$id}" class="ExpandableSectionContainer {if(exists(SHOW)) then 'ExpandableSectionContainerShow' else ''}">
175                                <xsl:apply-templates select="current()/SELECTIONS" mode="SelectionList">
176                                        <xsl:with-param name="processSubSelections" select="true()"/>
177                                </xsl:apply-templates>
178                        </div><br/>
179                </xsl:for-each>
180        </xsl:template>
181
182
183
184
185        <xsl:template match="HTML_CONTENT/CONTENT//ibis:SelectionTree" mode="ibis.copy"
186                ibis:doc="Provides ability to more easily create an expandable tree structure
187                        based on the standard SELECTIONS/SELECTION structure.  Note that the approp
188                        CSS and JS will need to be included and initialized.  For this to work,
189                        the SELECTIONS element must be a child element.  The parent ID is based
190                        on position() thus only enabling one tree per document.
191                "
192        >
193                <xsl:call-template name="SelectionTree.expandableTree">
194                        <xsl:with-param name="parentID"        select="position()"/>
195                        <xsl:with-param name="title"           select="TITLE"/>
196                        <xsl:with-param name="description"     select="DESCRIPTION"/>
197                        <xsl:with-param name="selections"      select="SELECTIONS"/>
198                        <xsl:with-param name="userAuthorities" select="$UserAuthorities"/>
199                </xsl:call-template>
200        </xsl:template>
201
202
203
204        <xsl:template match="HTML_CONTENT/CONTENT//ibis:SelectionList" mode="ibis.copy"
205                ibis:doc="Provides ability to more easily embed a standard list based on
206                        a SELECTIONS/SELECTION structure.  This code handles sub ibis:includes
207                        so that a MENU structure can be included.  If the container element
208                        does NOT have a direct child element named SELECTIONS then the optional
209                        SELECTIONS_CONTAINER_ELEMENT_NAME can be used.  If the INCLUDE_SUB_LISTS
210                        element is present then the list will be processed for sub lists.
211                "
212        >
213                <!-- variable is needed to process any ibis:include statements -->
214                <xsl:param name="processedContent">
215                        <xsl:apply-templates select="*" mode="ibis.copy"/>
216                </xsl:param>
217                <xsl:param name="selections"
218                        select="
219                                if(exists(SELECTIONS_CONTAINER_ELEMENT_NAME))
220                                        then $processedContent//*[name()=$processedContent/SELECTIONS_CONTAINER_ELEMENT_NAME]/*
221                                        else $processedContent
222                        "
223                />
224
225                <ul>
226                        <xsl:apply-templates select="$selections/*" mode="SelectionList">
227                                <xsl:with-param name="processSubSelections" select="exists(INCLUDE_SUB_LISTS)"/>
228                                <xsl:with-param name="userAuthorities" select="$UserAuthorities"/>
229                        </xsl:apply-templates>
230                </ul>
231        </xsl:template>
232
233</xsl:stylesheet>
234<!-- ============================= End of File ============================= -->
235
Note: See TracBrowser for help on using the repository browser.