Dear Experts,
I'm going to create an Excell spreadsheet xml. So far things work very
well. But in case I add <Row> elements by a recursive template call it
goes wrong.
See the attached XSLT and the result. Last 30 lines of the xslt may be
the most interesting ones. I'm processing it with XMLSPY. Regardless
of the xslt processor (ALTOVA / MSXML4 ) I get the same result.
Hence, I belive I have not done it right. Sorry for the long code, but
I do not really know where the problem might be.
Any help is welcome
Regards
Rolf
############### ########## XSLT ############### ############### #####
<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cdb="http ://intra.etc.nec.d e/cdb.html"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns:x="urn:sc hemas-microsoft-com:office:exce l"
xmlns:ss="urn:s chemas-microsoft-com:office:spre adsheet"
xmlns:html="htt p://www.w3.org/TR/REC-html40">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="max_hiera rchy">
<xsl:for-each select="//xs:element">
<xsl:sort select="-count(ancestor: :xs:element)"
data-type="number"/>
<xsl:if test="position( )=1">
<xsl:value-of select="count(a ncestor-or-self::xs:elemen t)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="items" select="9"/>
<xsl:variable name="FirstItem Index" select="$max_hi erarchy * 2 +
1"/>
<xsl:variable name="ExpandedC olumnCount" select="$FirstI temIndex +
$items"/>
<xsl:variable name="Elements"
select="count(x s:schema/xs:element[@name='Chip']//xs:element)"/>
<!--header row counts -->
<xsl:variable name="ExpandedR owCount" select="$Elemen ts + 1"/>
<!-- <xsl:variable name="header_it ems"
select="documen t('<items><i>A</i><i>B</i></items>','/items'"-->
<Workbook xmlns="urn:sche mas-microsoft-com:office:spre adsheet"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns:x="urn:sc hemas-microsoft-com:office:exce l"
xmlns:ss="urn:s chemas-microsoft-com:office:spre adsheet"
xmlns:html="htt p://www.w3.org/TR/REC-html40">
<DocumentProper ties
namespace="urn: schemas-microsoft-com:office:offi ce">
<Author>CreateX LSXMLFromChipDB Schema</Author>
<LastAuthor>
<xsl:value-of select="//HISTORY//XSDHISTORY[last()]/@who"/>
</LastAuthor>
<Company>NEC Electronics (Europe)</Company>
</DocumentPropert ies>
<ExcelWorkboo k namespace="urn: schemas-microsoft-com:office:exce l">
<ProtectStructu re>False</ProtectStructur e>
<ProtectWindows >False</ProtectWindows>
</ExcelWorkbook>
<Styles>
snipped ..........
</Styles>
<Worksheet ss:Name="Schema Structure">
<Table ss:ExpandedRowC ount="{$Expande dRowCount + 100}"
ss:ExpandedColu mnCount="{$Expa ndedColumnCount }" x:FullColumns=" 0"
x:FullRows="1">
<!-- column widths -->
<Column ss:Index="{$Fir stItemIndex + 0}" ss:Width="20"/>
snipped ....
<Column ss:Index="{$Fir stItemIndex + 8}" ss:Width="100"/>
<!-- header line -->
<Row>
<Cell ss:MergeAccross ="{$FirstItemIn dex}"
ss:StyleID="hea der_element">
<Data ss:Type="String ">Hierarchy Element</Data>
</Cell>
<Cell ss:Index="{$Fir stItemIndex + 0}" ss:StyleID="hea der_item">
<Data ss:Type="String ">MinBound</Data>
</Cell>
snipped ......
<Cell ss:Index="{$Fir stItemIndex + 8}" ss:StyleID="hea der_item">
<Data ss:Type="String ">Example</Data>
</Cell>
</Row>
<Row><!-- this works well -->
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">├</Data>
</Cell>
</Row>
<!-- Rows inserted by the template get a null namespace with it
!!!1 -->
<xsl:apply-templates select="xs:sche ma/xs:element[@name='Chip']"
mode="e"/>
</Table>
</Worksheet>
</Workbook>
</xsl:template>
<xsl:template match="*" mode="e">
<!--<xsl:element name="Row"> the same behaviour as <Row> -->
<Row> <!-- here namespace xmlns="" is added as attribute WHY ??? -->
<xsl:for-each select="./ancestor::xs:el ement">
<!-- Cell gets no additional namspace with it!! -->
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">│</Data>
</Cell>
</xsl:for-each>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">├</Data>
</Cell>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">
<xsl:value-of select="@name"/>
</Data>
</Cell>
</Row>
<xsl:apply-templates
select="./xs:complexType/xs:sequence/xs:element" mode="e"/>
</xsl:template>
</xsl:stylesheet>
############## RESULT ############### ###############
<?xml version="1.0" encoding="UTF-8"?>
<Workbook xmlns="urn:sche mas-microsoft-com:office:spre adsheet"
xmlns:cdb="http ://intra.etc.nec.d e/cdb.html"
xmlns:html="htt p://www.w3.org/TR/REC-html40"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns:ss="urn:s chemas-microsoft-com:office:spre adsheet"
xmlns:x="urn:sc hemas-microsoft-com:office:exce l"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<DocumentProper ties
namespace="urn: schemas-microsoft-com:office:offi ce">
<Author>CreateX LSXMLFromChipDB Schema</Author>
<LastAuthor>kem perr</LastAuthor>
<Company>NEC Electronics (Europe)</Company>
</DocumentPropert ies>
<ExcelWorkboo k namespace="urn: schemas-microsoft-com:office:exce l">
<ProtectStructu re>False</ProtectStructur e>
<ProtectWindows >False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal ">
<Alignment ss:Vertical="Bo ttom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="header_e lement">
<Alignment ss:Horizontal=" Left" ss:Vertical="Bo ttom"/>
<Interior ss:Color="silve r" ss:Pattern="Sol id"/>
</Style>
<Style ss:ID="header_i tem">
<Alignment ss:Horizontal=" Left" ss:Vertical="Bo ttom"/>
</Style>
<Style ss:ID="element" >
<Alignment ss:Horizontal=" Left" ss:Vertical="Bo ttom"/>
<Interior ss:Color="orang e" ss:Pattern="Sol id"/>
</Style>
<Style ss:ID="leaf_ele ment">
<Alignment ss:Horizontal=" Left" ss:Vertical="Bo ttom"/>
<Interior ss:Color="blue" ss:Pattern="Sol id"/>
</Style>
<Style ss:ID="TreeLine ">
<Alignment ss:Horizontal=" Right" ss:Vertical="Bo ttom"/>
</Style>
</Styles>
<Worksheet ss:Name="Schema Structure">
<Table ss:ExpandedRowC ount="228" ss:ExpandedColu mnCount="22"
x:FullColumns=" 0" x:FullRows="1">
<Column ss:Index="13" ss:Width="20"/>
<Column ss:Index="14" ss:Width="20"/>
<Column ss:Index="15" ss:Width="100"/>
<Column ss:Index="16" ss:Width="100"/>
<Column ss:Index="17" ss:Width="30"/>
<Column ss:Index="18" ss:Width="30"/>
<Column ss:Index="19" ss:Width="100"/>
<Column ss:Index="20" ss:Width="100"/>
<Column ss:Index="21" ss:Width="100"/>
<Row>
<Cell ss:MergeAccross ="13" ss:StyleID="hea der_element">
<Data ss:Type="String ">Hierarchy Element</Data>
</Cell>
<Cell ss:Index="13" ss:StyleID="hea der_item">
<Data ss:Type="String ">MinBound</Data>
</Cell>
<Cell ss:Index="14" ss:StyleID="hea der_item">
<Data ss:Type="String ">MaxBound</Data>
</Cell>
<Cell ss:Index="15" ss:StyleID="hea der_item">
<Data ss:Type="String ">ToolTip</Data>
</Cell>
<Cell ss:Index="16" ss:StyleID="hea der_item">
<Data ss:Type="String ">Help</Data>
</Cell>
<Cell ss:Index="17" ss:StyleID="hea der_item">
<Data ss:Type="String ">HierarchyName </Data>
</Cell>
<Cell ss:Index="18" ss:StyleID="hea der_item">
<Data ss:Type="String ">LeafChild </Data>
</Cell>
<Cell ss:Index="19" ss:StyleID="hea der_item">
<Data ss:Type="String ">FilterReg Ex</Data>
</Cell>
<Cell ss:Index="20" ss:StyleID="hea der_item">
<Data ss:Type="String ">FilterFun c</Data>
</Cell>
<Cell ss:Index="21" ss:StyleID="hea der_item">
<Data ss:Type="String ">Example</Data>
</Cell>
</Row>
<Row>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">├</Data>
</Cell>
</Row>
<Row xmlns="">
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">├</Data>
</Cell>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">Chip</Data>
</Cell>
</Row>
<Row xmlns="">
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">│</Data>
</Cell>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">├</Data>
</Cell>
<Cell ss:StyleID="Tre eLine">
<Data ss:Type="String ">XMLHISTOR Y</Data>
snipped .....
############### ###### end ############### ##########