在我的肥皂响应xml中,我会重复获得"选项"父节点。在父节点中,我的节点" rgb"包含一些值。我正在使用该数据创建HTML。从父级我使用描述,当该描述我放入TD时,我需要将TD颜色作为rgb值在选项节点中
中的rgb值样本XML
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ToggleOptionResponse xmlns="urn:configcompare4g.kp.chrome.com">
<status>None</status>
<originatingChromeOptionCode>SM</originatingChromeOptionCode>
<originatingOptionAnAddition>true</originatingOptionAnAddition>
<requiresToggleToResolve>false</requiresToggleToResolve>
<configuration>
<options>
<headerName>PRIMARY PAINT</headerName>
<consumerFriendlyHeaderId>10</consumerFriendlyHeaderId>
<consumerFriendlyHeaderName>Exterior</consumerFriendlyHeaderName>
<optionKindId>68</optionKindId>
<descriptions>
<description>Shadow Black</description>
<type>PrimaryName</type>
</descriptions>
<uniqueTypeFilter>N</uniqueTypeFilter>
<rgbValue>0A0A0C</rgbValue>
</options>
<options>
<headerName>PRIMARY PAINT</headerName>
<consumerFriendlyHeaderId>10</consumerFriendlyHeaderId>
<consumerFriendlyHeaderName>Exterior</consumerFriendlyHeaderName>
<optionKindId>68</optionKindId>
<descriptions>
<description>Ruby Red Metallic Tinted Clearcoat</description>
<type>PrimaryName</type>
</descriptions>
<rgbValue>570512</rgbValue>
</options>
</configuration>
</ToggleOptionResponse>
</S:Body>
</S:Envelope>
对应XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:p="urn:configcompare4g.kp.chrome.com" version="1.0"
exclude-result-prefixes="p">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<xsl:for-each select="//p:ToggleOptionResponse/p:configuration/p:options">
<tr bgcolor="#9acd32">
<xsl:for-each select="p:headerName[not(.=preceding::*)]">
<th><xsl:value-of select="." /></th>
</xsl:for-each>
</tr>
<tr>
<td><xsl:value-of select="p:consumerFriendlyHeaderName"/></td>
<xsl:if test="p:headerName != 'PRIMARY PAINT'">
<td><xsl:for-each select="p:descriptions/p:description">
<xsl:if test="position() > 1 ">, </xsl:if>
<xsl:value-of select="."/><xsl:text> </xsl:text></xsl:for-each></td>
</xsl:if>
<xsl:if test="p:headerName = 'PRIMARY PAINT'">
<td bgcolor ='#<xsl:value-of select="p:rgbValue">'>
<xsl:for-each select="p:descriptions/p:description">
<xsl:if test="position() > 1 ">, </xsl:if>
<xsl:value-of select="."/><xsl:text> </xsl:text></xsl:for-each></td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我是第一次尝试XSLT,需要输入
预先感谢
您需要在此处使用属性值模板..
而不是这样做...
<td bgcolor ='#<xsl:value-of select="p:rgbValue">'>
做这个....
<td bgcolor ='#{p:rgbValue}'>
卷曲支撑表示要评估的表达式,然后将其结果放在属性中。