0

A simple Workbook/Worksheet XML file

<?xml version="1.0"?>
<Workbook>
  <Worksheet>
  <Table>
   <Row>
    <Cell><Data>ID10065</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

performing a simple and a complex XSLT Transformation:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="/">
        <simple>
            <xsl:value-of select="/Workbook/Worksheet/Table/Row/Cell/Data"/>
        </simple>
        <complex>
            <xsl:for-each select="*[starts-with(name(), 'Workbook')]/*[starts-with(name(), 'Worksheet')]/*[starts-with(name(), 'Table')]/*[starts-with(name(), 'Row')]/*[position()=1 and starts-with(name(), 'Cell')]">
                <xsl:value-of select="."/>
            </xsl:for-each>
        </complex>
    </xsl:template>
</xsl:transform>

Result is a expected:

<simple>ID10065</simple>
<complex>ID10065</complex>

Problem:

If I save an Excel Worksheet as a XML file, the structure is the same (with microsoft office namespace extensions)

<?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">
  <Worksheet ss:Name="Tabelle1">
  <Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="1" x:FullColumns="1"
   x:FullRows="1" ss:DefaultColumnWidth="65" ss:DefaultRowHeight="16">
   <Row>
    <Cell><Data ss:Type="String">ID10065</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

If I do the same XSLT transformation, the result is now only

<complex>ID10065</complex>

Why isn't the "simple" part working with excel worksheets?

Frank

0 Answers0