source: main/trunk/ibisph-view/src/main/webapp/xslt/_ibis-path.xslt @ 19868

Last change on this file since 19868 was 19868, checked in by GarthBraithwaite_STG, 2 years ago

view - more css tweaks. Reworked common.xml to go back to add model maps be referenced. Added complete external path for xslt access.

File size: 7.0 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
3<xsl:stylesheet version="3.0" 
4        xmlns:xsl ="" 
5        xmlns:xs  =""
6        xmlns:ibis=""
8        exclude-result-prefixes="ibis xs xsl"
11        <ibis:doc>
12                <name>ibis-path</name>
13                <summary>Library of generic/common ibis path related functions</summary>
14        </ibis:doc>
17        <!-- ========================= P A R A M E T E R S   and   V A R I A B L E S
18                The java servlet controller code adds ALL URL query request parameters
19                to the XSLT transformation's parameters.  Other special parameters are
20                added as well. 
22                Many of the global type parameters are defined within this XSLT file. 
23                The parameters are passed in via the Java XSLT transformation parameter
24                map (and thus are nameed according to the Java model map key value). 
25                For ease of XSLT code maintenance these global XSLT parameters are
26                wrapped within an "ibis." prefix so that it is shown which XSLT file
27                contains the definition.
28        -->
30        <!-- RESOURCE ADDRESSING: The "WebAppURLContextPrefix" parameter is used to
31                explicitly build URL addresses to site related resources.  The value is
32                typically pulled from the servlet context.  The resource's path is relative
33                to the application's root.  The prefix and the relative root address are
34                then concatenated together (along with a separator) to build a complete,
35                explicit path for the resource.  This value can either be hard coded as an
36                XSLT variable or in this case is set as a parameter passed in from the
37                XML/XSLT transformer.
39                This full context path value is needed because relative paths do not work
40                for sites that have resources under different directory paths.  E.g. the
41                browser tries to get the resource based on the current resource's path.
42                Relative paths work well with sites that deliver dynamic content using a
43                servlet call that is located at the root level of the application's context.
44                Addressing anything within a site like this using a relative address path
45                works since the current resource's path is the root directory.
47                The resource could also be explicitly coded for a given application context
48                (or as the default application - without any context path) but then the code
49                is context deployment dependent and would need changing based on the context
50                the app was deployed under.  So the root "/" can't be used either...
52                This solution is messier from an XSLT perspective and in making sure that the
53                XML/XSLT transformer is passed the correct value and inserts the value in as
54                the "WebAppURLContextPrefix" parameter.  However, this is a safe way to ensure
55                that the resources are found while remaining deployment context independent.
57                OLDER SOLUTIONS:
58                If the apps context is the root then this value should be '/'.  If it's
59                not then it should be something like: '/ibisph-view/'
60                <xsl:variable name="webappURLContextPrefix" select="'/ibisph-view/'"/>
61                <xsl:variable name="webappURLContextPrefix" select="concat('/', SystemServlet:System.getWebAppContextName(), '/')" xmlns:SystemServlet="org.ibisph.servlets.view"/>
63                WORKS - should be a little faster than system properties...
64                <xsl:variable name="webappURLContextPrefix" select="concat('/', SystemServlet:System.getWebAppContextName(), '/')" xmlns:SystemServlet="org.ibisph.servlet.view"/>
66                ALSO WORKS:
67                <xsl:variable name="webappURLContext" select="org.ibisph:SystemProperties.getProperty('WebAppContextName')" xmlns:org.ibisph="org.ibisph"/>
68                <xsl:variable name="webappURLContextPrefix" select="concat('/', $webappURLContext, '/')"/>
70                TRIED:
71                doesn't blow but doesn't have the correct content path either...
72                select="concat(, '/')" xmlns:java=""
74                ONE LINE PROPERTY CALL - WORKS:
75                <xsl:variable name="webappURLContextPrefix" select="concat('/', org.ibisph:SystemProperties.getProperty('WebAppContextName'), '/')" xmlns:org.ibisph="org.ibisph"/>
76                <xsl:variable name="webappURLContextPrefix" select="org.ibisph:SystemProperties.getProperty('WebAppURLContextPrefix')" xmlns:org.ibisph="org.ibisph"/>
77        -->
80        <xsl:param name="RequestURL" 
81                ibis:doc="Current HTTP request URL."
82        />
83        <xsl:variable name="ibis.requestURL" select="$RequestURL"/>
85        <xsl:param name="WebAppContextPath" 
86                ibis:doc="Prefix used/needed for referencing resources within the site."
87        />
88        <xsl:variable name="ibis.contextPath" select="$WebAppContextPath"
89                ibis:doc="WebAppContextPath access variable that all pages should use. 
90                        Has the 'ibis.' prefix to know what XSLT the variable/param is defined in.
91                "
92        />
94        <xsl:param name="WebAppRemoteRequestPath" select="$ibis.contextPath" 
95                ibis:doc="
96                        Prefix used/needed for referencing this apps resources outside the
97                        site.  This value is primarily used for the site search and remote
98                        email verification request.
99                "
100        />
101        <xsl:variable name="ibis.remoteRequestPath" select="$WebAppRemoteRequestPath"
102                ibis:doc="WebAppRemoteRequestPath access variable that any pages could use. 
103                        Has the 'ibis.' prefix to know what XSLT the variable/param is defined in.
104                "
105        />
107        <xsl:param name="ContentBasePath" select="'../../ibisph-content'"
108                ibis:doc="Injected via the common alt model map bean def.  This allows
109                        down stream XSLT to dynamically access the 2ndardy XML files as well
110                        as leaflet map and kendo json files.
111                "
112        />
113        <xsl:function name="ibis:getContentPath" as="xs:string"
114                ibis:doc="Returns the ContentBasePath param (injected via spring bean)
115                        concatenated with the passed in filePath
116                "
117        >
118                <xsl:param name="filePath" ibis:doc="Path to be appended to the ContentBasePath"/>
119                <xsl:value-of select="ibis:getPath($ContentBasePath, $filePath)"/>
120        </xsl:function>
123        <xsl:function name="ibis:getCompleteURL" as="xs:string"
124                ibis:doc="tests the supplied path/URL and if no http prefix then the
125                        webapp context is added as a prefix to the path."
126        >
127                <xsl:param name="path" ibis:doc="Path/URL to be tested/adjusted.  If
128                        the value begins with http then URL is returned untouched.  Else
129                        the webapp context is added as a prefix and returned."
130                />
131                <xsl:value-of select="if(starts-with($path,'http')) then $path else ibis:getPath($WebAppContextPath, $path)"/>
132        </xsl:function>
135        <xsl:function name="ibis:getPath" as="xs:string"
136                ibis:doc="Returns the ContentBasePath param (injected via spring bean)
137                        concatenated with the passed in filePath
138                "
139        >
140                <xsl:param name="pathPrefix" ibis:doc="Path to be preappended"/>
141                <xsl:param name="pathAndFilename" ibis:doc="Path to be appended to the pathPrefix"/>
142                <xsl:value-of select="if(ends-with($pathPrefix, '/') or starts-with($pathAndFilename, '/')) then concat($pathPrefix, $pathAndFilename) else concat($pathPrefix, '/', $pathAndFilename)"/>
143        </xsl:function>
147<!-- ============================= End of File ============================= -->
Note: See TracBrowser for help on using the repository browser.