This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: CALS and keys (difficult)


I had to do something quite similar to this - here's some code:

<xsl:template match="entry">
<th>
<xsl:if test="@spanname">
	<xsl:variable name="namest"
select="ancestor::tgroup/spanspec[@spanname=current()/@spanname]/@namest"/>
	<xsl:variable name="nameend"
select="ancestor::tgroup/spanspec[@spanname=current()/@spanname]/@nameend"/>
	<xsl:variable name="colst"
select="ancestor::*[colspec/@colname=$namest]/colspec[@colname=$namest]/@col
num"/>
	<xsl:variable name="colend"
select="ancestor::*[colspec/@colname=$nameend]/colspec[@colname=$nameend]/@c
olnum"/>
	<xsl:attribute name="colspan"><xsl:value-of select="number($colend)
- number($colst) + 1"/></xsl:attribute>
</xsl:if> 
</th>
</xsl:template>

which I think is okay and correctly identifies the right colspecs for theads
and tbodys.  I don't know if it's very efficient, though, and it won't work
for entrytbl's with spanspecs.

Hope this helps,
David.
--
David McNally            Moody's Investors Service
Software Engineer        99 Church St, NY NY 10007 
David.McNally@Moodys.com            (212) 553-7475 




> From: Andrew Welch [mailto:andrew@thebristoldirectory.com]
> So, I need this psuedocode converted to xsl (I think using keys):
> 
> match <entry>
> if it has attribute spanname
>   find ancestor <spanspec> with same spanname attribute
>     get namest attribute
>     get nameend attribute
>   work out number of columns from colspec, based on colname attributes
>   output 'colspan=' the value
> 
> 
> ===The XML snippet===
> <tgroup cols="4">
>   <colspec colname="C.9P2" colnum="1" colwidth="55mm"/>
>   <colspec colname="C.9PC" colnum="2" colwidth="32mm" align="CENTER"/>
>   <colspec colname="C.9PE" colnum="3" colwidth="32mm" align="CENTER"/>
>   <colspec colname="C.9PG" colnum="4" colwidth="49mm"/>
>   <spanspec spanname="S.9PA" namest="C.9PB" nameend="C.9PD"/>
>   <thead valign="MIDDLE">
>      <colspec colname="C.9PH" colnum="1" colwidth="55mm"/>
>      <colspec colname="C.9PB" colnum="2" colwidth="32mm" 
> align="CENTER"/>
>      <colspec colname="C.9PD" colnum="3" colwidth="32mm" 
> align="CENTER"/>
>      <colspec colname="C.9PF" colnum="4" colwidth="49mm"/>
>      <row rowsep="1">
>         <entry colname="C.9PH" morerows="1" valign="MIDDLE"
> align="CENTER">Item</entry>
>         <entry spanname="S.9PA" rowsep="1" 
> align="CENTER">Location</entry>
>         <entry colname="C.9PF" morerows="1" valign="MIDDLE"
> align="CENTER">Access</entry>
>      </row>
>      <row rowsep="1">
>         <entry colname="C.9PB" align="CENTER">Zone</entry>
>         <entry colname="C.9PD" align="CENTER">Compartment</entry>
>      </row>
>   </thead>
> 
> ===The Required HTML===
> <tr>
>   <th rowspan="2" align="CENTER" valign="MIDDLE">Item</th>
>   <th colspan="2" align="CENTER">Location</th>
> <th rowspan="2" align="CENTER" valign="MIDDLE">Access</th>
> </tr>
> <tr>
>   <th align="CENTER">Zone</th>
>   <th align="CENTER">Compartment</th>
> </tr>
> 

> 


---------------------------------------

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission.  If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited.  If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments.  Thank you.

Every effort is made to keep our network free from viruses.  You should, however, review this e-mail message, as well as any attachment thereto, for viruses.  We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]