Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Michael Sokolov" <sokolov@--------.--->
To: <xsl-list@-----.------------.--->
Date: 7/3/2009 1:07:00 PM
 

> -----Original Message-----
> From: Wendell Piez [mailto:wapiez@m...] 
...
 
> At 04:53 AM 7/2/2009, Michael Ludwig wrote:
> >I have an editor macro that produces the stylesheet skeleton plus 
> >identity template, as this is almost always the right starting point 
> >for a new stylesheet.
> 

...

> >Note that XSLT has built-in template rules that basically lose the 
> >markup and display the text only. Most of the time you'll want to 
> >supplant these by the identity template. Some people even think that 
> >the identity template should have been the built-in template rule.
> 
> And some don't. Some (like myself), think that might be a 
> useful option to allow -- at the cost, perhaps, of making 
> XSLT even more mysterious to beginners. :-)
> 
> >Bottom line, start with the identity template.
>

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:

>>  <xsl:template match="@*|node()"><!-- identity template -->
>>    <xsl:copy>
>>      <xsl:apply-templates select="@*|node()"/>
>>    </xsl:copy>
>>  </xsl:template> 

I would almost certainly have gotten a first working stylesheet more quickly
if the default were swapped.  And for the other case (ie when you want your
document turned in to text by default), the required rule to supplant the
copy-by-default is a lot simpler:

<xsl:template match="*">
   <xsl:apply-templates />
</xsl:template>

It's much easier to understand what this is doing.

I suppose a possible benefit of the current situation is that by grappling
with the identity transform, beginners are immediately forced to learn about
the difference between nodes, text, elements and attributes, including the
bizarre conceit that attribute *nodes* are not matched by the 'node()' test
(perhaps some other name would have been more appropriate?).  This is
required knowledge, so I guess the earlier swallowed the better?

Of course all this discussion seems besides the point and entirely academic
given the well-established precedents.  Can't go changing these defaults
now.  But that's no reason to try to provide post-hoc justifications,
either, IMO.

-Mike


--~------------------------------------------------------------------
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