XSLT新增功能。我有如下的XML消息:複雜屬性的XSL轉換
<Root>
<Payload>
<SendEmail>
<customerID>123123</customerID>
<subscriberID>123123</subscriberID>
<MessageDetails>
<AttributeList>
<Attribute Name="CcEmailAddress">[email protected]</Attribute>
<Attribute Name="BcccEmailAddress">[email protected]</Attribute>
<Attribute Name="SenderEmailAddress">[email protected]</Attribute>
<Attribute Name="SenderMobileNo">[email protected]</Attribute>
<Content Name="MobileNo">[email protected]</Content>
<Content Value="TxnNO">[email protected]</Content>
<ERCo ercvalue="ERCNO">[email protected]</ERCo>
<Attribute Name="OrderHeader"><![CDATA[" and ends with "]]></Attribute>
</AttributeList>
</MessageDetails>
<MessageDetails>
<AttributeList>
<Attribute Name="CcEmailAddress">[email protected]</Attribute>
<Attribute Name="BcccEmailAddress">[email protected]</Attribute>
<Attribute Name="SenderEmailAddress">[email protected]</Attribute>
<Attribute Name="SenderMobileNo">[email protected]</Attribute>
<Content Name="MobileNo">[email protected]</Content>
<Content Value="TxnNO">[email protected]</Content>
<ERCo ercvalue="ERCNO">[email protected]</ERCo>
<Attribute Name="OrderHeader"><![CDATA[" and ends with "]]></Attribute>
</AttributeList>
</MessageDetails>
</SendEmail>
</Payload>
</Root>
下面是我的要求和問題:
在AttributeList中的標籤,我要查找的屬性「姓名」,它具有特定值(比方說CcEmailAddress),然後將相應的字段值(實際的電子郵件ID)映射到我的目標標記。我試過 // [@ Name ='CcEmailAddress'] 由於它在我的輸入中出現一次,我決定遍歷名稱爲Name和值爲CcEmailAddress的所有屬性。但它似乎沒有工作。
如何確保我的代碼選擇特定的發生?在我的情況下,消息細節重複n次。如果我在for-each中使用select,它只會獲取第一個發生值。當循環在第二個「MessageDetails」時,我想要獲取它們中的值。我如何實現這一目標?
在AttributeList中,我擁有「Attribute」元素和n個其他元素。如果我想通過「Content」元素進行搜索並找到屬性「Name」= MobileNo(MobileNo可以出現在任何標籤下,但我只想要重複內容下的東西)的值,我該如何做?
非常感謝您的幫助。
請編輯問題並指定轉換的確切想要的結果。 – 2013-03-19 03:48:02