Adding a Master File Transformation
THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO
In this tutoiral, you'll learn how you can add a new master file transformation. More specifically, you'll create a site map according to the format found on at sitemaps.org. This new site map can then be referenced in your publication's robots.txt file and read by supporting serach engines.
Learning about the sitemap file format
The Sitemap protocol format consists of XML tags. All data values in a Sitemap must be entity-escaped. The file itself must be UTF-8 encoded.
Reading the first few paragraphs on this page is enough knowledge of the new file format to build a transformation.
Creating the transformation template from an existing file
The best way to create such transformation is to start from an existing file, map_to_ul_menu.xsl being one of the best candidate.
To use the file map_to_ul_menu.xsl as a starting point, follow these steps.
- In Windows Explorer, navigate to your publication's online/xsl folder
- Open the file map_to_ul_menu.xsl
- Save it as map_to_urlset_sitemap.xsl
Editing the new transformation template
You should then edit the template to look like this.
Let's get a closer look at the above template.
Namespaces
Line 1 defines the required namespaces in the xsl:template root element.
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"is the XSLT namespace
- xmlns:xhtml="http://www.w3.org/1999/xhtml" is required to read the xhtml source topics
- xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"is the sitemap namespace
Template parameters
Lines 10 and 11 declare two custom template parameters that will be used to create the final output.
- web_site is the root of your web site (ex.: http://www.formedia.ca/)
- source_file_extension is the file extension you are using for your source files. The default value is "xhtml".
The temeplate
Lines 15 to 17 replace the original outer element with the element and calls the individual topic template with the mode set to "url". Please note the the mode attribute could be left unused and everything would work but it's a good habit to use modes for your templates.
The temeplate
Lines 24 to 38 replace the original template with a slight variation that uses the custom "web_site" parameter.
Reading values from the XHTML topic files
Lines 39, 42 and 45 read their value from the actual xhtml topic with the help of the XSLT document() function.
- '../../xml/' is the relative path of the xhtml source files
- @id is the topic identifier taken from the master file topic node
- '.' is a separator
- $language is one of the standard parameters that is sent to the template
- '.' is another separator
- $source_file_extension is the second custom parameter you created already
When you got the xml document() and you want to get the revised date, the "//xhtml:meta[@name='revised_date']/@content" pattern gets you to the desired value.
A complete tutorial on XSLT is beyond the scope of this topic but this should give you a good start.
Adding the template parameters to the collection
To add the necessary template parameters, follow these steps.
- Select the Collection tab
- Select the Collection Parameters tab
-
Add the following parameters
- web_site
- source_file_extension
- Set these parameters to an appropriate value
- Save your collection
The transformation template will now use these parameters during the publishing process to create the final output.
Adding the master transformation to the publishing process
ParagraphTo add this new transformation to the publishing process, follow these steps.
- Select the Package tab
- In the Master Templates grid, add the following entry
Referencing the new site map in the robots.txt file
Search engines like Google and Yahoo crawl the web searching for pages to index in their databases. One way you can communicate with these web crawlers is to setup a file named robots.txt on your web site.
Using this robots.txt file, you can let search engines know about your sitemap file so thay can use it to index your web site. A typical robots.txt file would look like this.
User-agent: *
Disallow: /xml/
Disallow: /xsl/
Sitemap: http://www.formedia.ca/topico/xml/urlset.en.xml
In the example above, the line in bold is the entry for the site map.
THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO