[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stylesheet for converting XHTML tables to CALS

Subject: Re: Stylesheet for converting XHTML tables to CALS
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 6 Mar 2006 12:03:08 GMT
xhtml table
> 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 &gt; 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
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.