Teach Yourself e.net - Syspro
Teach Yourself e.net - Syspro
Teach Yourself e.net - Syspro
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
6.1.2.1. XSLT as a Template<br />
XSLT is important for transforming the XML output of the SYSPRO business objects for<br />
use in other applications and settings. In order to gain a better understanding of XSLT, it's<br />
important that we define what an XSLT document contains. Although XSLT stands for<br />
Extensible Stylesheet Language Transformations, another name for it could be "Extensible<br />
Template Language Transformations". This is because XSLT relies on templates to<br />
process and create the particular output structure. The W3C provides the following<br />
statement about XSLT in relation to templates:<br />
“A stylesheet contains a set of template rules. A template rule has two parts: a pattern<br />
which is matched against nodes in the source tree and a template which can be instantiated<br />
to form part of the result tree. This allows a stylesheet to be applicable to a wide class of<br />
documents that have similar source tree structures.”<br />
I'm sure that you have used templates in another application (i.e. MS Word) and so will<br />
know that they provide the basic structure that can be reused for specific purposes.<br />
Templates function in much the same way in XSLT, except that they are programmed to<br />
match up with nodes within an XML document. XSLT templates allow us to process and<br />
structure the data contained within the elements and attributes of the source XML<br />
document. They provide a template structure that can be processed when a particular node<br />
in the source XML document is matched.<br />
Remember that the XSLT processor described earlier is provided with two tree structures<br />
to use when transforming. The first is the structure for the source XML document and the<br />
second is the XSLT template document. Once these two structures are loaded, the XSLT<br />
processor attempts to match the element or attribute names found in the source XML<br />
document with templates contained in the XSLT document. The matching process is<br />
performed using XPath expressions that are part of the XSLT document. When a node<br />
from the source XML document matches a template in the XSLT document, the data<br />
contained in that node gets processed though the template.<br />
The use of XSLT definition files as templates offers an effective way to process various<br />
XML document structures. Each element, attribute, text node, or whatever, can be<br />
matched up with the appropriate template via the XPath expressions. If a given node does<br />
not have a matching template, no processing will occur for it, and the next section of the<br />
source XML document will be processed. When a matching node is found, the template<br />
takes care of creating the proper output structure based on information contained within<br />
the node.<br />
The theory of using XSLT to transform XML is very powerful, but let's begin to apply it<br />
to transforming XML to HTML so that we can use the XmlOut data returned from the<br />
SYSPRO e.<strong>net</strong> solutions business objects in a web-based application.<br />
6–4