私はtcldomを使用してスクリプトを作成しました:
package require utils
package require testrunscheduler
package require tdom
tla::TSConfig::init -schedulerContext "Reporting" -environment production
tla::TSDBFactory::getConnection db
set testCaseList [$db doSQL "SELECT root_name,suite_name,case_name FROM ics where test_type = 'tce' limit 1"]
set item [join $testCaseList ""]
set doc [dom createDocument testCases]
set root [$doc documentElement]
set subnode [$doc createElement testCase]
$root appendChild $subnode
foreach item $item {
set node [$doc createElement root]
$node appendChild [$doc createTextNode $item]
$subnode appendChild $node
}
私が得る出力は次のとおりです。
<testCases>
<testCase>
<root>SPB</root>
<root>subscriberServices</root>
<root>jmsServices</root>
</testCase>
</testCases>
しかし、出力を次のようにしたい:
<testCases>
<testCase>
<root>SPB</root>
<suite>subscriberServices</suite>
<case>jmsServices</case>
</testCase>
</testCases>
私はこれに foreach を使用しましたが、それはルートに対してのみ作成されます。おそらく欠落しています。この構造はそれ自体を繰り返し、SQL クエリからのユーザー入力のように成長します。
<testCases>
<testCase>
<root>demoRoot</root>
<suite>demoSuite</suite>
<case>demoCase</case>
<testCase>test_demo001</testCase>
</testCase>
<testCase>
<root>demoRoot</root>
<suite>demoSuite</suite>
<case>demoCase</case>
<testCase>test_demo002</testCase>
</testCase>
</testCases>
この種の出力を取得するのを手伝ってください。このプットプットを取得するのは非常に面倒です。これは反復的ですが、構造は 1 つです。