An Engine for Generating XSLT from Examples

Transcription

An Engine for Generating XSLT from Examples
An Engine for Generating XSLT from Examples
José Paulo Leal | Ricardo Queirós
CRACS & INESC-Porto LA
Faculdade de Ciências,
Universidade do Porto
Rua do Campo Alegre, 1021
4169-007 Porto PORTUGAL
Outline
Introduction
Related work
The Vishnu engine
1.
2.
3.
Validation
4.
5.
Architecture
Context
Generation
Refinement
consistency (unit testing)
coverage of the existing rules (scenarios)
adequacy (GWT web application)
Conclusions and future work
1. Introduction
Extensible
Stylesheet Language Transformations (XSLT)
powerful
& widely used language for transforming XML documents
overwhelming for novice or infrequent users
XSLT
program inference
from
examples, based on source and target documents.
seldom adequate for production usage …
… but can be used as
a skeleton of the final program
as scaffolding in the process of coding it
2. Related work
Environments
for programming in XSLT
XSLT editors
Environments
Types
IDE
XML IDE’s
General purpose IDE’s
Independent/Standalone
Examples
Altova StyleVision, Stylus Studio, oXygen
TigerXSL, XSL Tools, OrangeVoltXSLT, X-Assist
Dexter-xsl, VXT, FOA
XSLT generators
Example-based annotation tool
Annotation-based page-clipping engine
3. The Vishnu engine
Vishnu
- Visual programming tool for creating XSLT programs
Composed
by 2 components
Programming engine (server)
automatic generation of XSLT program from examples
using 2nd order transformations
Graphical Editor (client) - user interaction where the programmer
loads and edits document examples
pairs their content using graphical primitives
3. The Vishnu engine
Vishnu
- Generation
pairs
<vishnu xmlns="http://www.dcc.fc.up.pt/vishnu">
<source>...</source>
<target>...</target>
<pairings>
<pairing source = "/rss[1]/channel[1]/title[1]/text()”
target = "/html[1]/head[1]/title[1]/text()"/>
<pairing source = "/rss[1]/channel[1]/title[1]/text()”
target = "/html[1]/body[1]/h1[1]/text()"/>
</pairings>
</vishnu>
generates
<xsl:template match="/">
<html><head>title>
<xsl:value-of select="/vishnu/source/rss[1]/channel[1]/title[1]/text()"/>
</title></head><body><h1>
<xsl:value-of select="/vishnu/source/rss[1]/channel[1]/title[1]/text()"/>
</h1></body></html>
</xsl:template>
3. The Vishnu engine
Vishnu
communication
between components is regulated by the Vishnu API
the Vishnu façade class
implements the Vishnu API
hides the inner structure of the XSLT generator
organized in three main components
context
generator
refiner
3. The Vishnu engine
Vishnu
XML
– Context (1)
file with data for the generation process
Formalized by the following XML Schema:
source: a copy of the source document
target:: a copy of the target document
pairings: list of pairing relating the two documents
<pairing source="/rss[1]/channel[1]/title[1]/text()” target="/html[1]/head[1]/title[1]/text()"/>
3. The Vishnu engine
Vishnu
– Context (2)
converts
text into XML and vice-versa
converts text locations (offsets) into IdPaths expressions and vice-versa
IdPath is an absolute XPath expression which selects either single texts or
attribute nodes in an XML document:
/n1[p1]/.../nn[pn]/text()
/n1[p1]/.../nn[pn]/@attr
3. The Vishnu engine
Vishnu
– Generation (1)
produces
an initial XSLT program from source, target and mapping
a default mapping
the
Is inferred if no mapping is provided by the client
links text or attribute nodes in both documents (equal character strings)
initial XSLT program
has a single template containing an abstraction of the target document
target positions in the mapping are replaced with xsl:value-of instructions
processes documents with the same structure of the source document
a refinement process abstracts this program
3. The Vishnu engine
Vishnu
– Refinement (1)
Produce
a high quality XSLT program from the initial program
Composed by a set of 2nd order transformations (refinements)
Control of the refinement process
Based on strategies (process sequencing)
Implemented in Java
Two
types of refinements:
Simplifications
Abstractions
3. The Vishnu engine
Vishnu
Two
– Refinement (2)
types of refinements:
Simplifications:
Preserve the program semantics, changing its syntax
Improve the readability of XPath expressions and extract global
variables
Examples: Context, Melt, Extract and Join
Abstractions:
Change both the syntax and semantics of the program
Generalize templates and restructure large templates in several
smaller ones
Examples: Generalize and Structure
4. Validation
The
1.
2.
3.
Vishnu engine was validated in 3 approaches:
consistency of the generation and refinement process;
coverage of the existing rules;
adequacy of the Vishnu API to XSLT editing environments
4. Validation
Consistency
1.
Validation of the consistency of the generation and refinement
process by
checking that each intermediate transformation converts the example
source document into the examples target document.
If this invariant is not satisfied then the refinement process is aborted
and an error is reported to the client.
4. Validation
Coverage
2.
based on scenarios
each scenario includes source and target document and a
mapping, as well as the expected program
for each scenario the generated output of the engine is matched
with the resources enclosed on the scenario itself
current scenarios include the conversion of:
RSS documents to HTML
Mathematical expressions in MathML to presentation MathML
Meta-data in LOM (Learning Object Metadata) to RDF
4. Validation
Adequacy
3.
To validate the adequacy of the Vishnu API we developed a
simple web environment for XSLT programming based on the
Google Web Toolkit (GWT)
Conclusion and future work
Conclusion
Design of Vishnu a visual XSLT programming tool
Based on examples
Produces a high-quality XSLT based on a set of refinements
Project in implementation phase (client)
Future work
Editor
Improve web interface
IDE integration
Engine
Support refactoring features
Support mixed-content
Questions?
Authors
José Paulo Leal
[email protected]
http://www.dcc.fc.up.pt/~zp
Ricardo Queirós
[email protected]
http://www.eseig.ipp.pt/docentes/raq
Thanks!