Html 从具有多个属性的节点创建XML XSL表
我想基于下面的XML表,用XSL创建一个HTML表。目标是创建一个包含所有公司名称及其所有产品名称的表Html 从具有多个属性的节点创建XML XSL表,html,xml,xslt,html-table,Html,Xml,Xslt,Html Table,我想基于下面的XML表,用XSL创建一个HTML表。目标是创建一个包含所有公司名称及其所有产品名称的表 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="style.xsl"?> <Companies> <Company CompanyID="1"> <CompanyInfo> <Name>ABC&l
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<Companies>
<Company CompanyID="1">
<CompanyInfo>
<Name>ABC</Name>
<ProductNames>
<ProductName Name="Product 1" />
<ProductName Name="Product 2" />
<ProductName Name="Product 3" />
<ProductName Name="Product 4" />
</ProdcutNames>
</CompanyInfo>
</Company>
<Company CompanyID="2">
<CompanyInfo>
<Name>TVM</Name>
<ProductNames>
<ProductName Name="Product A" />
<ProductName Name="Product B" />
<ProductName Name="Product C" />
<ProductName Name="Product D" />
</ProdcutNames>
</CompanyInfo>
</Company>
</Companies>
基础知识
TVM
目前我有以下XSL表(这是不够的)
表视图
名称
产品名称
目标输出应如下所示:
<table>
<tr>
<th>CompanyName</th>
<th>ProductName</th>
</tr>
<tr>
<td>ABC</td>
<td>Product 1</td>
</tr>
<tr>
<td>ABC</td>
<td>Product 2</td>
</tr>
<tr>
<td>ABC</td>
<td>Product 3</td>
</tr>
<tr>
<td>ABC</td>
<td>Product 4</td>
</tr>
<tr>
<td>TVM</td>
<td>Product A</td>
</tr>
<tr>
<td>TVM</td>
<td>Product B</td>
</tr>
<tr>
<td>TVM</td>
<td>Product C</td>
</tr>
<tr>
<td>TVM</td>
<td>Product D</td>
</tr>
</table>
公司名称
产品名称
基础知识
产品1
基础知识
产品2
基础知识
产品3
基础知识
产品4
TVM
产品A
TVM
产品B
TVM
产品C
TVM
产品D
目前,我只能查看每个公司的一个产品,但不是所有产品。因此,我的目标是为每个产品创建一个表,其中包含一行对应的公司名称
如果有人能帮我,那就太好了 变化
<xsl:for-each select="Companies/Company/CompanyInfo">
<tr>
<td><xsl:value-of select="Name" /></td>
<td><xsl:value-of select="ProductNames/ProductName/@Name" /></td>
</tr>
</xsl:for-each>
到
<xsl:for-each select="Companies/Company/CompanyInfo">
<tr>
<td><xsl:value-of select="Name" /></td>
<td><xsl:value-of select="ProductNames/ProductName/@Name" /></td>
</tr>
</xsl:for-each>
<xsl:for-each select="Companies/Company/CompanyInfo/ProductNames/ProductName/@Name">
<tr>
<td><xsl:value-of select="ancestor::CompanyInfo/Name" /></td>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>