H_3k
asked on
XML from Excel2002 meets XSLT
I have a problem transforming an XML file with an XSLT. The XML file was generated by using save as XML in Excel2002.
I can transform the files listed below if I change the namespace from 'http://www.w3.org/1999/XSL/Transform' to 'http://www.w3.org/TR/WD-xsl'. But I do not wish to use the 'http://www.w3.org/TR/WD-xsl' namespace because I will need xsl:key elements in my XSLT and they're not allowed.
Does anybody know how I can use the 'http://www.w3.org/1999/XSL/Transform' namespace to transform the given XML? (or maybe if there is another solution: using another namespace, using xsl:key elements with namespace 'http://www.w3.org/TR/WD-xsl')
I am becoming desperate on this one, thx in advance.
MY XSLT FILE (SIMPLE VERSION):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/">
<Test>
<Test1><xsl:value-of select="Workbook/DocumentP roperties/ Author"/>< /Test1>
</Test>
</xsl:template>
</xsl:stylesheet>
XML FILE FROM EXCELL:
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microso ft-com:off ice:spread sheet"
xmlns:o="urn:schemas-micro soft-com:o ffice:offi ce"
xmlns:x="urn:schemas-micro soft-com:o ffice:exce l"
xmlns:ss="urn:schemas-micr osoft-com: office:spr eadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microso ft-com:off ice:office ">
<Author>HFagard</Author>
<LastAuthor>HFagard</LastA uthor>
<Created>2003-02-27T14:18: 59Z</Creat ed>
<Version>10.4219</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microso ft-com:off ice:office ">
<DownloadComponents/>
<LocationOfComponents HRef="file:///\\"/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microso ft-com:off ice:excel" >
<WindowHeight>8445</Window Height>
<WindowWidth>15195</Window Width>
<WindowTopX>0</WindowTopX>
<WindowTopY>45</WindowTopY >
<ProtectStructure>False</P rotectStru cture>
<ProtectWindows>False</Pro tectWindow s>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2" x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">valueA1</ Data></Cel l>
<Cell><Data ss:Type="String">valueB1</ Data></Cel l>
</Row>
<Row>
<Cell><Data ss:Type="String">valueA2</ Data></Cel l>
<Cell><Data ss:Type="String">valueB2</ Data></Cel l>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microso ft-com:off ice:excel" >
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
<ActiveCol>1</ActiveCol>
<RangeSelection>R1C1:R2C2< /RangeSele ction>
</Pane>
</Panes>
<ProtectObjects>False</Pro tectObject s>
<ProtectScenarios>False</P rotectScen arios>
</WorksheetOptions>
</Worksheet>
</Workbook>
I can transform the files listed below if I change the namespace from 'http://www.w3.org/1999/XSL/Transform' to 'http://www.w3.org/TR/WD-xsl'. But I do not wish to use the 'http://www.w3.org/TR/WD-xsl' namespace because I will need xsl:key elements in my XSLT and they're not allowed.
Does anybody know how I can use the 'http://www.w3.org/1999/XSL/Transform' namespace to transform the given XML? (or maybe if there is another solution: using another namespace, using xsl:key elements with namespace 'http://www.w3.org/TR/WD-xsl')
I am becoming desperate on this one, thx in advance.
MY XSLT FILE (SIMPLE VERSION):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/">
<Test>
<Test1><xsl:value-of select="Workbook/DocumentP
</Test>
</xsl:template>
</xsl:stylesheet>
XML FILE FROM EXCELL:
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microso
xmlns:o="urn:schemas-micro
xmlns:x="urn:schemas-micro
xmlns:ss="urn:schemas-micr
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microso
<Author>HFagard</Author>
<LastAuthor>HFagard</LastA
<Created>2003-02-27T14:18:
<Version>10.4219</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microso
<DownloadComponents/>
<LocationOfComponents HRef="file:///\\"/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microso
<WindowHeight>8445</Window
<WindowWidth>15195</Window
<WindowTopX>0</WindowTopX>
<WindowTopY>45</WindowTopY
<ProtectStructure>False</P
<ProtectWindows>False</Pro
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">valueA1</
<Cell><Data ss:Type="String">valueB1</
</Row>
<Row>
<Cell><Data ss:Type="String">valueA2</
<Cell><Data ss:Type="String">valueB2</
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microso
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
<ActiveCol>1</ActiveCol>
<RangeSelection>R1C1:R2C2<
</Pane>
</Panes>
<ProtectObjects>False</Pro
<ProtectScenarios>False</P
</WorksheetOptions>
</Worksheet>
</Workbook>
Sorry that last bit should have read:
<html>
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("MSXML2.DOMD ocument.3. 0")
xml.async = false
if (!xml.load("myxmlfile.xml" ))
alert('Error parsing xml: ' + xml.parseError);
// Load XSL
var xsl = new ActiveXObject("MSXML2.DOMD ocument.3. 0")
xsl.async = false
if (!xsl.load("myxslfile.xsl" ))
alert('Error parsing xsl: ' + xsl.parseError);
// Transform
document.write(xml.transfo rmNode(xsl ))</script >
</body>
</html>
<html>
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("MSXML2.DOMD
xml.async = false
if (!xml.load("myxmlfile.xml"
alert('Error parsing xml: ' + xml.parseError);
// Load XSL
var xsl = new ActiveXObject("MSXML2.DOMD
xsl.async = false
if (!xsl.load("myxslfile.xsl"
alert('Error parsing xsl: ' + xsl.parseError);
// Transform
document.write(xml.transfo
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The 'http://www.w3.org/1999/XSL/Transform' namespace is only supported by version 3 of MSXML.
IE5 and IE5.5 come with versions 2 and 2.5 of MSXML.
To allow these browsers to work with MSXML3 you can install it in replace mode: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmconinstallingmsxml30inreplacemode.asp.
Note you can not install MSXML 4.0 in replace mode.
Better still install IE6 which uses MSXML3 by default.
Alternatively you can do the transform in javascript in which case you can select which version of MSXML to use:
<html>
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.X
xml.async = false
if (!xml.load("myxmlfile.xml"
alert('Error parsing xml: ' + xml.parseError);
// Load XSL
var xsl = new ActiveXObject("Microsoft.X
xsl.async = false
if (!xsl.load("myxslfile.xsl"
alert('Error parsing xsl: ' + xsl.parseError);
// Transform
document.write(xml.transfo
</body>
</html>
Hope this helps,
>S'Plug<