xsl-list
[Top] [All Lists]

Re: [xsl] mixed content grouping by whitespace

2010-04-12 09:33:49
On Mon, Apr 12, 2010 at 12:34, G. Ken Holman
<gkholman(_at_)cranesoftwrights(_dot_)com> wrote:
They do, the end result is the same.  But I perceived what I was doing as
preserving the text as a text node and then copying the text node.  Asking
for the value of an element does a recursive descent below the element
looking for all text nodes.  Sure there is only one, so it isn't going to go
far.  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.  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.  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.  Remember that in the start of a group the current node is the
first member of the group.  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  starting to make my brain melt less than previously,
which is a start I guess.
Good!  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

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