Subject: [xsl] position() test for processing boundaries From: Ron Van den Branden <ron.vandenbranden@xxxxxxxx> Date: Fri, 19 Nov 2004 14:06:57 +0100 |
This is the first time I write to this list, since I have carefully tried to check the archives for an answer to my question. I am struggling with finding ways to delimit processing of descendant nodes based on start and end positions.
A previous posting (http://www.biglist.com/lists/xsl-list/archives/200009/msg00181.html) comes close, but leaves me confused about one aspect. Basically, it has to do with a (seemingly?) difference in the way [position() > ...] and [position() < ...] predicates are evaluated.
<p> <q n="1> <app n="2"> <rdg n="3">rdg1</rdg> <rdg n="4">rdg2</rdg> <rdg n="5">rdg3</rdg> </app> [text] <anchor n="6"/> <app n="7"> <rdg n="8">rdg1</rdg> <rdg n="9">rdg2</rdg> <rdg n="10">rdg3</rdg> </app> </q> [text] <app n="11"> <rdg n="12">rdg1</rdg> <rdg n="13">rdg2</rdg> </app> <anchor n="14"/> <q n="15"> <app n="16"> <rdg n="17">rdg1</rdg> <rdg n="18">rdg2</rdg> <rdg n="19">rdg3</rdg> </app> [text] <anchor n="20"/> text <app n="21" TEIform="app"> <rdg n="22">rdg1</rdg> <rdg n="23">rdg2</rdg> </app> [text] </q> </p>
I am trying to find ways for delimiting the processing of descendants of <p>, so that all and only those elements between a certain start position and a certain end position are processed. Experimenting with ways to express such constraints, I managed to identify a basic problem (in my understanding, probably). I found following differences:
Given following example XSLT fragment triggering processing from START position 3:
<xsl:template match="p"> <xsl:copy-of select="(.//*)[position() > 3]"/> </xsl:template>
This one correctly (or, at least, expectedly) copies all descendant nodes of <p>, starting from <rdg n="4"> up to the end.
However, when I use that same position as END position in following fragment:
<xsl:template match="p"> <xsl:copy-of select="(.//*)[position() < 3]"/> </xsl:template>
All direct children of <p> are returned that occur before the 3rd direct child:
<q n="1"> <app n="2"> <rdg n="3">rdg1</rdg> <rdg n="4">rdg2</rdg> <rdg n="5">rdg3</rdg> </app> [text] <anchor n="6"/> <app n="7"> <rdg n="8">rdg1</rdg> <rdg n="9">rdg2</rdg> <rdg n="10">rdg3</rdg> </app> </q> <app n="2"> <rdg n="3">rdg1</rdg> <rdg n="4">rdg2</rdg> <rdg n="5">rdg3</rdg> </app>
This seems to suggest that the position test in case (A) is applied at the level of the deepest descendant, while in case (B) at the level of the first generation of descendants.
Could anyone explain what makes the difference? Any suggestions for the right way to delimit processing of descendant nodes up to a certain position (in this example only the nodes appearing before <rdg n="3">)?
-- Ron Van den Branden Wetenschappelijk attachi Centrum voor Teksteditie en Bronnenstudie (CTB) Koninklijke Academie voor Nederlandse Taal- en Letterkunde (KANTL) Koningstraat 18 / b-9000 Gent / Belgium e-mail : ron.vandenbranden@xxxxxxxx http://www.kantl.be/ctb/staff/ron.htm
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl key related, Thomas Vanparys | Thread | RE: [xsl] position() test for proce, Michael Kay |
[xsl] xsl key related, Mark Ivs | Date | RE: [xsl] position() test for proce, Michael Kay |
Month |