Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] returning nodes which have a specific child

From: David Carlisle <davidc@---.--.-->
To: xsl-list@-----.------------.---
Date: 7/3/2009 2:35:00 PM

> 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. 
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent