我将执行 XSLT 转换,将 XML 转换为 HTML 表。它是表格数据,所以这就是我不使用 div 的原因。;)
无论如何,我需要为我的一个集合的大小重复 XSLT 的一部分。这是代码片段...
Dim styleSheet = <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:rh="ReportHub"
exclude-result-prefixes="msxsl"
>
<xsl:output method="html" indent="yes" />
<xsl:template match="rh:Report/rh:Tablix1/rh:Details_Collection">
<xsl:variable name="alternating-row" select="position() mod 2" />
<table class=<%= dataFormatter.formattingTableClass %>>
<xsl:choose>
<xsl:when test="count(rh:Details)=0">
<tr>
<td>There are no items listed for this client</td>
</tr>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="rh:Details">
<tr class=<%= dataFormatter.formattingTRClass %>>
<xsl:variable name="mainrow-position" select="position()" />
<xsl:for-each select="@*">
<%= From x In dataFormatter.dataColumnSettings Select
<xsl:if test="name() != 'colName'">
<xsl:choose>
<xsl:when test="$mainrow-position=1">
<th>
<xsl:value-of select="name()"/>
</th>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
%>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</table>
</xsl:template>
</xsl:stylesheet>
问题是因为 LINQ 查询中的 XML 引用了 xsl 命名空间,所以我得到:
错误 9 XML 命名空间前缀“xsl”未定义。
任何人有任何聪明的想法?
- LINQ 查询中 XML 的内部工作还没有完成,所以不要担心它是什么样子的。