Root Match Templates
Each XML document has a single root element. This element encloses all following elements and is therefore the parent element to all the other elements.
When the XSLT processor applies a stylesheet to an XML document, it begins processing with the root element of the XML source document. To process the root element, the XSLT processor searches the stylesheet for a template rule that matches the root element. A template rule matches the root element when the value of the template's match attribute is "/".
If the user explicitly defined a template rule that matches the root element, the XSLT processor finds it and implements that template to the entire XML document. If the XSLT processor does not find an explicitly defined template rule that matches the root element, the processor implements the default template that matches the root element. Every stylesheet includes this default template.
Root Match Templates in ePublisher Designer
The root match template has a number of responsibilities in ePublisher Designer. They are listed here:
*Recording Files and Dependencies
*Loading Node Sets
*Progress recording for the extension object that lives in the wwprogress namespace
*Up-to-Date checking on the projects output files
*Writing output
Recording Files and Dependencies
All root match templates in ePublisher Designer XSL files begin and end with the <wwfiles:Files></wwfiles:Files> elements. Within each root match template, usually near the bottom are one or more <wwfiles:Files> elements which include one or more <wwfiles:Depends /> elements. The attributes in these elements provide information about the file such as the path, and type. Upon completion of a stage, the ePublisher Designer engine will write the location of the processed information in the file for use by other stages attempting to complete their pipeline. Each stage may draw information from and deposit information for use by another stage.
Loading Node Sets
Another responsibility of the ePublisher Designer XSL root match template is to load the node sets needed for the transformation. This is usually done by accessing one or more <wwfiles:Files /> elements from, and using the path attribute on each <wwfiles:Files /> element together with the document() or wwexsldoc:LoadXMLWithoutResolver extension object, to load the node set for the transform. In most cases, the <wwfiles:Files /> elements are selected using an XSL parameter from the format.wwfmt file, or Stage in the current Pipeline.
The wwprogress extension object sends messages to the ePublisher Designer progress indicator. If a root match template is being applied over several documents in several groups, then the number of documents or groups to be processed is recorded using the Start method in the wwprogress namespace.
Notice that an operation registered with the wwprogress extension object has concluded is initiated by using the End method.
The ePublisher Designer’s XSL file’s root match template also ensures whether files to be processed are up to date. This is accomplished by passing attributes accepted by the wwfilesext:UpToDate extension method.
Writing Output
If a file is determined to be not up to date, then a XSL template is called, with the result then passed along with information regarding what type of output file is to be written, to the wwexsldoc:Document() method for processing. If the output is to contain XML or HTML elements, then it is necessary to use the msxsl:node-set() method to make the contents of the variable behave as a new XML fragment.
Real Life Example
Let’s return to our pizzeria. Our pizza chef, who forgets how to make a pizza whenever he sets out to do so, has a set of rules he follows posted on the wall. Sometimes, the owner pastes special instructions on the bag of ingredients. But there are some rules that are never altered. The chef may be instructed every time to wash his hands. Or not to smoke a cigarette while making a pizza. These rules that he must make sure to follow every single time during the entire pizza production process, are the equivalent of the root match template.
Was this helpful?
Last modified date: 08/16/2017