An Approach to Translate XSLT into XQuery

XML (eXtensible Markup Language) transformations and queries are crucial operations for interpreting XML databases.  XSLT (eXtensible Stylesheet Language Transformations) is a prominent XML technology for these operations, but XQuery (XML Query Language) can query a broad spectrum of XML information sources, including both databases and documents.  In this project, we present our approach to translate XSLT to XQuery. We illustrate our approach as a set of rules or templates which translates an XSLT document into XQuery. We also discuss grouping operations for both XSLT and XQuery. Finally, we present the performance of XSLT versus equivalently transformed XQuery documents for varying sizes of documents and for different rules.

Papers

·         Albin Laga, Praveen Madiraju, Darrel A. Mazzari and Gowri Dara. Translating XSLT into XQuery. Proceedings of 15th International Conference on Software Engineering and Data Engineering (SEDE-2006), Los Angeles, California, July 6-8, 2006

·         Albin Laga, Praveen Madiraju, and Darrel A. Mazzari . An Approach to Translate XSLT into XQuery. An extended version, unpublished.

Members

  • Albin Laga (student)
  • Praveen Madiraju (faculty)
  • Darrel Mazzari (student)
  • Gowri Dara (student)

Testing performance of XSLT and XQuery

 

The Goal

Our goal is to test the performance of the basic functions of XSLT and its equivalent of XQuery. More details of these functions are given in the two papers given above.

Code and Scripts

- Sample XML document, cdcatalog.xml  and cdcatalog.xsd (schema document)

- Sample functions - rules (all in one ZIP file), previously developed:

Function

XSLT

XQuery

Rule 1

<xsl:param name="..."> ... </xsl:param>

declare variable $c as xs:string := "..."

Rule 2

<xsl:value-of select="..." />

for $x in …(collection of data[1])

Rule 3

<xsl:for-each select="node">

for $x in …(collection of data)

Rule 4

XPath/expression/[where condition]/node

where variable = “something”

Rule 5

<xsl:sort/>

Order by variable/XPath/expression

Rule 6

<sxl:if>

if () then else() but with empty else() statement

Rule 7

<sxl:choose>

if() then else if()then else()

Rule 8

<xsl:template match="node">

declare function local:cd-info($cd as element()? ) as element()?

Grouping

In XSLT 1

<xsl:key name="by-country" match="cd" use="country"/> Function: node-set key('by-country', country) Function: string generate-id(node-set?)

distinct-values(doc("cdcatalog.xml")/catalog/cd/country) for $x in doc("cdcatalog.xml")/catalog/cd where $x/country = $c

In XSLT 2

<xsl:for-each-group select="cd" group-by="country"> <!– Content: (xsl:sort*, sequence-constructor) --> </xsl:for-each-group>

Software

    - Xalan 2.7.0 for Java

    - Saxon 6.5.5j

    - Saxon 8.7j

Hardware, computer ()Compaq Presario X6000:

    - CPU - 2.8 GHz, Pentium 4
    - RAM 512 MB
    - Free space of Hard disk = 15 GB
    - Operating System - Win XP Version 5.1.2600
 

What to do?

    - Create XML Schema for the sample XML document in order to use it to generate big sample XML documents.

    - Generate large XML sample documents using MSV (Sun Multi-Schema Validator).

    - Organize all available files.

    - Create batch scripts to run the test and tables to store results.

    - Run batch scripts and store the result in the tables.

    - Create charts from the obtained data and analyze them.

 

XML Schema - cdcatalg.xsd

Generating the following XML sample documents:

    - cdcatalog_500.xml

    - cdcatalog_1000.xml
    - cdcatalog_1300.xml
    - cdcatalog_1500.xml
    - cdcatalog_2000.xml
    - cdcatalog_2500.xml
    - cdcatalog_2600.xml
    - cdcatalog_3000.xml
    - cdcatalog_3500.xml
    - cdcatalog_4000.xml
    - cdcatalog_4500.xml
    - cdcatalog_5000.xml

 

java -jar ./lib/xmlgen.jar -n 100 -ascii -depth 300000 -width 10000 ./src/cdcatalog.xsd ./samples/cdcatalog.$.xml

The above command generates 100 sample XML files; approximately five of these fulfills the requirement of being large enough.

Creating tables and batch scripts

    XSLT (Xalan 2.7.0)

    Batch script: xalan_xslt_tet.bat

File size in MB

Rule 1

Rule 2

Rule 3

