0
我有以下XML:XSLT動態的XPath撒克遜EE
...
<peci:Address peci:isDeleted="1">
<peci:Usage_Type>WORK</peci:Usage_Type>
<peci:Address_Line_1>AMEC</peci:Address_Line_1>
<peci:Address_Line_2>2020 Winston Park Drive, Suite
700</peci:Address_Line_2>
<peci:City>Oakville</peci:City>
<peci:Postal_Code>L6H 6X7</peci:Postal_Code>
<peci:Country>CA</peci:Country>
<peci:Country_Region>ON</peci:Country_Region>
<peci:State_Province>Ontario</peci:State_Province>
</peci:Address>
<peci:Address peci:isAdded="1">
<peci:Usage_Type>WORK</peci:Usage_Type>
<peci:Address_Line_1>639 5th Avenue SW</peci:Address_Line_1>
<peci:Address_Line_2>Suite 1410</peci:Address_Line_2>
<peci:City>Calgary</peci:City>
<peci:Postal_Code>T2P 0M9</peci:Postal_Code>
<peci:Country>CA</peci:Country>
<peci:Country_Region>AB</peci:Country_Region>
<peci:State_Province>Alberta</peci:State_Province>
<peci:Address>
<peci:Usage_Type>HOME</peci:Usage_Type>
<peci:Address_Line_1>88 Bridge Cres.</peci:Address_Line_1>
<peci:City>Burlington</peci:City>
<peci:Postal_Code>L7L 0A3</peci:Postal_Code>
<peci:Country>CA</peci:Country>
<peci:Country_Region>ON</peci:Country_Region>
<peci:State_Province>Ontario</peci:State_Province>
</peci:Address>
<peci:Email/>
...
我通過文件迭代,當發現添加節點
peci:isAdded="1"
我檢查是否主持節點具有相同的元素,並已被刪除
peci:isDeleted="1"
如果是這種情況我想遍歷子元素並列出所有元素這是不同的(這裏除了國家以外的任何東西)
我想用於不同的節點,所以我不能使用硬編碼的元素列表,當迭代通過添加元素時我不知道如何訪問繼續兄弟姐妹中的相應元素。它嘗試某事像:
<xsl:when
test="../@peci:isAdded and ../preceding-sibling::*[../local-name()]/@peci:isDeleted">
<xsl:variable name="oldValueLocations" select="local-name()"/>
<xsl:value-of select="../preceding-sibling::*[../local-name()][@peci:isDeleted]/$oldValueLocations"/>
</xsl:when>
我希望
<out:Row xtt:separator="," xtt:quotes="always">
<out:PayGroupCode>93JH</out:PayGroupCode>
<out:LegacyID>93JH000660265</out:LegacyID>
<out:WorkdayID>660265</out:WorkdayID>
<out:Name>SixWFNLastname SixWFNFirstname</out:Name>
<out:Status>Active</out:Status>
<out:Transaction>CHANGE</out:Transaction>
<out:Process_Type>DTA</out:Process_Type>
<out:Type>Address</out:Type>
<out:SubType>Country_Region</out:SubType>
<out:Effective_Date>2017-03-06</out:Effective_Date>
<out:Old_Value>ON</out:Old_Value>
<out:New_Value>AB</out:New_Value>
</out:Row>
而是我得到
<out:Row xtt:separator="," xtt:quotes="always">
<out:PayGroupCode>93JH</out:PayGroupCode>
<out:LegacyID>93JH000660265</out:LegacyID>
<out:WorkdayID>660265</out:WorkdayID>
<out:Name>SixWFNLastname SixWFNFirstname</out:Name>
<out:Status>Active</out:Status>
<out:Transaction>CHANGE</out:Transaction>
<out:Process_Type>DTA</out:Process_Type>
<out:Type>Address</out:Type>
<out:SubType>Country_Region</out:SubType>
<out:Effective_Date>2017-03-06</out:Effective_Date>
<out:Old_Value>WORK AMEC 2020 Winston Park Drive, Suite 700 Oakville L6H 6X7 CA ON
Ontario</out:Old_Value>
<out:New_Value>AB</out:New_Value>
</out:Row>
我認爲 和但是不能將它分配給$ oldValueLocations的本地名稱相同 –
pshemek
您可能想要編輯你的問題,並添加一個最小但完整的輸入樣本,你有你想要的輸出和輸出。我到目前爲止認爲問題是關於識別'peci:Address'元素的各種子元素。那些具有'peci:isAdded/isDeleted'屬性的元素是否也出現在不同的元素上? –
而不是: WORK AMEC 2020 Winston Park Drive,Suite 700 Oakville L6H 6X7 CA ON 安大略省 out:Old_Value> 我想在這種情況下有一個合適的值。 ON out:Old_Value> –
pshemek