我试图让我的 XSL 从我的 XML 中提取数据以将其推送到 Excel。我可以让 Excel 工作表生成和输入单元格,但它不会从 XML 文档中提取任何数据。
在下面的示例中,我想要的只是@date
来自PLMXML
元素。
XML:
<?xml version="1.0" encoding="UTF-8"?>
<PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema" schemaVersion="6" language="en-us" date="2013-06-11" time="11:47:25" author="XXXXXXXXX">
<Header id="id1" traverseRootRefs="#id2 #id8 #id36 #id38 #id41 #id43 #id40 #id48 #id50 #id47 #id55 #id57 #id54 #id62 #id64 #id61 #id68 #id84 #id93 #id98 #id118" transferContext="xXXXXxx" />
<ProductRevision id="id2" name="XXXXXXX & XXXXXXXXX" accessRefs="#id3" subType="XXXXXXXXXX" masterRef="#id6" revision="03">
<ApplicationRef version="h0BAw48K4MeaHA" application="XXXXXXXX" label="gOGAwodW4MeaHA" />
</ProductRevision>
<Product id="id6" name="XXXXXXXXX & XXXXXXXX" accessRefs="#id3" subType="XXXXXXX" productId="XXXXXXXX">
<ApplicationRef version="gOGAwodW4MeaHA" application="XXXXXXXX" label="gOGAwodW4MeaHA" />
</Product>
<AccessIntent id="id3" intent="reference" ownerRefs="#id4" />
<Site id="id4" name="XXX" siteId="-2093050256">
<ApplicationRef version="wxPAAAAE4MeaHA" application="XXXXXXXX" label="wxPAAAAE4MeaHA" />
<UserData id="id5">
<UserValue value="1" title="xxxx" />
</UserData>
</Site>
</PLMXML>
XSL 文件:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema"
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" >
<xsl:param name="report_date" select="/plm:PLMXML/@date" />
<!-- Method for translation -->
<xsl:output method="xml" version="1.0" indent="yes" />
<xsl:strip-space elements="*"/>
<!-- ******************** -->
<!-- Header and structure -->
<!-- ******************** -->
<xsl:template name="BOMReportHeader">
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
<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">
<Styles>
<Style ss:ID="heading1">
<Font ss:Color="#000000" ss:Size="20" ss:FontName="Arial" ss:Bold="1"/>
<Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="heading2">
<Font ss:Color="#000000" ss:Size="12" ss:FontName="Arial" ss:Bold="1"/>
<Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="heading3">
<Alignment ss:Horizontal="Left"/>
<Font ss:Color="#000000" ss:Size="10" ss:FontName="Arial" ss:Bold="1"/>
<Interior ss:Color="#CCCCFF" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="cell_data">
<Font ss:Color="#000000"/>
<Interior ss:Color="#FFFFCC" ss:Pattern="Solid"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="60" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="60" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Column ss:AutoFitWidth="0" ss:Width="80" AutoFitWidth="1"/>
<Row></Row>
<Row>
<Cell ss:StyleID="heading1">
<Data ss:Type="String">
</Data>
</Cell>
<Cell ss:StyleID="heading1"></Cell>
</Row>
<Row></Row>
<Row>
<Cell ss:StyleID="heading2">
<Data ss:Type="String">
Date: <xsl:value-of select="$report_date"/>
</Data>
</Cell>
<Cell ss:StyleID="heading2"></Cell>
</Row>
<Row></Row>
</Table>
</Worksheet>
</Workbook>
</xsl:template>
<!-- **************** Top Level data element **************** -->
<xsl:template match="/">
<xsl:call-template name="BOMReportHeader">
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
我尝试了许多其他方法,包括删除一些命名空间,但它似乎没有帮助。在过去的两天里,我一直在努力解决这个问题,但没有运气。