Rule 4

Rule 5

Rule 6

Rule 7

Rule 8

0.5

875

906

1,110

1,016

1,328

1,234

1,422

875

1.0

985

1,000

1,266

1,141

1,547

1,469

1,718

984

1.5

1,047

1,062

1,422

1,266

1,812

1,688

2,062

1,047

2.0

1,156

1,172

1,516

1,359

2,015

1,875

2,328

1,157

2.5

1,219

1,281

1,671

1,485

2,234

2,078

2,563

1,250

3.0

1,328

1,344

1,781

1,562

2,453

2,281

2,844

1,329

3.5

1,406

1,421

1,906

1,656

2,672

2,500

3,125

1,406

4.0

1,515

1,531

2,047

1,781

2,860

2,672

3,375

1,500

4.5

1,593

1,596

2,187

1,859

3,063

2,891

3,640

1,578

5.0

1,656

1,672

2,234

1,969

3,328

3,078

3,937

1,656

   

    XSLT 2 (Saxon 8.7j)

    Batch script: saxon_xslt_tet.bat

File size in MB

Rule 1

Rule 2

Rule 3

Rule 4

Rule 5

Rule 6

Rule 7

Rule 8

0.5

328

328

547

406

765

656

875

328

1.0

422

437

718

516

1,110

969

1,266

422

1.5

625

641

953

719

1,500

1,313

1,703

625

2.0

672

672

1,062

782

1,766

1,516

2,016

672

2.5

922

937

1,375

1,031

2,218

1,922

2,500

922

3.0

1,016

1,031

1,515

1,140

2,484

2,188

2,844

1,016

3.5

1,110

1,125

1,672

1,234

2,828

2,484

3,204

1,110

4.0

1,063

1,094

1,703

1,203

3,110

2,703

3,531

1,078

4.5

1,375

1,375

2,063

1,500

3,610

3,140

4,047

1,359

5.0

1,438

1,437

2,172

1,547

3,891

3,375

4,375

1,406

 

    Xquery 1 (Saxon 8.7j)

    Batch script: sacon_xquery_test.bat

File size in MB

Rule 1

Rule 2

Rule 3

Rule 4

Rule 5

Rule 6

Rule 7

Rule 8

0.5

391

391

547

469

875

593

1,000

381,594

1.0

500

484

719

578

1,172

750

1,344

1,360,484

1.5

703

687

953

781

1,547

1,032

1,750

1,946,640

2.0

766

750

1,046

844

1,734

1,078

1,985

2,725,672

2.5

1,000

985

1,328

1,094

2,078

1,375

2,360

3,920,000

3.0

1,078

1,109

1,484

1,203

2,375

1,531

2,704

5,160,000

3.5

1,204

1,187

1,609

1,312

2,672

1,672

3,047

6,220,000

4.0

1,172

1,172

1,625

1,281

2,750

1,703

3,172

7,460,000

4.5

1,469

1,469

1,953

1,578

3,735

2,016

4,375

8,640,000

5.0

1,531

1,516

2,063

1,625

out

2,188

out

10,046,422

    out - out of Java heap space memory!

 

    Grouping

    Batch scripts: group_xslt_test.bat, group_xquery_test.bat

File size ( MB )

Xalan  2.7.0

Saxon 6.5.5j

Saxon 8.7j

XSLT 1

XSLT 1

XSLT 2

XQuery

0.5

1,797

844

859

25,200

1.0

2,312

1,187

1,250

89,812

1.5

2,812

1,531

1,640

183,016

2.0

3,000

1,672

1,765

174,219

2.5

3,485

2,141

2,281

296,782

3.0

3,828

2,344

2,469

371,094

3.5

4,187

2,546

2,734

434,094

4.0

4,375

2,703

2,813

353,672

4.5

4,812

3,109

3,344

553,375

5.0

5,141

3,344

3,572

596,859

 

Charts

 

REFERENCES

XQuery 1.0: An XML Query Language, http://www.w3.org/TR/2005/WD-xquery-20050915/

XSL Transformations (XSLT) Version 2.0, http://www.w3.org/TR/2005/WD-xslt20-20050915/

XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xquery-operators/

XSLT Tutorial, http://www.w3schools.com/xsl/default.asp

XQuery Tutorial, http://www.w3schools.com/xquery/default.asp

Jeni's XSLT Pages, Tutorials: Grouping in XSLT 1.0, http://www.jenitennison.com/xslt/index.html