繁体   English   中英

如何传递肥皂XML中传入的rgb值将其转换为xsl并传递rgb值

[英]How to pass rgb value coming in soap xml converting it into xsl and pass the rgb value

在我的soap响应XML中,我反复得到“选项”父节点。 在父节点内部,我有一个包含一些值的节点“ rgb”。 我正在使用该数据创建html。 在父级中,我正在使用描述,当该描述输入td时,我需要在选项节点中将td颜色作为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}'>

大括号表示要评估的表达式,然后将其结果放入属性中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM