Re: [xsl] Transforming XML document to Microsoft Excel XML Format

Subject: Re: [xsl] Transforming XML document to Microsoft Excel XML Format
From: Tom Sawyer <z0n0mail@xxxxxxxxx>
Date: Thu, 31 Aug 2006 15:19:17 -0700 (PDT)
Excellent, Thank you very much (Charles + Joe).

--- Joe Fawcett <joefawcett@xxxxxxxxxxx> wrote:

> You can't use xsl:value-of, or any other element
> within an attribute, use an 
> attribute value template:
> 
> <Worksheet ss:Name="{@id}">
> 
> Joe
> 
> ----- Original Message ----- 
> From: "Tom Sawyer" <z0n0mail@xxxxxxxxx>
> To: "XSL List" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, August 31, 2006 6:13 PM
> Subject: [xsl] Transforming XML document to
> Microsoft Excel XML Format
> 
> 
> > Hi,
> >
> >   I m a xml/xslt newbie working to transform an
> xml
> > document to an MS-Excel xml format. I am having
> issues
> > creating an element with an attribute, marked in
> the
> > xsl file with "PROBLEM HERE". I need to have the
> > attribute of the "roster_report" element be
> included
> > in the ss:Name attribute value of the Worksheet
> tag
> > for the output, and it blows up when I use the xsl
> > I've specified.
> >
> > Can someone please help me out how to do it the
> right
> > way ? Please help !
> >
> > -Tom
> >
> >
> >
> > I am including the  input xml
> > ==================
> > INPUT XML
> > ==================
> > <?xml version="1.0" encoding="UTF-8"?>
> > <reports>
> >  <group_report id="Group Id" title="Group Title">
> >    <roster_report id="ReportIdOne">
> >      <title>ReportOne Title</title>
> >      <data_row>
> >        <row_header>HeaderContent One</row_header>
> >        <data>a</data>
> >      </data_row>
> >      <data_row>
> >        <row_header>HeaderContent Two</row_header>
> >        <data>b</data>
> >      </data_row>
> >      <data_row>
> >        <row_header>HeaderContent
> Three</row_header>
> >        <data>c</data>
> >      </data_row>
> >      </roster_report>
> >    <roster_report id="ReportIdTwo">
> >      <title>ReportTwo Title</title>
> >      <data_row>
> >        <row_header>HeaderContent One</row_header>
> >        <data>a</data>
> >      </data_row>
> >      <data_row>
> >        <row_header>HeaderContent Two</row_header>
> >        <data>b</data>
> >      </data_row>
> >      <data_row>
> >        <row_header>HeaderContent
> Three</row_header>
> >        <data>c</data>
> >      </data_row>
> >      </roster_report>
> >  </group>
> > </reports>
> >
> >
> > ============================
> > DESIRED OUTPUT XML (Microsoft Excel)
> > ============================
> > <?xml version="1.0"?>
> > <?mso-application progid="Excel.Sheet"?>
> > <Workbook
> >
> xmlns="urn:schemas-microsoft-com:office:spreadsheet"
> > xmlns:o="urn:schemas-microsoft-com:office:office"
> > xmlns:x="urn:schemas-microsoft-com:office:excel"
> >
> >
>
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
> > xmlns:html="http://www.w3.org/TR/REC-html40";>
> > <DocumentProperties
> > xmlns="urn:schemas-microsoft-com:office:office">
> >  <Author>authName</Author>
> >  <LastAuthor>authName</LastAuthor>
> >  <Created>datestamp</Created>
> >  <LastSaved>datestamp</LastSaved>
> >  <Company>CompanyName</Company>
> >  <Version>11.8036</Version>
> > </DocumentProperties>
> > <ExcelWorkbook
> > xmlns="urn:schemas-microsoft-com:office:excel">
> >  <WindowHeight>13545</WindowHeight>
> >  <WindowWidth>19035</WindowWidth>
> >  <WindowTopX>240</WindowTopX>
> >  <WindowTopY>30</WindowTopY>
> >  <ActiveSheet>1</ActiveSheet>
> >  <ProtectStructure>False</ProtectStructure>
> >  <ProtectWindows>False</ProtectWindows>
> > </ExcelWorkbook>
> > <!--
> > ..
> > ..
> > -->
> > <Worksheet ss:Name="ReportIdOne">
> >   <Table ss:ExpandedColumnCount="2"
> > ss:ExpandedRowCount="3" x:FullColumns="1"
> >    x:FullRows="1">
> >    <Row>
> >     <Cell><Data ss:Type="String">HeaderContent
> > One</Data></Cell>
> >     <Cell><Data ss:Type="String">a</Data></Cell>
> >    </Row>
> >    <Row>
> >     <Cell><Data ss:Type="String">HeaderContent
> > Two</Data></Cell>
> >     <Cell><Data ss:Type="String">b</Data></Cell>
> >    </Row>
> >    <Row>
> >     <Cell><Data ss:Type="String">HeaderContent
> > Three</Data></Cell>
> >     <Cell><Data ss:Type="String">c</Data></Cell>
> >    </Row>
> >   </Table>
> >   <WorksheetOptions
> > xmlns="urn:schemas-microsoft-com:office:excel">
> >    <Panes>
> >     <Pane>
> >      <Number>1</Number>
> >      <ActiveRow>1</ActiveRow>
> >      <RangeSelection>R2:R3</RangeSelection>
> >     </Pane>
> >    </Panes>
> >    <ProtectObjects>False</ProtectObjects>
> >    <ProtectScenarios>False</ProtectScenarios>
> >   </WorksheetOptions>
> >  </Worksheet>
> > <!--
> >  Repeat for 2nd, 3rd.. n workseets (each worksheet
> > for a roster_report)
> >  ..
> >  -->
> >  </Workbook>
> >
> >
> >
> >
> >
> >
> >  ================
> >  XSL stylesheet used
> >  ================
> >  <?xml version="1.0" encoding="UTF-8" ?>
> >  <xsl:stylesheet version="1.0"
> >
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >                  >
> >  <xsl:output method="xml"/>
> >
> >  <xsl:template match="reports">
> >  <Workbook
> >
> xmlns="urn:schemas-microsoft-com:office:spreadsheet"
> >
> >
>
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
> >   <DocumentProperties
> > xmlns="urn:schemas-microsoft-com:office:office">
> >    <Author>authName</Author>
> >    <LastAuthor>authName</LastAuthor>
> >    <Created>datestamp</Created>
> >    <LastSaved>datestamp</LastSaved>
> >    <Company>CompanyName</Company>
> >    <Version>11.8036</Version>
> >   </DocumentProperties>
> >   <ExcelWorkbook
> > xmlns="urn:schemas-microsoft-com:office:excel">
> >    <WindowHeight>13545</WindowHeight>
> >    <WindowWidth>19035</WindowWidth>
> >    <WindowTopX>240</WindowTopX>
> >    <WindowTopY>30</WindowTopY>
> >    <ActiveSheet>1</ActiveSheet>
> >    <ProtectStructure>False</ProtectStructure>
> >    <ProtectWindows>False</ProtectWindows>
> >   </ExcelWorkbook>
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread