[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] returning nodes which have a specific child
Subject: Re: [xsl] returning nodes which have a specific child From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 3 Jul 2009 15:34:55 +0100 |
> I'm w/Michael on this one, at least from the perspective of clarity and ease > of learning. The number one confusion for me when learning XSLT a couple of > years ago was the mysterious disappearance of all my tags, and the necessity > of learning, as almost the first step required to get anything useful done, > an arcane identity transformation: As Wendell said, it depends a lot on the kind of stylesheets you write. The original motivating use case for the design of XSLT wastransforming to a presentational format (html or xsl-fo) and considering the case of html for example. The default behaviour is guaranteed to generate valid html document. Then as you decide you need more html markup in the result, you add more templates, and it all works very naturally. For the kind of transformation where you are "not doing much" and so want to start off with the identity template, the default is not so useful, but the identity template was given as an example in xslt from the earliest drafts. It might not be the first thing that comes in to a beginners head, but then <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" probably isn't the most memorable thing either. Some thigs you can just learn by rote until you get the experience to understand what the various constructs mean. In my own stylesheets, they are probably "identity" based in only a very small percentage of my code. If you are stating with some in XML in an in house markup, and generating html or xhtml, or C code or C# code, or matlab, or maple or ... Then the stylesheets are all very different but in all cases they have the property that you don't want _any_ of the original markup to survive into the result. Actually I don't usually leave the default template in action, even if I am not overriding with an identity template. In the other cases I usually start off with <xsl:template match="*"> <xsl:message select="'unexpected element: ',name()"/> <xsl:apply-templates/> </xsl:template> Then the specification for any new stylesheet project is essentially "add new templates until the stylesheet stops complaining about elements in the input..." David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] returning nodes which hav, Michael Ludwig | Thread | RE: [xsl] returning nodes which hav, Michael Kay |
RE: [xsl] returning nodes which hav, Michael Sokolov | Date | [xsl] Merge Two Files, Brad Felix |
Month |