这里是我的xml:如果我改变这一行XSL属性值没有得到显示
<tr>
<td border="1"><a href="broker_name">BARC</a></td>
<td border="1"><a href="broker_id">11 </a></td>
</tr>
然而
:
<RESPONSE heading="Broker List">
<RESULTSET nbr="1" rowcount="11">
<ROW nbr="1">
<COL nbr="1" name="broker_name" datatype="String" href="api">BARC</COL>
<COL nbr="2" name="broker_id" datatype="String">11</COL>
</ROW>
</RESULTSET>
</RESPONSE>
这XLS作品:
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/RESPONSE">
<html>
<head>
</head>
<body class='data'>
<h2><xsl:value-of select="./@heading"/></h2>
<xsl:apply-templates select="RESULTSET" />
</body>
</html>
</xsl:template>
<xsl:template match="RESULTSET">
<table id="result" class="sortable-theme-finder" data-sortable="">
<thead>
<xsl:for-each select="ROW[1]/COL">
<th> <xsl:value-of select="@name" /></th>
</xsl:for-each>
</thead>
<tbody>
<xsl:apply-templates select="ROW" />
</tbody>
</table>
<br/>
</xsl:template>
<xsl:template match="ROW" >
<tr>
<xsl:apply-templates select="COL" />
</tr>
</xsl:template>
<xsl:template match="COL">
<td border="1">
<a><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:value-of select="."/>
</a>
</td>
</xsl:template>
</xsl:stylesheet>
造成这样的:
<xsl:value-of select="@name" />
到
<xsl:value-of select="@href" />
的结果是这样的:
<tr>
<td border="1"><a href="">BARC</a></td>
<td border="1"><a href="">11 </a></td>
</tr>
为什么@href属性未被选中?它只会接受名称属性。尝试'身份证',但没有去。我正在使用C#XslCompiledTransform来执行转换。谢谢!
源XML中没有'href'属性。唯一相似的是'ref'。 –
我更新了xml以显示href现在(仍然不起作用)。我想也许href是一个保留字,所以我尝试了参考和其他属性名称。 – user3102739
对不起,我不得不走出来几个小时。我已按照您的要求提供了完整的xsl。 – user3102739