2011-09-29 4 views
0

멍청한 놈에게 XSLT 변환을 조언 해주세요.XSLT select의 변환 값 - 공백 출력?

다음 XSLvalue-of에는 무엇이 누락 되었습니까? 다음 XML 데이터가 있습니다. 그런 다음 아래에 나열된 변환에서 이러한 요소를 참조하고 있지만 출력에 빈 필드가 생깁니다. 나는 <xsl:value-of select="./userInfo/addressMap/entry[2]/firstName"/>

<userInfo> 
    <addressMap> 
     <entry> 
      <key>2</key> 
      <value> 
       <addressField1>21941 Main Drive</addressField1> 
       <addressField2>Apt XYZ</addressField2> 
       <addressType>0</addressType> 
       <city>Lake Forest</city> 
       <emailId>[email protected]</emailId> 
       <firstName>Krystal M</firstName> 
       <lastName>Obama</lastName> 
       <phoneNo>9495551212</phoneNo> 
       <state>CA</state> 
       <zipCode>92630</zipCode> 
      </value> 
     </entry> 
    </addressMap> 
</userInfo> 


    <table border="0" width="600" cellpadding="5" cellspacing="5"> 
    <tr bgcolor="#cccccc" style="font-size:14px; font-weight:bold;"> 
     <td align="left">SHIPPING INFO</td> 
     <td align="left">BILLING INFO</td> 
    </tr> 
    <tr bgcolor="#ffffff" style="font-size:12px;"> 
     <td align="left"><table border="0"> 
      <tr> 
      <td><xsl:value-of select="./userInfo/addressMap/entry[2]/firstName"/>&#160; 
      <xsl:value-of select="./userInfo/addressMap/entry[2]/lastName"/></td> 
      </tr> 
      <tr> 
      <td><xsl:value-of select="./userInfo/addressMap/entry[2]/addressField1"/></td> 
      </tr> 
      <xsl:choose> 
      <xsl:when test="./userInfo/addressMap/entry[2]/addressField2 and ./userInfo/addressMap/entry[2]/addressField2 != ''"> 
       <tr> 
       <td><xsl:value-of select="./userInfo/addressMap/entry[2]/addressField2"/></td> 
       </tr> 
      </xsl:when> 
      <xsl:otherwise> 
       <tr> 
       <td>&#32;</td> 
       </tr> 
      </xsl:otherwise> 
      </xsl:choose> 
      <tr> 
      <td><xsl:value-of select="./userInfo/addressMap/entry[2]/city"/>,&#160; 
      <xsl:value-of select="./userInfo/addressMap/entry[2]/state"/>&#160; 
      <xsl:value-of select="./userInfo/addressMap/entry[2]/zipCode"/> USA </td> 
      </tr> 
      <tr> 
      <td><xsl:value-of select="./userInfo/addressMap/entry[2]/phoneNo"/></td> 
      </tr> 
     </table> 

에 잘못된 구문을 사용해야하는 것은 여기 내 전체 XML 데이터입니다.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<cart> 
    <basketQuantity>0</basketQuantity> 
    <cartTotals> 
     <amtDueToBePaid>35.4</amtDueToBePaid> 
     <discountList>Employee Discount</discountList> 
     <giftWrapping>0.0</giftWrapping> 
     <preferredMemberAmountCharged>0.0</preferredMemberAmountCharged> 
     <preferredMemberSavings>0.0</preferredMemberSavings> 
     <promoCodeSavings>0.0</promoCodeSavings> 
     <promoShipping>0.0</promoShipping> 
     <regularMerchandise>59.0</regularMerchandise> 
     <regularShipping>0.0</regularShipping> 
     <saleMerchandise>59.0</saleMerchandise> 
     <savings>23.6</savings> 
     <shippingSavings>0.0</shippingSavings> 
     <subTotal>35.4</subTotal> 
     <tax>0.0</tax> 
     <taxableMerchandise>35.4</taxableMerchandise> 
     <total>35.4</total> 
    </cartTotals> 
    <errorAndWarnings/> 
    <itemsList> 
     <discountMap> 
      <entry> 
       <key>Employee Discount</key> 
       <value>23.6</value> 
      </entry> 
     </discountMap> 
     <itemName>Rosette Smocked Top</itemName> 
     <productId>45711923</productId> 
     <promoPrice>0.0</promoPrice> 
     <quantity>1</quantity> 
     <regularPrice>59.0</regularPrice> 
     <returnValue>35.4</returnValue> 
     <salePrice>59.0</salePrice> 
     <savings>23.6</savings> 
     <taxCode>0.0</taxCode> 
     <unitTax>0.0</unitTax> 
     <upc>457119500004</upc> 
     <uuid>b18ffa87c0a86f6f14618000479d92c9</uuid> 
    </itemsList> 
    <orderPlaced>false</orderPlaced> 
    <pipelineSessionId>abcxyz</pipelineSessionId> 
    <shipping> 
     <availableShippingMap> 
      <entry> 
       <key>2</key> 
       <value> 
        <actualShippingCost>7.95</actualShippingCost> 
        <deliveryDays>0</deliveryDays> 
        <savings>0.0</savings> 
        <shippingDiscount>0.0</shippingDiscount> 
        <shippingMethodName>2nd Day</shippingMethodName> 
       </value> 
      </entry> 
      <entry> 
       <key>1</key> 
       <value> 
        <actualShippingCost>0.0</actualShippingCost> 
        <deliveryDays>0</deliveryDays> 
        <savings>0.0</savings> 
        <shippingDiscount>0.0</shippingDiscount> 
        <shippingMethodName>Standard Shipping</shippingMethodName> 
       </value> 
      </entry> 
      <entry> 
       <key>3</key> 
       <value> 
        <actualShippingCost>19.95</actualShippingCost> 
        <deliveryDays>0</deliveryDays> 
        <savings>0.0</savings> 
        <shippingDiscount>0.0</shippingDiscount> 
        <shippingMethodName>Overnight Delivery</shippingMethodName> 
       </value> 
      </entry> 
     </availableShippingMap> 
     <savings>0.0</savings> 
     <selectedShippingMethodId>1</selectedShippingMethodId> 
     <shippingCost>0.0</shippingCost> 
     <shippingPromo>0.0</shippingPromo> 
    </shipping> 
    <userInfo> 
     <addressMap> 
      <entry> 
       <key>2</key> 
      <value> 
       <addressField1>21941 Main Drive</addressField1> 
       <addressField2>Apt XYZ</addressField2> 
       <addressType>0</addressType> 
       <city>Lake Forest</city> 
       <emailId>[email protected]</emailId> 
       <firstName>Krystal M</firstName> 
       <lastName>Obama</lastName> 
       <phoneNo>9495551212</phoneNo> 
       <state>CA</state> 
       <zipCode>92630</zipCode> 
      </value> 
      </entry> 
     </addressMap> 
    </userInfo> 
</cart> 
+0

변환을 실행하는 데 사용중인 프로세서는 무엇입니까? Visual Studio 2010을 통해 이것을 실행할 수 있습니다. 정상적으로 출력됩니다. http://jsbin.com/ulibel/2/edit –

+0

Eclipse XSLT 프로세서를 사용하고 있습니다. – Byron

+0

'xsl : 가치? 또한, 당신은 두 번째''에서''을 찾고 있지만, 예제에서는''만 있습니다. –

답변

1

문제는 "입력 [2]"입니다

"./userInfo/addressMap/entry[string(key) = 2]/value/firstName"과 같은 형식이어야합니다.

+0

감사합니다 @Dabbler, 내 문제가 해결되었습니다. – Byron