xsl template 2012 - ec.europa.euec.europa.eu/ipg/tools/wcm-portal/documentation/assets/um.xsl... ·...
TRANSCRIPT
2 of 28
DOCUMENT HISTORY
Version Date Author Description Action(*) Confidentiality Pages
1.0 02/12/2011 Acsone Creation C High 25
1.1 10/07/2012 IDS Add new parameter “switch” for link strategies I High 26
1.2 18/07/2012 IDS Changed template: EC 2012 U High 28
(*) Action: C= Creation, I=Insert, U=Update, R=Replace, D=Delete
3 of 28
TABLE OF CONTENTS
1. About 5
2. New structure 6
3. Overview 7
3.1 How to start 7
3.2 Available templates 7
3.3 Available strategies 7
4. Commission template (ec.europa.eu) 9
4.1 library 9
4.2 doctype 9
4.3 window-title 9
4.4 metadata 9
4.5 title 9
4.6 header 9
4.7 services 11
4.8 modification_date 11
4.9 tools 12
5. Core templates 14
5.1 create_link 14
5.2 create_url 15
6. Adapted templates 16
6.1 “Cross-templates” parameters 16
6.2 wcm_links 19
6.3 wcm_documents 22
6.4 wcm_linkgroup 24
6.5 wcm_menu 25
5 of 28
1. ABOUT
XSL template 2011 has been created in the spirit of PST.
Cross browser
W3C compliant
Syntax declaration simplified
Same XHTML output
Same CSS and JS (Non intrusive JavaScript) from PST
…
Therefore, a migration to PST will be easier.
Here are some remarks about this framework:
It doesn’t contain any template to transform the content (abstract, related medias,…).
All XSL have been improved for a faster rendition from template 2007.
No new JAVA function has been created.
It’s a standalone framework. All central XSL templates are located in “template-2011” except the
“label_translations.xsl” which is in root domain.
You can customize your includes with the new structure of XSL-COMMON.
Defining a “user_class” parameter cancels any CSS rules from the central CSS.
Filtering by category is mandatory for element “wcm_document” and “wcm_link” (on more than one linkgroup).
Concerning the elements “wcm_documents”, “wcm_links”, “wcm_linkgroup” and “wcm_menu”, only the links to documents which master has a state greater or equal to the state of the current document are displayed, whatever the chosen strategy.
For instance if the current document is "Staging", only documents which master being "Staging" or "Active" will be displayed.
6 of 28
2. NEW STRUCTURE
[XSL-COMMON] / internet / ec.europa.eu
/template-2012
o /v01
/components
calendar_2007.xsl
dynamic_panel.xsl
evoting.xsl
openlayer.xsl
/core
common.xsl
header.xsl
strategy.xsl
/dictionary
labels_header.xsl
/elements
common.xsl
documents.xsl
feeds.xsl
linkgroup.xsl
links.xsl
menu.xsl
/templates
agenda.xsl
chapter_content.xsl
event.xsl
faq.xsl
gallery.xsl
newsletter.xsl
short_content.xsl
speech.xsl
includes.xsl
7 of 28
3. OVERVIEW
3.1 How to start
Copy all necessary templates from the XSL-COMMON to the parallel structure of your subsite. These templates are located in:
[XSL-COMMON]/ [CABINET] / [DOMAINE] / template-2012 / [VERSION] / templates
3.2 Available templates
Corporate templates
o library
o doctype
o window-title
o metadata
o title
o header
o modification_date
o tools
Core template
o create_link
o create_url
Adapted template
o wcm_links
o wcm_documents
o wcm_feeds
o wcm_menu
o wcm_linkgroup
Components
o “calendar_2007”
o dynamic_panel
o evoting
o openLayerMap
3.3 Available strategies
Two global variables define default strategies in the core/strategy.xsl file.
$DEFAULT_CREATE_LINK_STRATEGY is the default strategy used for creating links (see
Error! Reference source not found. Error! Reference source not found.) or for all <a>
(match=”a|A”) tags.
8 of 28
$DEFAULT_CREATE_URL_STRATEGY is the default strategy used for all <img>
(match=”img|IMG”) tags.
You can overwrite these variables in your own templates for defining your own default strategy.
In a lot of templates (wcm_links, wcm_documents, create_url, create_link .. ), you are able to overwrite
the strategy by using parameter strategy.
Available strategies are:
NO_CHANGE
o Meaning no linguistic change. In this strategy the language parameter of the target
document is not modified.
NO_CHECK
o The system simply generates a valid URL and applies the wanted language code.
CHECK_DOC
o The system will check if a translation exists in the requested language and if it is available
in the wanted state.
CHECK_VIRTUAL_DOC
o It means that the system will try to check if a translation exists in the wanted state.
WEB_SERVICE *
o The system will try to generate a web service consulting link (of course only available for
managed links).
NON_XML_WEB_SERVICE (default) *
o Same as "WEB_SERVICES" except that the web services icon will only be shown for binary
documents.
ZZ_ICONS *
o Several language icons, each corresponding to an available translation, are generated.
MODAL_WINDOW *
o This is the same as the ZZ_ICONS strategy except that a modal window will be used to
show the language coverage.
*Only available for link strategy.
9 of 28
4. COMMISSION TEMPLATE (EC.EUROPA.EU)
4.1 library
Template library includes all necessary CSS and JS files.
4.2 doctype
Template doctype returns the mandatory “doctype” of the document. (HTML 4.01 Transitional loose)
4.3 window-title
Template window-title returns a string with “- European Commission” at the end base from the title of the
document.
4.4 metadata
Template metadata returns all mandatory meta.
4.5 title
Template title displays the title of the document by using H1. The title is not display when the global variable
$IS_HOMEPAGE is set to $YES.
4.6 header
The template header is used for displaying a header.
Parameter Type/possible values
is_homepage Force using <H1> ($YES) for the header title text or <P> ($NO)
Possible values:
$YES
$NO (default)
site_name It’s a mandatory value and it will be always a string.
services This value must be setting as an XML.
Possible attribute name value:
custom
atoz
sitemap
10 of 28
about
faq
news
legal
contact
search
Default value is store in global variable ($DEFAULT_SERVICES)
<services>
<service name="legal" />
<service name="contact"/>
<service name="search"/>
</services>
Attributes allowed on XML
url
label
accesskey
Example 1: overwrite an existing service
<services>
<service name="legal" />
<service name="contact" url=”/my-site/my-contact_{$EU_LANGUAGE}.htm”/>
<service name="search"/>
</services>
Example 2: creating a custom service
<services>
<service name="legal" />
<service name="custom" label=”’My custom label’” url=”/my-site/my-custom-url.htm”/>
11 of 28
<service name="contact"/>
<service name="search"/>
</services>
validate Check if any document exist or not in each crumb.
Possible values:
$YES
$NO (default)
max_depth The value must be a number.
Default value: -1
max_length The value must be a number.
Default value: 100
strategy See available strategies in chapter 3.3
Default value : $NO_CHECK
Remarks:
No specific strategy can be defined by service
4.7 services
Template “services” is not a master template then you cannot call this template directly! It’s used by the header template.
4.8 modification_date
Template modification date allows you to display the publication date of your document or the current date (when
your document is regenerate)
Parameter Type/possible values
format_date A pattern to display the date.
Default value: dd/MM/yyyy
12 of 28
publication_date Possible values:
$YES
$NO (default)
4.9 tools
The additional tools template allow user to display some accessibility tools or else.
Parameter Type/possible values
tools This value must be setting as an XML.
Possible attribute name value:
custom
font_decrease
font_increase
Default value is store in global variable ($DEFAULT_TOOLS)
<tools>
<tool name="print" />
<tool name="font_decrease"/>
<tool name="font_increase"/>
</tools>
Attributes allowed on XML
name (see possible values)
url
label
icon
class
Example 1: overwrite an existing tool
<tools>
<tool name="print" url=”javascript:PrintMe()”/>
13 of 28
<tool name="font_decrease"/>
<tool name="font_increase"/>
</tools>
Example 2: create a custom tool
<tools>
<tool name="custom" url=”/my-site/my-rss.rss” icon=”/my-site/my-rss.gif” class=”my-rss” label=”’Follow me on RSS’”/>
</tools>
14 of 28
5. CORE TEMPLATES
5.1 create_link
Template create_link allows the webmaster to create a hyperlink.
Parameter Type/possible values
url The value can be an ID or an URL X
content The value can be any XHTML fragment. X
attributes This value must be setting as an XML.
Example
<attributes>
<class>my-link additional-class</class>
<id>myLinkID</id>
<title>My title attributes</title>
</attributes>
Remark: This XML must contain any valid attributes. There is no validation on it.
force_language Transform or not the language extension to the current language of the document.
Possible value
$YES (default)
$NO
Remark: The default value use a global variable: $DEFAULT_FORCE_LANGUAGE_LINK
strategy See available strategies in chapter 3.3
15 of 28
Default value : $DEFAULT_CREATE_LINK_STRATEGY (defined in core\strategy.xsl)
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
switch Sets the number of translations to display before switching to a different format.
This parameter is only available for strategies “ZZ_ICONS” and “MODAL_WINDOW”.
With the strategy "ZZ_ICONS" when X is reached, the strategy "ZZ_ICONS" displays a "MODAL_WINDOW".
With the strategy "MODAL_WINDOW" icon is displayed only when X is reached.
Default value : $DEFAULT_STRATEGY_SWITCH (defined in core\strategy.xsl)
5.2 create_url
Template create_url allows webmaster to create a url.
Parameter Type/possible values
url The value can be an ID or an URL X
Forcenochangeinlanguage Possible values:
$YES
$NO (default)
url_may_be_in_docbase Possible values:
$YES (default)
$NO
Strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_URL_STRATEGY
16 of 28
6. ADAPTED TEMPLATES
6.1 “Cross-templates” parameters
These are parameters used in several templates.
6.1.1 style_params
The style parameters allow user to define some extra parameters depending of the style used. These parameters must be defined as string.
Style Parameters
slideshow Examples:
display:fill,width:480,height:360
sequence:random,player:0
display:stretch,withlink:0
Possible parameter/value
display
o text (default)
o stretch
o fill
width
o A number to define the width. Default: 180.
height
o A number to define the height. Default: 120.
sequence
o random
o default (default)
autostart
o 1: run automatically the slideshow onload (default)
o 0: to not run automatically onload
withlink
o 1: used link for image (default)
o 0: do not use link with image
class
o Adding a class on the slideshow when javascript is enabled.
17 of 28
interval
o Elapse time in secondes between 2 images. Default: 6
pause
o 1: Pause on mouse over
o 0: do not pause on mouse over (default)
player
o 1: display the navigation bar (default)
o 0: do not display the navigation bar
mediagallery Examples:
with:200,height:300,abstract:1
with:200,height:300,title:0,abstract:1
Possible parameter/value
sequence
o parent (default)
o random
class
o Adding a class on the slideshow when javascript is enabled.
width
o A number to define the width. Default: 180. Width parameter
is ignored if value of playlist or freesize is 1.
height
o A number to define the height. Default: 150. Height
parameter is ignored if value of playlist or freesize is 1.
title
o 1: display the title (default)
o 0: do not display the title
abstract
o 1: display abstract
o 0: do not display abstract (default)
class
o User can add a specific class to managed the presentation of
the mediagallery
playlist
o 1: display the list of media
o 0: do not display the list of media (default)
freesize
Allow user to play with CSS instead of width and height parameters
to define the size of player. freesize is ignored (forced to 1) if value
of playlist is 1.
18 of 28
o 1: do not use height and width parameters
o 0: Use height and width parameters
callback
o Allow advanced user to play with javascript to use the player
functions.
6.1.2 Multipage
The multipage allow user to paginate any result of templates (wcm_xxx). This parameters is only available for specific style (list and box) on any template that using this style.
The structure must be always like this: “[position],[max_item],[max_links], [tag] ,[show_menu]”
Example: “top,1,3,li,false”
Remark: There is not default value for these parameters. Be sure that all parameters are defined.
Parameters
Position Choose the position of the navigation bar.
Possible value:
top
bottom
both
max_item This value must be a number and define the max item by page
max_links This value must be a number and define the max number of link display in
the navigation bar.
Tag Collect any repeating item “tag” with “euItem” class.
Possible value:
li (when style “list” is used)
div (when style “box” is used)
show_menu This display or not the dropdown menu to change dynamically the number
of item by page.
Possible value:
19 of 28
false
true
6.2 wcm_links
This template is used for displaying a flat list of links belonging to one or several linkgroups.
Differences with PST + limitations
1. Cannot define date format so date format has to be default date format (dd/MM/yyyy hh:mm:ss)
2. Using several linkgroup sources only works if at least one of the following constraint is defined :
category, country or region
3. No parameter applicable_group
4. Category parameter cannot take a list of category groups as parameter (No pattern like
catgrp(lgid,lgid,…))
5. No filter_lang and filter_state parameters
Parameter Type/possible values
style Possible values:
list (default)
list-date
box
box-date
slideshow
mediagallery
style_params See 6.1.1
lg_id This value is mandatory and must be a linkgroup ID or a comma separated list of
linkgroup ID.
Remark:
If parameters category AND country AND region are EMPTY, this template is
only valid with a single lgId
order Possible values:
$ASCENDING (default)
$DESCENDING
20 of 28
order_by Possible values:
seq_nr (default)
subject
title
reference_date
Remark:
There is no guarantee any other value will generate the expected result.
Do not use an empty string.
Ordering is only applied within each linkgroup and not across linkgroups.
max The value must be a number.
Default value: 20
Remark:
Display a max value of 20 items is a good practice for accessibility and
usability reasons (IPG).
category Possible values:
document
parent
A category ID or a comma separated list of category ID
Remark:
'' : an empty string means user doesn't want to filter by category ==> NO
category filter is applied
'parent' which is a keyword for filtering on subsite's categories
'document' which is a keyword for filtering on document's categories
category_operator Possible values:
and
or (default)
country ISO code of country (ex:FR)
Remark:
An empty string means user doesn't want to filter by country
region ISO code of region
Remark:
An empty string means user doesn't want to filter by region
21 of 28
reference_date Possible values:
date
date range
date list
Remark:
'' : an empty string means user doesn't want to filter by reference_date
Date format must be 'dd/MM/yyyy HH:mm:ss'
Not taken into account if parameters category AND country AND region are
EMPTY
valid_from Possible values:
date
date range
date list
Remark:
'' : an empty string means user doesn't want to filter by reference_date
Date format must be 'dd/MM/yyyy HH:mm:ss'
Not taken into account if parameters category AND country AND region are
EMPTY
valid_to Possible values:
date
date range
date list
Remark:
'' : an empty string means user doesn't want to filter by reference_date
Date format must be 'dd/MM/yyyy HH:mm:ss'
Not taken into account if parameters category AND country AND region are
EMPTY
format-date Possible values: any date format
Default value: dd/MM/yyyy
This parameter does only make sense with list-date and box-date styles. It is used
for the display of dates.
strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_LINK_STRATEGY
22 of 28
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
user_class Any value as string to fill the class attribute
user_id Any value as string to fill the id attribute
multipage See 6.1.2
6.3 wcm_documents
This template constructs a link box using documents searched in the docbase based on specific criteria.
Parameter Type/possible values
style Possible values:
list (default)
box
box-date
location It’s a mandatory value.
Possible value
Empty string means location of the subject
Absolute path
Relative path: In this case the relative path will be resolved against the
subsite of the subject. The specified path must start with “./”.
deep Possible value
$YES
$NO (default)
order Possible value
$ASCENDING (default)
$DESCENDING
23 of 28
order_by More relevant possible values are:
begin_date (default)
eu_start_date (! only when subject is eu_event)
object_id
r_object_id
title
subject
Remark: If subject is "eu_event" then begin date means eu_start_date (Start date
of event). If subject is "eu_content" then begin date means r_creation_date
(Creation date of document)
category Possible value
document
parent (default)
A category ID or a comma separated list of category ID
Remark: Category is a mandatory criteria for filtering documents so :
Using 'parent' keyword while subsite is not categorized will return NO result
Using 'document' while document is not categorized will return NO result
Using an EMPTY list of categories will return NO result
category_operator Possible values:
and
or (default)
subject Possible values:
eu_content
eu_event
Remark: When searching events the system will also retrieve and show the
attributes eu_start_date and eu_end_date.
max The value must be a number.
Default value: 5
format_date Allow user to display the format date base from a pattern. Only available with style
“box-date” and when subject is “eu_event”.
Default value: dd/MM/yyyy
24 of 28
start_date Possible values:
date
date range
date list
Remark:
'' : an empty string means user doesn't want to filter by valid_from
Date format must be 'dd/MM/yyyy HH:mm:ss'
Make sense only if subject is eu_event
end_date Possible values:
date
date range
date list
Remark:
'' : an empty string means user doesn't want to filter by valid_to
Date format must be 'dd/MM/yyyy HH:mm:ss'
Make sense only if subject is eu_event
strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_LINK_STRATEGY
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
user_class Any value as string to fill the class attribute
user_id Any value as string to fill the id attribute
multipage See 6.1.2
6.4 wcm_linkgroup
Display a hierarchical list base from a linkgroup.
Remark:
No filter_lang
25 of 28
No filter_state
cntIcons forced to be false with dropdown and flyout styles
Parameter Type/possible values
style Possible values:
list (default)
dropdown
flyout
lg_id The ID of linkgroup is mandatory
user_class Any value as string to fill the class attribute
user_id Any value as string to fill the id attribute
max Default value: 100
strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_LINK_STRATEGY
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
6.5 wcm_menu
Display a restrictive hierarchical list base from a linkgroup menu.
Remark:
No filter_lang
No filter_state
Parameter Type/possible values
26 of 28
style Possible values:
list (default)
user_class Any value as string to fill the class attribute
user_id Any value as string to fill the id attribute
strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_LINK_STRATEGY
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
6.6 wcm_feeds
Display any feeds source: rss, wcm or rapid from the feed cache.
Parameter Type/possible values
style Possible values:
list (default)
box
location The url of feed
order Possible value
$ASCENDING (default)
$DESCENDING
order_by Possible values:
title
description
url
27 of 28
max Default value: 20
user_class Any value as string to fill the class attribute
user_id Any value as string to fill the id attribute
strategy See available strategies in chapter 3.3
Default value : $DEFAULT_CREATE_LINK_STRATEGY
cnticons Display or not the content icons and the file size.
Possible values:
$YES (default)
$NO
multipage See 6.1.2
6.7 dynamic_panel
This component enables to create a panel to load dynamically the content of an external webpage.
Parameter Type/possible values
url Contains the path where the HTML code fragment has to be searched.
fallback A fallback value for url if the main document was not found.
begin A textual value specifying the begin token of the HTML fragment to insert.
end A textual value specifying the end token of the HTML fragment to insert.
Example:
<xsl:call-template name="dynamic_panel">
<xsl:with-param name="url" select="'/my-site/fragment.htm'"/> <xsl:with-param name="end" select="'endTag'"/> <xsl:with-param name="begin" select="'beginTag'"/> </xsl:call-template>
28 of 28
The “fragment.htm” contain:
<p>Ignored HTML fragment</p> <!--beginTag--> <p>HTML fragment 1</p> <!--endTag-->
<p>Ignored HTML fragment</p> <!--beginTag--> <p>HTML fragment 2</p> <!--endTag-->
Note:
The fragment can contain one or several item repeating (beginTag , endTag).
The entire page is loading when “begin” and “end” are empty.