Subject: RE: [xsl] Re: On XSLT 2.0 Writing Styles From: "Michael Kay" <mhk@xxxxxxxxx> Date: Sat, 11 Oct 2003 17:55:52 +0100 |
> > I understand this as personal preference or is this > preference based on some objective criteria? It's based on instinctive judgements about the engineering quality of the code, but it's far too early to judge whether my instincts are right. > > I would appreciate your opinion on how do these two styles -- > long (20-line > +) XPath expressions versus xslt-structured style -- score in > +readability, > compactness, flexibility, efficiency and maintainability. There has been an ongoing debate about the merits of using XML syntax versus non-XML syntax for a while now, and I don't think it's going to go away. It promises to be one of these perennials like "elements vs attributes". Some people seem to take an instinctive dislike to having attributes in an XML document whose content is 20 lines long. Part of the rationale is that the newlines don't survive XML parsing, but the newlines are essential to the readability of the code. I think it's going to be quite unusual to see XQuery parsers that report more than one syntax error in a single compile run. The grammar is not robust enough to allow easy recovery from syntax errors, though the introduction of semicolons as separators in the latest draft helps. Reporting multiple errors in XSLT is easy because of the 3-phase parsing approach (XML parsing first, then XSLT, then XPath). This gives a definite advantage when you're doing something on the DocBook scale. > > In other words, why should we prefer the "XSLT style" to the > "XQuery style"? > I think the advantages of an XML-based syntax are: (a) it's useful where the stylesheet includes large chunks of stuff to copy into the result document (b) it's useful when you want to transform stylesheets or to do any kind of reflection or introspection (c) it reuses all the XML machinery such as character encodings, base URIs, entity references (d) it's much easier to provide user or vendor extensions to the language in a controlled way. But there's no doubt that the XQuery style makes it much easier to write short queries. Michael Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: On XSLT 2.0 Writing Style, Dimitre Novatchev | Thread | [xsl] Re: Re: On XSLT 2.0 Writing S, Dimitre Novatchev |
RE: [xsl] Re: Re: Re: XSLT 2.0: On , Michael Kay | Date | [xsl] Re: Re: On XSLT 2.0 Writing S, Dimitre Novatchev |
Month |