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

RE: problem with spreadsheet-like xml structure

Subject: RE: problem with spreadsheet-like xml structure
From: max@xxxxxxxxxx
Date: Sat, 11 Jun 2005 23:00:51 +0200 (CEST)
ss type datetime
Thanks for the (very fast) answer!

Actually there are a lot more cells, so I have to use:

<xsl:if test="(position()  = 2) or (position()  = 7) or (position()  = 12)
or (position()  = 17) or (position()  = 22) ">
	<xsl:element name="location">
		<xsl:element name="name">
			<xsl:value-of select="./ss:Data"/>
		</xsl:element>
		<xsl:attribute name="arrival">
			<xsl:value-of select="following-sibling::ss:Cell/ss:Data[1]"/>
		</xsl:attribute>

	</xsl:element>
</xsl:if>

But it doesn't work, the (real) data is:

 <Row>
    <Cell><Data ss:Type="String">Abrikosov</Data></Cell>
    <Cell><Data ss:Type="String">Moscow, Russia</Data></Cell>
    <Cell><Data ss:Type="DateTime">1928-06-25T00:00:00.000</Data></Cell>
    <Cell ss:StyleID="s21"><Data ss:Type="String">55.7506N</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">37.6276E</Data></Cell>
    <Cell ss:Index="7"><Data ss:Type="String">Argonne, Illinois,
USA</Data></Cell>
    <Cell ss:StyleID="s26"><Data ss:Type="Number">1991</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">41.6688N</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">87.9846W</Data></Cell>
    <Cell><Data ss:Type="String">National laboratory</Data></Cell>
    <Cell><Data ss:Type="String">Stockholm, Sweden </Data></Cell>
    <Cell ss:StyleID="s26"><Data ss:Type="Number">2003</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">59.3323N</Data></Cell>
    <Cell ss:StyleID="s22"><Data ss:Type="String">18.0651E</Data></Cell>
    <Cell><Data ss:Type="String">Nobel Prize inPhysics</Data></Cell>
    <Cell ss:StyleID="Default"><Data ss:Type="String">Argonne, Illinois,
USA</Data></Cell>
    <Cell><Data ss:Type="Number">1991</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">41.6688N</Data></Cell>
    <Cell ss:StyleID="s39"><Data ss:Type="String">87.9846W</Data></Cell>
    <Cell><Data ss:Type="String">National Laboratory</Data></Cell>
    <Cell ss:Index="23" ss:StyleID="Default"/>
    <Cell ss:StyleID="Default"/>
    <Cell ss:Index="29" ss:StyleID="Default"/>
   </Row>


> If you know that the data is in groups of three, you can use
>
> <xsl:template match="row">
>   <xsl:for-each select="cell[position() mod 3 = 1]">
>     <location>
>       <name><xsl:value-of select="."/></name>
>       <note><xsl:value-of select="following-sibling::cell[1]"/></note>
>       <date><xsl:value-of select="following-sibling::cell[2]"/></date>
>     </location>
>   </
> </
>
> Michael Kay
> http://www.saxonica.com/
>
>
>> -----Original Message-----
>> From: max@xxxxxxxxxx [mailto:max@xxxxxxxxxx]
>> Sent: 11 June 2005 21:40
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject:  problem with spreadsheet-like xml structure
>>
>> Hi all,
>>
>> I am trying to convert data in an Excel's xml-format to a
>> custom xml-format.
>> The logical structure of the Excel data is
>>
>> <table>
>> <row>
>>
>> <cell> location1 <cell>
>> <cell> note <cell>
>> <cell> date1 <cell>
>>
>> <cell> location2 <cell>
>> <cell> note2 <cell>
>> <cell> date2 <cell>
>>
>> <cell> location3 <cell>
>> <cell> note3 <cell>
>> <cell> date3 <cell>
>>
>> </row>
>> <row>
>> ...
>> </row>
>> </table>
>>
>> What I need is:
>>
>> <row>
>>
>> <location date="date1">
>> <name>location1</name>
>> <note>note1</note>
>> </location>
>>
>> <location date="date2">
>> <name>location2</name>
>> <note>note2</note>
>> </location>
>>
>> <location date="date3">
>> <name>location3</name>
>> <note>note3</note>
>> </location>
>>
>> <row>
>>
>> I can get the location cells ( using position() ) and place
>> the cell data
>> into my location element but
>> then I don't know how to place the following cells inside
>> this location
>> element.
>>
>> <xsl:if test="position() =1 ">
>> 	<xsl:element name="location">
>> 		<xsl:element name="name">
>> 				<xsl:value-of select="."/>
>> 			</xsl:element>
>>
>> 		<!-- PLACE HERE NEXT TWO CELLS -->
>>
>> 		</xsl:element>
>> </xsl:if>

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.