1
我想將子節點追加到父節點中。什麼使用xslt將下一個子節點追加到父節點
這是XML。我想追加order_d到order_h如果我的下order_h order_no是order_h
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<order>
<order_h owner="GD" order_no="421424" profoma_po="421425">
<order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783">
<Size_b assoc_id="69398" row_no="0" pct_ratio="PCT" total_pct="100" priority="0" ship_pack="BULK">
<size_d assoc_id="69398" ship_pack="BULK" ctn_sku="5602060" size_code="XS" alloc_qty="18" plan_pct_ratio="23.5" row_no="0" sort_value="5"/>
</Size_b>
</order_d>
</order_h>
<order_h owner="GD" order_no="421424" profoma_po="421425">
<order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421424" profoma_po="421425">
<order_d owner="GD" item_no="100000014" line_no="2" order_no="421424" color_code="257" manufacturer="100783">
</order_d>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421425" profoma_po="421426">
<order_d owner="GD" item_no="100000014" line_no="1" order_no="421425" color_code="730" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421425" profoma_po="421426">
<order_d owner="GD" item_no="100000014" line_no="3" order_no="421425" color_code="002" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421425" profoma_po="421426">
<order_d owner="GD" item_no="100000014" line_no="2" order_no="421425" color_code="257" manufacturer="100783">
</order_d>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421426" profoma_po="421427">
<order_d owner="GD" item_no="100000015" line_no="1" order_no="421426" color_code="000" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421426" profoma_po="421427">
<order_d owner="GD" item_no="100000015" line_no="3" order_no="421426" color_code="002" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421426" profoma_po="421427">
<order_d owner="GD" item_no="100000015" line_no="2" order_no="421426" color_code="450" manufacturer="100783">
</order_d>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421427" profoma_po="421428">
<order_d owner="GD" item_no="100000015" line_no="1" order_no="421427" color_code="000" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421427" profoma_po="421428">
<order_d owner="GD" item_no="100000015" line_no="3" order_no="421427" color_code="002" manufacturer="100783">
</order_d>
</order_h>
<order_h owner="GD" order_no="421427" profoma_po="421428">
<order_d owner="GD" item_no="100000015" line_no="2" order_no="421427" color_code="450" manufacturer="100783">
</order_d>
</order_h>
</order>
</document>
等於下列order_no,我需要如下
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<order>
<order_h owner="GD" order_no="421424" profoma_po="421425">
<order_d owner="GD" item_no="100000014" line_no="1" order_no="421424" color_code="730" manufacturer="100783"/>
<order_d owner="GD" item_no="100000014" line_no="3" order_no="421424" color_code="002" manufacturer="100783"/>
<order_d owner="GD" item_no="100000014" line_no="2" order_no="421424" color_code="257" manufacturer="100783"/>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421425" profoma_po="421426">
<order_d owner="GD" item_no="100000014" line_no="1" order_no="421425" color_code="730" manufacturer="100783"/>
<order_d owner="GD" item_no="100000014" line_no="3" order_no="421425" color_code="002" manufacturer="100783"/>
<order_d owner="GD" item_no="100000014" line_no="2" order_no="421425" color_code="257" manufacturer="100783"/>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421426" profoma_po="421427">
<order_d owner="GD" item_no="100000015" line_no="1" order_no="421426" color_code="000" manufacturer="100783"/>
<order_d owner="GD" item_no="100000015" line_no="3" order_no="421426" color_code="002" manufacturer="100783"/>
<order_d owner="GD" item_no="100000015" line_no="2" order_no="421426" color_code="450" manufacturer="100783"/>
</order_h>
</order>
<order>
<order_h owner="GD" order_no="421427" profoma_po="421428">
<order_d owner="GD" item_no="100000015" line_no="1" order_no="421427" color_code="000" manufacturer="100783"/>
<order_d owner="GD" item_no="100000015" line_no="3" order_no="421427" color_code="002" manufacturer="100783"/>
<order_d owner="GD" item_no="100000015" line_no="2" order_no="421427" color_code="450" manufacturer="100783"/>
</order_h>
</order>
</document>
感謝提前輸出
@Dimitre ..非常感謝美化代碼,但是我的xml稍作修改,並在上面進行更新。你能不能讓我知道需要在xslt中修改哪些內容才能獲得輸出結果。請不要讓你煩惱。謝謝您的幫助。 – Tarak
@ user1760923,您的問題已完全解答。無論何時「更改」源XML文檔,您實際上都有一個新問題。建議不要連續改變問題,而是提出一個新問題。因此,我建議您將問題恢復到原始狀態並提出一個新問題。另外,請*,接受*這個答案(通過點擊答案旁邊的複選標記)。 –
A您建議我已將其替換爲之前的xml並標記爲已回答。請回復這個http://stackoverflow.com/questions/13534647/appending-child-node-into-the-parent-node。 – Tarak