Subject: Re: [xsl] Question about table column width in XSLT/XSLFO From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 17 Oct 2006 12:51:35 -0400 |
Well, I am a little confused. Please bear with me as I try to explain.
My XML does not have "colnum" as an attrinute to 'colspec".
It only has "colname",
and the "entry" tag has the "namest" and "namend". The "colname" tag has names of the columns like "c1", "c2" etc. So how the XML for entry will have <entry namest="c1" namend="c9">
Right. That is typical of OASIS/CALS tables. Many of us have seen a lot of this.
How do you achieve column span using these column names instead of column numbers in xslt?
Thank you for all your patience and help.
You are welcome, but it seems you did not even try using my previous answer to this same question. I outlined an untested example of the kind of code you need to answer your question. At which part of using my example did you have problems?
Below is the same example, but polished up with your actual test data from your earlier post to illustrate what I gave you in my last post. This code is actually tested. It takes more time to volunteer a tested working solution than to answer inquiries of the general direction to take when solving a problem.
The code below determines the number of columns being spanned by the namest= and nameend= attributes when the current node is <entry>, and assigns the value to the colspan= attribute.
What part of the example in my earlier email, as modified below, didn't work for you?
T:\ftemp>type meenakshi.xml <?xml version="1.0" encoding="US-ASCII"?> <table tocentry="Y"> <tgroup align="left" charoff="50" cols="4"> <colspec colname="c1" colwidth="1.50in"> </colspec> <colspec colname="c2" colwidth="2.0in"> </colspec> <colspec colname="c3" colwidth="3.0in"> </colspec> <colspec colname="c4" colwidth="1in"> </colspec> <tbody valign="top"> <row> <entry namest="c1" nameend="c3"/> <entry namest="c1" nameend="c2"/> <entry namest="c2" nameend="c3"/> </row> </tbody> </tgroup> </table> T:\ftemp>type meenakshi.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <xsl:for-each select="//entry"> <test colspan="{ count(ancestor::table[1]/*/colspec[@colname=current()/@nameend]/ preceding-sibling::colspec ) - count(ancestor::table[1]/*/colspec[@colname=current()/@namest]/ preceding-sibling::colspec ) + 1 }"/> </xsl:for-each> </xsl:template>
T:\ftemp>xslt meenakshi.xml meenakshi.xsl con <?xml version="1.0" encoding="utf-8"?> <test colspan="3"/> <test colspan="2"/> <test colspan="2"/> T:\ftemp>
-- 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Question about table colu, ms | Thread | [xsl] Even/Odd + Reference orientat, Sakib R Saikia |
Re: [xsl] Determining if an optiona, Richard Lewis | Date | Re: [xsl] Determining if an optiona, Sam Carleton |
Month |