Re: [xsl] mixed content grouping by whitespace

Subject: Re: [xsl] mixed content grouping by whitespace
From: James Cummings <james@xxxxxxxxxxxxxxxxx>
Date: Mon, 12 Apr 2010 15:33:04 +0100
On Mon, Apr 12, 2010 at 12:34, G. Ken Holman
<gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> They do, the end result is the same. B But I perceived what I was doing as
> preserving the text as a text node and then copying the text node. B Asking
> for the value of an element does a recursive descent below the element
> looking for all text nodes. B Sure there is only one, so it isn't going to
go
> far. B But the philosophy of taking the value of an element to me was
> different than simply copying that text node I created to preserve the
> white-space. B I wrote it to support the way I was thinking about it.

I suppose that makes sense. I wonder if that is also more efficient
for the processor as well.

>> This works because
>> you're doing group-starting-with() so you know the first thing in the
>> group is the my:text node.
> The first thing *may* be a my:text node. B All of the lines don't start
with
> white-space, so all of the lines will start with a group without a my:text
> element. B Remember that in the start of a group the current node is the
> first member of the group. B Which is why I'm using the self:: axis to
ensure
> that I'm only copying the nodes of the first of the group if the first of
> the group is a my:text element.

Yes, it is that this is really a conditional copy-of that wasn't
apparent to me at the start. I.e. that because there is
self::my:text/node() it will only copy if the first member of the
group (which is the context node inside for-each-group) is a my:text
node. For a moment I had some unease about whether only having this at
the start (before the <w>) meant I was somehow missing a my:text from
the end, but of course, since it is 'group-starting-with' that is not
the case, as if it was there it would be a new group.

> People gripe about namespaces but note how I was able to use my own
> namespace to add unambiguously my own information to the old information.

No, I like namespaces. They are a difficult sell to some of the TEI
community, but entirely necessary and wonderful.  Though I would have
(like Gerrit) just done it still in the TEI namespace since I was
getting rid of it afterwards, I understand the benefit of clarity that
doing it in a separate namespace provides.

>> These things are B starting to make my brain melt less than previously,
>> which is a start I guess.
> Good! B Grouping is a very powerful tool in XSLT 2.0.

Oh yes, I know that. It is in my top 3 things I like in XSLT2
Everytime I post here at the moment it seems to be grouping-related
(or analyze-string/regex).  I've started looking at other problems in
life as just really grouping problems. ;-)

-James

Current Thread