Subject: Re: [xsl] selecting associated headings based on sequence position From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 31 Jul 2008 09:50:01 -0400 |
I figured out a solution:
<xsl:template match="Cell"> <xsl:variable name="pos" select="position()"></xsl:variable> <b><xsl:value-of select="/Worksheet/Table/Row[1]/Cell[position() eq $pos]/Data"/></b> <xsl:value-of select="Data"></xsl:value-of><br/> </xsl:template>
It seemed difficult because I couldn't figure out how to get the position of the current Cell element from within the xpath expression... position() allows no arguments and only works on the current context.
<xsl:template match="Cell"> <xsl:variable name="pos" select="count(preceding-sibling::Cell)"/> <b><xsl:value-of select="/Worksheet/Table/Row[1]/Cell [count(preceding-sibling::Cell) eq $pos]/Data"/> </b> <xsl:value-of select="Data"/><br/> </xsl:template>
<xsl:variable name="pos" select="count(preceding-sibling::Cell) + 1"/> <b> <xsl:value-of select="/Worksheet/Table/Row[1]/Cell[$pos]/Data"/> </b>
You need to be aware that this won't work if there are empty cells. Excel doesn't output empty elements to represent such cells, rather it includes attributes on the next cell that isn't empty to give its position.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] selecting associated head, Rushforth, Peter | Thread | RE: [xsl] selecting associated head, Rushforth, Peter |
RE: [xsl] coping with missing exter, Wendell Piez | Date | Re: [xsl] How to allow element to a, CyberSpace Industrie |
Month |