XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Justin KohlheppSubject: SpreadsheetML matching same cell with multiple names
Author: Justin Kohlhepp
Date: 16 Apr 2007 10:22 AM
I am working on an XSLT to take an Excel XML (a.k.a. SpreadsheetML) template and insert data into it. Sections in the template are identified by many different name regions. In SpreadsheetML, when you give a cell or region a name, it translates to the following:

<Cell>
<Data>cell value</Data>
<NamedCell Name="x"/>
<NamedCell Name="y">
</Cell>

Initially, I had in my template just something along the lines of <xsl:template match="Cell[NamedCell[@Name='x']]"> to find a given cell by name. However, I'm realizing that I may need to match the *same cell* for different names and do different things to the cell. In some cases, I would need both <xsl:template match="Cell[NamedCell[@Name='x']]"> and <xsl:template match="Cell[NamedCell[@Name='y']]"> to match. But my understanding of XSLT is that each node (i.e. Cell in this case) will only match one template.

How should I handle this situation?

Thanks in advance,

~ Justin

Posttop
James DurningSubject: SpreadsheetML matching same cell with multiple names
Author: James Durning
Date: 16 Apr 2007 11:32 AM
If you need to match on each NamedCell, then make the templates for the NamedCell element, eg:

<xsl:template match="NamedCell[@Name='x']">
<xsl:template match="NamedCell[@Name='y']">

Then inside the template, refer to the parent elements using the parent axis. Easiest transition would just be to surround the current contents of the template with:
<xsl:for-each select="..">

</xsl:for-each>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.