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

Re: Transformation of generic spreadsheet XML

Subject: Re: Transformation of generic spreadsheet XML
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 19 Apr 2001 16:01:47 +0100
different template in spreadsheet
Hi Xiaocun,

> XSL I have so far:
> 1. first capture the header:
>         <xsl:template match="row" mode="BidsDetail">
>                 <xsl:if test="string(cell[1]) = string('BidType')">
>                         <xsl:variable name="bidHeader" select="."/>
> 2. process each bid from the rows following the
> heading row:    
>         <xsl:for-each select="following-sibling::row">
>                 <xsl:element name="Bid">
>                         <xsl:for-each select="cell">

I think you'd be better off storing the bidHeader row in a global
variable (assuming that the row elements are children of a 'rows'
document element here):

<xsl:variable name="bidHeader" select="/rows/row[1]" />

Then you could apply templates to only the rows after the first row:

<xsl:template match="rows">
   <xsl:apply-templates select="row[position() > 1]" />
</xsl:template>

And then have a row-matching template to give the Bid element.  Within
that template, apply templates to all the cell elements:

<xsl:template match="row">
   <Bid>
      <xsl:apply-templates select="cell" />
   </Bid>
</xsl:template>

You can then have different templates for cell elements that have a
column attribute greater than 7, and other cell elements.  To answer
your question, you can get the relevant cell by comparing its column
attribute to the column attribute of the current cell, which you can
get with:

  current()/@column

So the cell-matching templates look like:

<!-- most cells make attributes -->
<xsl:template match="cell">
   <xsl:attribute
         name="{$bidHeader/cell[@column = current()/@column]}">
      <xsl:value-of select="." />
   </xsl:attribute>
</xsl:template>

<!-- other cells make ExtendedAttribute elements -->
<xsl:template match="cell[@column &gt; 7]">
   <ExtendedAttribute
      ExtendedAttributeCode="{$bidHeader/cell[@column = current()/@column]}"
      ExtendedAttributeValue="{.}" />
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


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.