X-Reyes

Friday, January 27, 2006

Catching errors and confirming results...

The XSLT pipeline processor that I created in order to apply the multiple transforms necessary to generate a rendered result is in need of two things:

1) It needs to report that an empty sequence from a process is an error, and a fatal one at that. Fairly obvious really!

2) Secondly, it would be nice if one could declare what the expected result should be.

Of course if I knew, in great detail, what the result was going to be before hand, then you have to ask yourself why have I created all of this mechanism in the first place. It's a bit self referential.

No, what I'm thinking of is declaring some pattern that can be applied to the result in order to provide some high level verification that the result is looking like what I'd expect. This is not comparing the differences, it's more of a case of 'have I got the right number of blocks?' or 'Does this node exist?'.

Now the obvious candidate for this is an XPath expression that is bound to a process and is evaluated against the result of the process. If the expression evaluates to true, then proceed, otherwise exit the pipeline gracefully and let me know what went wrong.

Now this sounds all very well and good, but, and there is one big but, the only easy way to evaluate an XPath expression is to use the saxon:eval() extension function. Now the thing is, I don't like using implementation specific extensions because they aren't transferable. Of course you could implement a simple XPath evaluator in XSLT by tokenizing the path expression, using regular expressions and recursively processing the path steps. I'll only do that if I'm ever so bored that I haven't got anything better to do!

Labels: , , ,

0 Comments:

Post a Comment

<< Home