How to replace XML result for distinct value case?
如何为不同的值案例替换XML结果?
I get value groupId
but I want to replace it into groupName
which can be read by Customer and not only just Number.
我得到值groupId但我想将它替换为groupName,可以由Customer读取,而不仅仅是Number。
<TestList>
<Test>
<number>1000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>2000</number>
<groupId>3434</groupId>
</Test>
<Test>
<number>3000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>4000</number>
<groupId>4444</groupId>
</Test>
</TestList>
Expected Result
<TestList>
<Test>
<number>1000</number>
<groupId>Group 1</groupId>
</Test>
<Test>
<number>2000</number>
<groupId>Group 2</groupId>
</Test>
<Test>
<number>3000</number>
<groupId>Group 1</groupId>
</Test>
<Test>
<number>4000</number>
<groupId>Group 3</groupId>
</Test>
</TestList>
Thanks,
Andree
1 个解决方案
#1
0
In 11g, I think you can use the BEA group by extension. Try something like this:
在11g中,我认为您可以通过扩展使用BEA组。尝试这样的事情:
declare variable $data :=
<TestList>
<Test>
<number>1000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>2000</number>
<groupId>3434</groupId>
</Test>
<Test>
<number>3000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>4000</number>
<groupId>4444</groupId>
</Test>
</TestList>;
<TestList>{
let $groups :=
for $test in $data/Test
group $test as $testGroup by $test/groupId as $groupId
return
<group>{$testGroup}</group>
for $group at $pos in $groups,
$test in $group/Test
return
<Test>
{$test/number}
<groupId>{$pos}</groupId>
</Test>
}</TestList>
#1
0
In 11g, I think you can use the BEA group by extension. Try something like this:
在11g中,我认为您可以通过扩展使用BEA组。尝试这样的事情:
declare variable $data :=
<TestList>
<Test>
<number>1000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>2000</number>
<groupId>3434</groupId>
</Test>
<Test>
<number>3000</number>
<groupId>2323</groupId>
</Test>
<Test>
<number>4000</number>
<groupId>4444</groupId>
</Test>
</TestList>;
<TestList>{
let $groups :=
for $test in $data/Test
group $test as $testGroup by $test/groupId as $groupId
return
<group>{$testGroup}</group>
for $group at $pos in $groups,
$test in $group/Test
return
<Test>
{$test/number}
<groupId>{$pos}</groupId>
</Test>
}</TestList>