Subject: RE: [xsl] following-sibling is not working|
From: "rfd ewrew" <xmlquestions101@xxxxxxxxxxx>
Date: Wed, 18 Oct 2006 11:28:01 -0500
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] following-sibling is not working Date: Wed, 18 Oct 2006 11:41:27 -0400
At 2006-10-18 10:34 -0500, rfd ewrew wrote:Thank you Michael. I think the problem is a little more complicated to me and I will try to explain it.
The XML looks like this:
<ele1> <step1><table></table></step1> <graphic>URL for graphic</graphic> <table>This is actually the CALS table model </table> </ele1>
Now, I wanted to template match all elements except graphic and so under ele1 i said
<xsl:apply-templates select=*(not[self::graphic])/> which worked just fine.
The next thing I wanted to do was to check if the following sibling of graphic was table, and if it was table, I wanted to display the table just below the graphic. The "table" element can appear anywhere in the XML, but only if it appears after <graphic> I want it to display below graphic.
This will test the immediately following element is a table:
This <table> element follows the CALS table model.
So under <graphic> template I said
<xsl:if test="following-sibling::table"><xsl:apply-templates select="table" mode="test"/></xsl:if>
Your if is testing all following siblings named "table" and your apply is acting on *children* elements named "table".
But since the CALS table has other elements like tgroup, row, entry which have all templates, when I say <xsl:template match "table" mode="test"> this does not force <table> below <graphic>.
That isn't a match problem ... once you "gain control" of a table you can do with it what you want.
How do I match <table> element which is in CALS format? I even tried adding mode to all other elements under <table> like this:
<xsl:template match="tgroup" mode="test">
That would only work if you used the mode during the apply
Can anyone help me out here?
Perhaps you'll get what you want when you fix the fact you were looking for children named table instead of the immediately following sibling named table.
I hope this helps.
. . . . . . . . . . . . Ken
-- UBL/XSLT/XSL-FO training: Allerxd/Verx Denmark 2006-11-13,17,20/24 UBL International 2006 2006-11-13/17 http://www.ublconference.com World-wide corporate, govt. & user group UBL, XSL, & XML training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal