RE: [xsl] Transformation of generic spreadsheet XML

Subject: RE: [xsl] Transformation of generic spreadsheet XML
From: "Xuegen Jin" <xjin_imi@xxxxxxxxx>
Date: Thu, 19 Apr 2001 12:56:13 -0400
After the <xsl:for-each select="cell">, add a variable 
<xsl:variable name="column" select="@column" />
then wherever you have $bidHeader/cell[position()]
change it to $bidHeader/cell[position()=$column]

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Xiaocun Xu
Sent: Thursday, April 19, 2001 8:15 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Transformation of generic spreadsheet XML


	I am having some problem transforming generic
spreadsheet XML into XML format I need.  The source
and desired target XML are shown below:

source XML:
    <cell column="1">BidType</cell>
    <cell column="2">LineItemCode</cell>
    <cell column="3">SupplierItemCode</cell>
    <cell column="4">Minimum</cell>
    <cell column="5">Maximum</cell>
    <cell column="6">PricePerUnit</cell>
    <cell column="7">OneTimeCharge</cell>
    <cell column="8">Color</cell>
    <cell column="9">Size</cell>
    <cell column="1">simple</cell>
    <cell column="2">AC74.000.101</cell>
    <cell column="3">3.1</cell>
    <cell column="6">400</cell>
    <cell column="8">blue</cell>
    <cell column="9">x-large</cell>

desired target XML:
<Bid BidType="simple" LineItemCode="AC74.000.101"
SupplierItemCode="3.1" PricePerUnit="400">
	<ExtendedAttribute ExtendedAttributeCode="Color"
	<ExtendedAttribute ExtendedAttributeCode="Size"

In general, what I need are:
1. For the first row, the first 7 columns are fixed
attributes, and therefore need to be transformed into
attribute names for Bid element.
2. For the first row, all columns after the 7th column
are extended attributes, and therefore need to be
transformed into ExtendedAttribute elements.
3. All rows after the first row will fill in for the
appropriate values according to the column attribute.

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">
3. use xsl:choose to separate out columns greater than
7 and add them as ExtendedAttributes, otherwise Bid
		<xsl:when test="@column &gt; 7">
			<xsl:element name="ExtendedAttribute">
				<xsl:attribute name="ExtendedAttributeCode">
				<xsl:attribute name="ExtendedAttributeValue">
					<xsl:value-of select="."/>
				<xsl:value-of select="."/>

The problem:
$bidHeader/cell[position()] I inserted for the
xsl:value-of are obviously incorrect, since what I
really want is: $bidHeader/cell where cell/@column
equals current @column.  How could I get that result?

Much thanks,

Xiaocun Xu

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

 XSL-List info and archive:

Do You Yahoo!?
Get your free address at

 XSL-List info and archive:

Current Thread