Hi David,
Thanks a lot for your comments.
It seems as there is still a lot orf work to be done for me :)
best regards,
Roman
-----Ursprüngliche Nachricht-----
Von: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Gesendet: Montag, 06. März 2006 13:03
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] Stylesheet for converting XHTML tables to CALS
I just finished my first attempt to transform XHTML tables
into tables
conforming to the CALS table model.
Attached is my XSLT 2.0 stylesheet. Every feedback is
heartily welcome
:)
You appear to be generating elements in the xhtml namespace
they should probably be in no-namespace or the new docbook 5
namespace or something, seeing as <entry> etc are not xhtml.
<xsl:param name="border" select="if(starts-with(@border,
'0')) then(xs:boolean(0)) else(xs:boolean(1))" as="xs:boolean"
tunnel="yes"/>
you are starting with a boolean value
starts-with(@border,'0')
then if it is true, taking an integer literal and coercing it
to a boolean. If you need boolean values you can just use
true() and false() but here you just need <xsl:param
name="border" select="not(starts-with(@border,'0'))"/>
<xsl:apply-templates
select="xhtml:tr[not(parent::*[local-name()=('thead',
'tbody', 'tfoot')])] | xhtml:tbody/xhtml:tr"/>
It's best not to use local-name() in such tests but just to
use name tests (which are namespace aware) however in this
case the current element is <table> so the parent of every
element selected by xhtml:tr is table and so the filter
testing on local-name is not doing anything.
so it could be
select="xhtml:tr| xhtml:tbody/xhtml:tr"/>
In
<xsl:template match="xhtml:th | xhtml:td">
<xsl:variable name="position"
select="count(preceding-sibling::*) + 1"/>
<entry>
<xsl:if test="@colspan > 1">
<xsl:attribute name="namest">
<xsl:value-of
select="concat('col',$position)"/>
don't you need to take account of any colspan attributes in
earlier columns, and rowspan attributes in earlier rows in
order to know which coulmn an entry in a table corresponds
to? (This is the hardest part of switching between html and
cals tables). In the above you are assuming that the second
td entry in a row is corresponding to the second column, but
this is not the case if the first entry spans columns, or if
an entry in an earlier row spans into the first cell of this row.
David
______________________________________________________________
__________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a
proactive anti-virus service working around the clock, around
the globe, visit:
http://www.star.net.uk
______________________________________________________________
__________
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--