2012-01-11 5 views
0

xmlタスクは、あるノードの値をリスト内の各要素の別のノードにコピーできますか?xmltaskで別の値をコピーする

ソースXML:

<a> 
<b> 
    <c1>foo</c1> 
    <c2></c2> 
</b> 
<b> 
    <c1>bar</c1> 
    <c2></c2> 
</b> 
... 
</a> 

先のXML:

<a> 
<b> 
    <c1>foo</c1> 
    <c2>foo</c2> 
</b> 
<b> 
    <c1>bar</c1> 
    <c2>bar</c2> 
</b> 
... 
</a> 

私は私のAntタスクで上記を達成しようとしているが、私はそれを行うための方法を見つけるように見えるcon'tここで私はこれまで何をしているのですか?

<target name="mergefile">  
    <!-- Read the source into a buffer --> 
    <xmltask source="source.xml" clearBuffers="list"> 
     <copy path="/a" buffer="list" append="true"/> 
    </xmltask> 

    <!-- Write them to the output --> 
    <xmltask source="destination.xml" dest="destination.xml" 
     outputter="simple"> 
     <!-- First clear all the old paths. --> 
     <remove path="https://stackoverflow.com/a/b"/> 
    <!-- Then add the resolved ones. --> 
     <paste path="/a" buffer="list"></paste> 
      <!-- Copy the value over? --> 
     <replace path="a/b/c2/text()" withText="No Idea"/> 
    </xmltask> 
</target> 

すべてのelemenの値を1つのノードから次のノードにコピーする方法リストのts?

+0

はdestination.xmlは、この例では最初は空ですか? –

+0

@Brianそれは '...'私は 'aノードの内容をsource.xmlからのパスで置き換えようとしています。 – Andrew

答えて

0

通常、私自身の仕事を書くことが私がそれを行うために見ることができる唯一の方法だったと思います。

@Override 
public void execute() throws BuildException { 
    //Read file line by line, regex test on each line, 
    //matches get written back twice. 
} 

すると、それがあったの呼び出し

<copyregmatch file="myfile.xml" regex=".*replace.*" /> 
関連する問題