<a name="819"></a><a name="wbp24ch21P1"></a>Chapter 21: Create an XML-Configured High-Performance Transformation Engine - Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

Mark V. Scardina, Ben ChangandJinyu Wang

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Chapter 21: Create an XML-Configured High-Performance Transformation Engine

Transforming XML documents from one markup language to another or from one schema to another is the responsibility of an XSLT processor. This process can be expensive in terms of time and memory even with the high-performance C and Java processors that are included in Oracle XDK 10g. This expense is largely due to the complexity and reiterative nature of the XSLT process. Therefore, to improve performance further, Oracle took an alternative approach and created the Oracle XDK 10g XSLT Compiler and XSLT virtual machine (XSLTVM). In this chapter we show you how you can put these to use for an application that requires dynamic selection of an XSLT stylesheet and the fastest, most efficient transformation. This will be done by creating a high-performance transformation engine that is XML-configured to apply precompiled stylesheets.


Designing the Framework


To create high-performance XSLT transformation, we must first examine the individual steps that go into the XSLT process and then see which steps can be optimized, combined, or even eliminated. For example, if you have a records.xml input XML file to be transformed by a XSLT stylesheet into a reportl output file, you need to perform the following functional steps:



Parse records.xml into a DOM.



Parse into an XSLT stylesheet object.



Apply the XSLT templates from the stylesheet object to the input DOM to create an XSLT result object.



Serialize the result object to reportl.

One way to optimize run-time performance is to introduce precompilation wherever possible. Although the input XML documents are not known ahead of time, the XSLT stylesheets usually are; however, standard XSLT processors do not serialize out nor read in their object formats. There is an XSLT compiler in Oracle XDK 10g that effectively does exactly this. Only instead of creating a serializable object, it creates XSLT byte code that can be understood by a purpose-built XSLT virtual machine. The advantage of this approach is that it can optimize Step 3 because it translates XSLT templates and functions into ready-to-execute byte-code instructions. Finally, Step 4 is usually not a bottleneck and, in fact, is very fast in the case of the VM, which is written in C.

A question remains as to how these compiled stylesheets become associated with the input XML files if there is more than one to choose from. XML files that require XSLT transformation usually include a stylesheet processing instruction (PI) in their prolog:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="?>

Since this is a reference to the stylesheet file and not the compiled version, you must create a mapping of one to the other. For this engine, you do this with an XSLT mapping file of the following form:

<?xml version = "1.0"?>
<xslmap>
<xsl xsb="booklist.xsb">booklist.xsl</xsl>
<xsl xsb="cdlist.xsb">cdlist.xsl</xsl>
<xsl xsb="dvdlist.xsb">dvdlist.xsl</xsl>
</xslmap>

By parsing this xslmap.xml file on startup, the engine can create a mapping table so that when it gets the stylesheet PI from the input document, it knows what compiled stylesheet to load into the VM.

To implement this engine, you will create two command-line applications. The first, xslcompile, creates the compiled XSLT stylesheets and adds a corresponding entry in the map file. The second, xsbtransform, applies the stylesheets to the input XML file to create the output file.

/ 218