How-To Automate XSLT Process Integration for Document Handling
In our previous post on XML Handling, we reviewed the built-in features of the Magic xpi Integration Platform that automate the handling of XML as part of an integration flow. In this article, we’ll examine the built-in capabilities of Magic xpi for XSLT (Extensible Stylesheet Language Transformations).
XSLT: Definition. A domain-specific XML based language used to generate transformed documents in either XML or other specified formats without altering the original source XML document. XSLT is commonly used to output transformed XML, PDF and other document formats.
XSLT can be a useful tool in the integration architect’s toolbox for multichannel communications. An integration platform, such as the Magic xpi Integration Platform can greatly simplify the effort needed to generate transformed documents as part of an automated business process.
In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document.
Using Magic xpi to Automate XSLT Processing of Documents
The XSLT component lets you transform XML documents. In Magic xpi Studio, when you place the XSLT component in a flow, you will automatically be able to configure your XSLT transformations using dialog box settings rather than having to use Java or some other way to generate the needed XSLT.
Magic xpi uses the following methods to give you full control over XML document transformations using XSLT:
XSLT Transform (Files)
XSLT Transform (BLOBs)
XSL-FO Convert (Files)
XSL-FO Convert (BLOBs)
Build Output Properties
Build Dynamic Parameters
Transforming XML Files Using XSLT.
Simply using XML does not ensure interoperation. While it provides a basic and standardized framework, XML schemas describing the same information can vary widely. But being able to interpret anything beyond that is a much tougher problem to solve. XML Schemas give you the tool for representing type definitions, but in the absence of a common schema, human intervention is still needed to bridge organizational boundaries. XSLT provides an XML-centric way to build that bridge.
Magic xpi Studio flows can use a number of methods in the XSLT component to work with XSLT files in order to transform XML according to a set of pre-defined rules. The Magic xpi XSLT Transform (Files) method transforms XML content using XSLT stylesheets into other XML files. At a minimum, you must specify the source and destination. You will also need to use an XSLT file containing the transformation instructions or use an XSL URL in the XML Source file itself. You can also use the Magic xpi XSL-FO Convert (Files) method to employ dynamic XSLT stylesheets to convert XML content to either PDF or SVG files.
Definition: The Portable Document Format (PDF) is a file format pioneered by Adobe Software to represent documents in a manner independent of application software, hardware, and operating systems. PDF files describe fixed-layout flat documents, including the text, fonts, graphics, and other information needed to represent them in a PDF reader or viewer such as Adobe Acrobat or a web browser.
Definition: The Scalable Vector Graphics (SVG) specifications use an XML based file format to represent static or dynamic two dimensional vector graphics.
Transforming XML Blobs Using XSLT.
Magic xpi Studio flows can also use a number of methods in the XSLT component to work with XSLT BLOBs (Binary Large Objects). The Magic xpi XSLT Transform (BLOBs)transforms XML content using XSLT stylesheets, expressed as BLOBs.
At a minimum, you must specify the destination XML file and the XML BLOB Source. Here again, you will also need to use an XSLT file containing the transformation instructions or an XSL URL inside the XML file itself. You can use the Magic xpi XSL-FO Convert (BLOBs) method for dynamic XSLT stylesheets that convert XML content to either PDF or SVG files.
Working with XSLT Properties and Parameters.
The Magic xpi Build Dynamic Parameters method invokes application-level context parameters that can be passed to the XSLT processor, and inserted into the XSLT stylesheet by specifying the parameter name and the parameter value.
The Magic xpi Build Output Properties method defines the format, the formatting properties, and the encoding of the transformation.
Several parameters are available:
You can specify the XML Version and the Output Encoding (i.e. the IANA character set such as UTF-8 or UTF-16, which are nearly universally supported) as well as aStandalone declaration. You can also decide to include these first three properties in theXML Declaration tag (highly recommended). You can specify the doctype as Doctype-public or Doctype-system. The SYSTEM and PUBLIC keywords both indicate that the DOCTYPE references an external DTD; the one you pick depends on how much information you want to provide. Both require a URI: the system identifier that uniquely identifies the DTD. This is normally an HTTP URL that points to the DTD (although it can be any unique URI), and by default the parser will attempt to read that document. The difference between SYSTEM and PUBLIC is that the latter provides an additional piece of data, the application-specific public identifier. In practice, the public identifier is superfluous: it provides a second unique identifier for the DTD, and one is enough. What this means is that you could write your web.xml using just the SYSTEM identifier, and a validating XML parser will accept it. CDATA Section Elements. This specifies a white space delimited list of the names of elements whose text node children should be output using CDATA sections. CDATA sections in an XML document serve no other purpose than to unambiguously say „this is all text, not markup“. In practice, all it does is it keeps you from having to escape the beginning-of-markup characters ‚<' and '&' and on occasion the end-of-markup '>‚. Indent. This indents the XML result tree to make the XML more readable. Media Type. You should use Media Type to specify the MIME content type of the data that results from the outputting of the result tree. The official list of MIME content types is maintained by the IANA and includes hundreds (if not thousands) of different formats falling into these broad categories: application, audio, example, image, message, model, multipart, text and video.
XSLT – Error Handing
Of course XSLT can generate errors so the Magic xpi Server Flow Manager checks for errors during the execution of a step. If there is an error in an XSLT component step, the Error Handler is invoked and handles the error based on the error code. These are usually involving errors in XML validity and syntax such as illegal arguments or IO errors.
Conclusion
The Magic xpi Integration Platform components for XML Handling and XSLT provide a methodology for automated handling of XML and XML transformations and conversions. These capabilities make Magic xpi a powerful automation platform for integration between popular enterprise software applications such as Oracle EBS, JD Edwards, PeopleSoft, SAP, Salesforce, SharePoint, Lotus, and literally hundreds of other enterprise applications that need help dealing with 3rd-party XML schemas, files and BLOBs.
Click for the Online version