Quick Reference "cheat sheet" to XML to DXL, XSL Import Stylesheet Syntax:
Upper "Header" portion:
01. <?xml version="1.0" encoding="ISO-8859-1"?>
02. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
03a. xmlns:dxl='http://www.lotus.com/dxl'
03b. exclude-result-prefixes="dxl">
04. <xsl:output method="xml" indent="yes" doctype-system="c:/lotus/lotusxml/domino.dtd" />
Description of above:
01. Makes the file a XML file. Both ISO-8859-1 and UTF-8 seem to work for encoding.
02. Doesn't do anything really. Gives viewer location to view documentation.
03a. Doesn't do anything either. Gives viewer location to view info on DTD used with this stylesheet.
03b. If we don't include this, we get an error that attribute (http://www.w3.org/2000/xmins/}dxl is not declared for "/document", in #05. Needed because we use "/document", not "dxl:document"
04. Output - specifies output to XML or Text usually. Indent is nice to have on. Internet Explorer used to have problems viewing XML files if output method was xml. Liked better as Text/HTML.
In this case we are also having the translation load a specific DTD for Domino. Otherwise our templates based on "/document" (really dxl:document) will fail in #05 below.
Template "Table of Contents" Section:
05. <xsl:template match="/document">
06. <xsl:processing-instruction name="xml-stylesheet">
07. type="text/xsl" href="http://www.mydomain.com/mystylesheet.xsl"
08. </xsl:processing-instruction>
09. <xsl:apply-templates select="title" />
10. <xsl:apply-templates select="body" />
11. </xsl:template>
Description of above:
05. Sets up the matching sections to come late in the code. In this case this is a "document"
This line is functioning like a table of contents that tells the translation engine where to go to process the various data tags (or in this case fields in the document).
06. ???
07. ???
08. Closing tag for #06 tag.
09. Match line for the table of contents that points/links to the template for this name/item. This tag is self terminated. In this case we are going to line #12 for Title.
10. Match line for the table of contents that points/links to the template for this name/item. This tag is self terminated. In this case we are going to line #?? for Body (a RTF).
11. Closing tag for #05
DocTitle Template:
12. <!-- my comment for DocTitle -->
13. <xsl:template match="title">
14. <item name="DocTitle">
15. <xsl:value-of select="@Value" />
16. </item>
17. </xsl:template>
Description of above:
12. Add a comment above just to let you know a year from now, what you are doing now and why.
13. Beginning template, the code to transform title into DocTitle
14. Names the item as "DocTitle". If keeping the same name, I could just do "@Name", to get the current attribute name.
15. @Value gets the value from the current line (attribute) of "title". "childnode" would retrieve a sub-node (child-node of this one) as the value.
16. Closes the tag for #14.
17. Closes the tag for this template, #13.
DocBody Template:
18. <!-- my comment for DocTitle -->
19. <xsl:template match="body">
20. <item name="DocBody">
21. <xsl:copy-of select="." />
22. </item>
23. </xsl:template>
Description of above:
18. Add a comment above just to let you know a year from now, what you are doing now and why.
19. Beginning template, the code to transform body into DocBody
20. Names the item as "DocBody".
21. "copy-of" does not convert to text but brings back the value unconverted. "value-of" converts to text. "." is like "this" in Java/JavaScript and returns this item's contents as it's value.
22. Closes the tag for #20.
23. Closes the tag for this template, #19.
previous page
|