[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Counting indent level

Subject: Re: Counting indent level
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Sep 2008 08:47:40 -0400
Re:  Counting indent level
At 2008-09-29 12:51 +1000, Nicholas Orr wrote:
On 29/09/2008, at 11:38 AM, G. Ken Holman wrote:
<xsl:template match="catalog">
 <xsl:apply-templates select="*"/>
<xsl:template match="group">
 <!--report on the group-->
 <xsl:apply-templates select="item"/>
<xsl:template match="item">
 <!--report on the item-->

The reason for that is that a item node might also contain child
that are also called <item> nodes that I don't want.  I only want a
item node that has it's immediate parent a group node.

Every node (except the root node above the document element) has only a single parent node, so I'm not sure what you mean by "immediate parent". Unless you meant to say "immediate ancestor" which is the parent.

Above you also state you want an item whose parent is catalogue and
not just those whose parent is group.  If I'm wrong, then you'll
have to change the above to the following to not process items that
are not a child of a group:

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

This is the same as the above, the first three lines at least - is that what you meant?

Sorry ... if you wanted to skip item children of catalogue then in the top example it would be select="group".

The code I give you above will process groups and items in document

Ken, does this mean it will retain the overall order though?


I want
to process them (from my original), as an export (like csv) in the
same order so the export would mix and match items and groups :


So it's one single export with both types mixed in the original
order.  This is why I used a single for-each with the "or" to pick up
everything in one go.

You didn't use "or", you used "union" (yes, there's a difference ... sometimes the union feels like and "or" and sometimes the union feels like an "and" ... your for-each statement could read "items and groups and items that are children of groups" which feels like an "and" and not an "or"). It works for you because the union is returned in document order. But in summary, in your code you are making assumptions about your data while in my code I was focused on the result. I think Mike was very eloquent (as always) in explaining the details of this in his post, especially how the words you put forward lead to a particular approach.

. . . . . . . . . Ken

Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.