xsl-list
[Top] [All Lists]

Re: [xsl] things about grouping

2012-11-28 01:04:16
On Sat, Nov 24, 2012 at 10:43 PM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
On 24/11/2012 05:54, Ihe Onwuka wrote:

1. <xsl:apply-templates select="current-group() except blah"/>

still applies templates to blah

well current-group() except blah selects all nodes in the current group
except blah nodes that are children of the current node. so it won't apply
templates to "blah" if blah is interpreted as a relative xpath
from the current node. If you mean don't select elements in the current
group that match blah then

current-group()[not(self::blah)]

is probably as clear as any of the alternatives.


Clear? In the not too distant past I taught XPath to overseas students
- I can just see the looks on their faces now. I must make time to
watch this video.

" Programmers can only understand their code by pretending to be
computers and running it in their heads. As this video shows, this is
increadibly inefficient and, as we generally have a computer in front
of us......."

http://www.i-programmer.info/news/112-theory/3900-a-better-way-to-program.html.

More recently from the same source -
http://worrydream.com/LearnableProgramming

The translation of <xsl:apply-templates select="current-group() except
current-group()/self::blah"/>  is

everything in the left hand side of the except but  not in the right hand side.

Semantically that is describing the concept of difference in a set
theoretical context.

Well XPath has direct support for union and intersect so for
completeness we would expect it to support difference. Thats
reasonable isn't it. So lets go to the part of the specification that
deals with set theoretic operators and see what it says.

The first hint of trouble is in the URL.

http://www.w3.org/TR/xpath-functions/#union-intersection-except

Lets read on and see why there is support for union and intersection
and not difference.

op:union        Returns the union of the two sequence arguments, eliminating
duplicates.
op:intersect    Returns the intersection of the two sequence arguments,
eliminating duplicates.
op:except       Returns the difference of the two sequence arguments,
eliminating duplicates.

So difference is supported except (pun intended) it is called except.

But (sic) the semantic of except  that has been ingrained in us since
childhood is that when you say  A except B, B takes it context from A.

This applies to all employess except directors.
All my kids except Jimmy.

I know people that were involved in drafting that specification read this group.

So I am going to out myself as a whining quiche eater and ask the
obvious question.

Why.

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>