簡體   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