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

Re: problems with position() and following-sibling

Subject: Re: problems with position() and following-sibling
From: Kenneth Stephen <marvin.the.cynical.robot@xxxxxxxxx>
Date: Fri, 12 Aug 2005 10:25:58 -0500
following sibling position
George,

    1.  Everywhere you've coded following-sibling::Cell[7] - you need
to replace that with ../Cell[7] .
    2.  The Excel format has a default namespace of
urn:schemas-microsoft-com:office:spreadsheet set on the root element
(Worksheet). You need to be using that in your XPath expressions too.
In the following example, I've mapped that namespace to "ss" :

	<xsl:template match="ss:Row">
		<row>
			<xsl:apply-templates />
		</row>
	</xsl:template>

	<xsl:template match="ss:Cell[position() &gt; 1 and position() &lt; 7]">
		<entry>
			<xsl:value-of select="ss:Data" />
			<xsl:if test="position()=3 and ../ss:Cell[7]">
				<xsl:message>+++ making footnote +++</xsl:message>
				<footnote>
					<para>
						<xsl:value-of select="../ss:Cell[7]/ss:Data" />
					</para>
				</footnote>
			</xsl:if>
		</entry>
	</xsl:template>

Regards,
Kenneth

On 8/12/05, Georges Schmitz <georges.schmitz@xxxxxxxxx> wrote:
> My use case:
>
> I have an Excel Sheet in xml format, that is basically build out of 6
> columns. Now and then I have a value in column 7, that should be made a
> footnote in column 2 of the output. Column 1 is to be eliminated in the
> output (I just use it for grouping).
>
> Example Data (6 columns, sometimes 7):
>
>   <Row>
>     <Cell><Data ss:Type="String">LAS</Data></Cell>
>     <Cell><Data ss:Type="String">Masterreport</Data></Cell>
>     <Cell><Data ss:Type="String">alle 4 Lizenzarten</Data></Cell>
>     <Cell><Data ss:Type="String">Lizenzdruck</Data></Cell>
>     <Cell><Data ss:Type="String">Jasper</Data></Cell>
>     <Cell><Data ss:Type="String">pilot_licence_CH.xml</Data></Cell>
>     <Cell><Data ss:Type="String">Alle Lizenzvorlagen sind in zip-Dateien
> zusammengefasst.</Data></Cell>
>   </Row>
>
> Output should be (5 columns):
>
>   <row>
>     <entry>Masterreport</entry>
>     <entry>alle 4 Lizenzarten<footnote>
>         <para>Alle Lizenzvorlagen sind in zip-Dateien
> zusammengefasst.</para>
>       </footnote>
>     </entry>
>     <entry>Lizenzdruck</entry>
>     <entry>Jasper</entry>
>     <entry>pilot_licence_CH.xml</entry>
>   </row>
>
> My approach is to use simple template matching for rows and cells:
>
>   <xsl:template match="Row">
>     <row>
>       <xsl:apply-templates/>
>     </row>
>   </xsl:template>
>
>   <xsl:template match="Cell[position() &gt; 1 and position() &lt; 7]">
>     <entry>
>       <xsl:value-of select="Data"/>
>       <xsl:if test="position()=3 and following-sibling::Cell[7]">
>         <xsl:message>+++ making footnote +++</xsl:message>
>         <footnote><para><xsl:value-of
> select="following-sibling::Cell[7]/Data"/></para></footnote>
>       </xsl:if>
>     </entry>
>   </xsl:template>

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.