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

RE: Rusty at XSLT, need help ("Oil can!, Oil can!")

Subject: RE: Rusty at XSLT, need help ("Oil can!, Oil can!")
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 26 Apr 2010 23:13:41 +0100
RE:  Rusty at XSLT
Apart from the problems that have been pointed out, the other problem is
that in the XML output from Excel, empty cells are often omitted, their
presence signalled only by the existence of an attribute on the next Cell
element that indicates what column number it is in. This makes processing
the XML quite challenging. When I used to do this regularly, I would
generally preprocess the XML with a generic stylesheet that added column
numbers as attributes to every cell, and then use these attribute values to
retrieve the cell, rather than using positional indexing.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 
 

> -----Original Message-----
> From: cknell@xxxxxxxxxx [mailto:cknell@xxxxxxxxxx] 
> Sent: 26 April 2010 22:06
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Rusty at XSLT, need help ("Oil can!, Oil can!")
> 
> I used to haunt this list when I was writing XSLT every day, 
> but it's been a few years now, and I feel like the Tin 
> Woodsman when caught in the rain. I am rusty and I need an 
> application of the oil can.
> 
> I am trying to extract the text from particular elements in 
> an Excel workbook which has been saved to XML format. The 
> structure, in short, is this:
> 
> <Workbook>
>   <DocumentProperties/>
>   <ExcelWorkbook/>
>    <Worksheet>
>       <Names/>
>         <Table>
>            <Column/>
>            <Row>
>               <Cell/>
>               <Cell/>
>               <Cell>
>                  <Data>Randolph</Data>
>                  <NamedCell/>
>               </Cell>
>            </Row>
>         </Table>
>          <WorksheetOptions/>
>    </Worksheet>
> </Workbook>
> 
> There is at least one <Worksheet> Element.
> 
> So here I am thinking, "This should be easy. Start with 
> selecting the text of the first cell in the first row on the 
> first worksheet."
> 
> So I use this XSLT:
> 
> <?xml version="1.0"?>
> 
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 		xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
> 		
> 		<xsl:template match="/">
> 			<xsl:value-of 
> select="Workbook/Worksheet[1]/Table/Row[3]/Data" />
> 		</xsl:template>
> </xsl:stylesheet>
> 
> thinking that the output will be "Randolph" because I can see 
>  that in the source document . But no, the only output I get 
> is the XML document declaration!
> 
> Please someone have pity on a fallen-away XSLT programmer 
> trying to be in the good graces of the W3C.
> 
> What am I doing wrong?
> 
> Thanks.
> --
> Charles Knell
> cknell@xxxxxxxxxx - email

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.