Sjoerd Visscher's weblog
Last Update
10/16/2005; 1:29:26 AM
Saturday, December 20, 2003
XQueryX to XSLT conversion
The XML Query Working Group has released an updated Working Draft of XML Syntax for XQuery 1.0 (XQueryX). Designed to be read with the XQuery language and its formal semantics, the document proposes that XQueryX will be an optional conformance level. The Working Group invites comments.[World Wide Web Consortium]
I missed the previous draft, which is 2.5 years old. My first impression: weird. Being used to XSLT, I had not expected that the XPath expression would also be converted to XML. But the XQuery designers see XQuery as an extension to XPath, so it makes sense that way. It also makes XQueryX more interesting.
The XML is full of constructs like this:
<xqx:expr xsi:type="xqx:flworExpr">
I find this very ugly. This is probably done because xqx:expr is allowed at a lot of places, and there are numerous subtypes of xqx:expr. But adding the following line to the schema would make it possible to simply write <xqx:flworExpr>
<xsd:element name="flworExpr" type="flworExpr" substitutionGroup="expr" />
Just to play with it (it's so much easier to play with a language when the parser is ubiquitously available), I created an XSLT stylesheet that tries to transform XQueryX to XSLT. It created XSLT 1.0 stylesheets, but if XPath 2.0 functions are used (like distinct()) the version has to be changed to 2.0 to get a valid XSLT document. Here are the converted examples: example 1, example 2, example 3.
Wednesday, December 17, 2003
“So you think you know how to program a Web App do ya?”
Check this out for a mind bender from Christian Tismer. Methinks continuations may make a comeback. Not only are they excellent for web programming (as Christian's example shows) but they are great for event driven architectures such as (as far as I'm concerned) any SOA worthy of the name. [Sean McGrath, CTO, Propylon]
Whenever continuations are mentioned to solve web application problems, I’m thinking client side programming makes it all even easier. This demo I might even be able to do in this post:
Tuesday, December 16, 2003
A shamelessly courted link
This is a nice idea! (That's not a shamelessly courted comment. Uhm, well, not directly anyway)
Monday, December 15, 2003
Providing context in programming (part 1)
Bryn Keller is right, my previous post needs a bit more explanation. The point Sean McGrath was making is that a number is as good as meaningless without context. XML nicely provides this context. I want to translate that to programming.
The importance of context for data structures in a datafile is probably more obvious than context for data structures in a program. But if you think about the problems with understanding a program, there can be two issues. Either you don't understand the syntax or semantics of the programming language, or you don't understand the relation between the purpose of the program and the data structures and the operations (algorithms) on them. The former part is probably better solved by educating those who have to understand the program. (Not using the full power of the programming language would be a waist.) So writing understandable programs means focusing on the latter part.
The obvious translation of the way XML provides context to data is using objects or records. But also assigning data to a properly named variable could be enough to provide the context. Now the problem with lists and tuples: they provide very little context. This does not mean they should never be used, only that little bit of context conforms with how the data is used in the program. What this means is actually very different for tuples and lists.
What context provides a list? Nothing more than that there's a list of items. The number of items is variable, possibly empty. The order of the items might have meaning, but is certainly not fixed. And all items in the list have the same role in the program. This means that when someone has to update your program, he can decide to f.e. filter the list or sort the list, anywhere in your program. If the way your program uses a list puts extra restrictions on the ways to modify the list, you'd better fill your program chock-full of comments to prevent future bugs.
More later… part 2