Re: XML transformation

Hi Gary,

> I have an XML document that complies with one schema and I want to
> convert it so it complies with another. I understand the semantics
> of both schemas and the transformations I wish to achieve. Will I,
> in all cases (and given a good knowledge of XSLT) be able to freely
> convert from one to another e.g omit elements conditionally on
> values of others, combine elements and attributes and anything else
> whacky and arbitrary. What I'm really asking is: will I be able to
> do everything that I could do in C++ with XSLT.

The things that you mention wanting to be able to do here you are able
to do very easily in XSLT. XSLT 1.0 is designed for XML to XML
transformations, and primarily those that involve fairly basic
manipulations of strings and numbers, rather than general purpose
programming, so you won't be able to do everything that you could do
in C++ with XSLT, but I doubt that you actually want to do
*everything* :)

> I'm prompted to ask this question because I heard that XSLT is a
> functional language but I don't know what the practical implications
> of this are. Does it mean that it is Turing incomplete like XML
> schema language? If so, does this mean that there are certain things
> I cannot do and if so what sorts of things.

XSLT is Turing complete and you can get there if you try - XPath 1.0
doesn't have a concept of 'dates', so nor does XSLT 1.0, but the XSLT
templates at http://www.exslt.org/ do a pretty good job of parsing and
reformatting them if I do say so myself - but often it's not worth it
because with most processors you can bug out to other languages to
write extension functions for the extra things you need.

The things that you'll probably miss most if you start using XSLT are:
 - dates
 - regular expressions
 - mathematical functions (sqrt(), pow(), sin() etc.)

With any luck these things will be covered in XPath/XSLT 2.0, whose
first WDs are due to be out 'soon'.

> Does anybody know of any tools that ease or partly automate the
> process of producing transformation stylesheets; I've heard that
> XSLT is pretty hard to get started with.

XSLT honestly isn't hard if you start small and try to understand the
basic concepts before launching into trying to write code. It also
helps if you turn off your procedural approach to programming as much
as you can.

There are quite a few mapping tools available that allow you to 'draw'
the mappings between source elements and result elements. For example:

 * XSLWiz (http://www.induslogic.com/products/products2.html)
 * XMapper (http://www.nalasoftware.com/DOCS/Xmapper/overview.cfm)
 * XSLerator (http://www.alphaworks.ibm.com/tech/xslerator)
 * Stylus Studio (http://www.stylusstudio.com)
 * CapeStudio (http://www.capeclear.com/products/capestudio)

They'll get you part of the way there, but it's a bit like writing
Visual Basic purely by drawing the interface - whenever you need to do
something in the least bit complicated you need to get your hands
dirty with the code, and some of the mappers produce code that isn't
all that easy to follow and edit.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Tuesday, 4 December 2001 14:46:03 UTC