Completed Xquery for multiple for loops
I have the input request like below
<Input>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
</BusinessObjects>
</Input>
i need to form an output like below schema
<Output>
<BusinessObject>
<BIKey></BIKey>
<BKey></BIKey>
<Bvalue></Bvalue>
<BOID></BOID>
</BusinessObject>
</Output>
For the above payload
The output should be
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
i have tried below Xquery to get the same but ended up with errors or not meeting the requiremnt
<Ouput>
<BusinessObjects>
{
for $bi in Input/BusinessObjects/BusinessObject/BusinessIdentifiers/BusinessIdentifier
return
<BIKey>
{
string-join(
for $bo in Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, '|'),
':'
)
}
</BIKey>
<BKey>data {$bi/Bkey}</BKey>
<Bvalue>data {$bi/Bvalue}</Bvalue>
for $bo in Input/BusinessObjects/BusinessObject return <BOID>{string-join($bo//BValue, ':')}<BOID>
}
</BusinessObjects>
</Ouput>
the description for the output fields as follows
BIKey-->it has formed with all the Bvalues of 'Business Identifier' concatenated with ':' and then for each businessobject it is separed with '|'
Bkey-->Straight mapping with bkey
Bvalue-->Straight mapping with Bvalue
BOID--> it has to formed for each businessobject, need to concatenate the values Bvalues of Business Identifiers with ':'
Any suggestions, i believe that i have to two complex loops in here, but not able to crack it.
Thanks
eclipse xquery oracle-service-bus
add a comment |
I have the input request like below
<Input>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
</BusinessObjects>
</Input>
i need to form an output like below schema
<Output>
<BusinessObject>
<BIKey></BIKey>
<BKey></BIKey>
<Bvalue></Bvalue>
<BOID></BOID>
</BusinessObject>
</Output>
For the above payload
The output should be
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
i have tried below Xquery to get the same but ended up with errors or not meeting the requiremnt
<Ouput>
<BusinessObjects>
{
for $bi in Input/BusinessObjects/BusinessObject/BusinessIdentifiers/BusinessIdentifier
return
<BIKey>
{
string-join(
for $bo in Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, '|'),
':'
)
}
</BIKey>
<BKey>data {$bi/Bkey}</BKey>
<Bvalue>data {$bi/Bvalue}</Bvalue>
for $bo in Input/BusinessObjects/BusinessObject return <BOID>{string-join($bo//BValue, ':')}<BOID>
}
</BusinessObjects>
</Ouput>
the description for the output fields as follows
BIKey-->it has formed with all the Bvalues of 'Business Identifier' concatenated with ':' and then for each businessobject it is separed with '|'
Bkey-->Straight mapping with bkey
Bvalue-->Straight mapping with Bvalue
BOID--> it has to formed for each businessobject, need to concatenate the values Bvalues of Business Identifiers with ':'
Any suggestions, i believe that i have to two complex loops in here, but not able to crack it.
Thanks
eclipse xquery oracle-service-bus
add a comment |
I have the input request like below
<Input>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
</BusinessObjects>
</Input>
i need to form an output like below schema
<Output>
<BusinessObject>
<BIKey></BIKey>
<BKey></BIKey>
<Bvalue></Bvalue>
<BOID></BOID>
</BusinessObject>
</Output>
For the above payload
The output should be
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
i have tried below Xquery to get the same but ended up with errors or not meeting the requiremnt
<Ouput>
<BusinessObjects>
{
for $bi in Input/BusinessObjects/BusinessObject/BusinessIdentifiers/BusinessIdentifier
return
<BIKey>
{
string-join(
for $bo in Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, '|'),
':'
)
}
</BIKey>
<BKey>data {$bi/Bkey}</BKey>
<Bvalue>data {$bi/Bvalue}</Bvalue>
for $bo in Input/BusinessObjects/BusinessObject return <BOID>{string-join($bo//BValue, ':')}<BOID>
}
</BusinessObjects>
</Ouput>
the description for the output fields as follows
BIKey-->it has formed with all the Bvalues of 'Business Identifier' concatenated with ':' and then for each businessobject it is separed with '|'
Bkey-->Straight mapping with bkey
Bvalue-->Straight mapping with Bvalue
BOID--> it has to formed for each businessobject, need to concatenate the values Bvalues of Business Identifiers with ':'
Any suggestions, i believe that i have to two complex loops in here, but not able to crack it.
Thanks
eclipse xquery oracle-service-bus
I have the input request like below
<Input>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
</BusinessObjects>
</Input>
i need to form an output like below schema
<Output>
<BusinessObject>
<BIKey></BIKey>
<BKey></BIKey>
<Bvalue></Bvalue>
<BOID></BOID>
</BusinessObject>
</Output>
For the above payload
The output should be
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
i have tried below Xquery to get the same but ended up with errors or not meeting the requiremnt
<Ouput>
<BusinessObjects>
{
for $bi in Input/BusinessObjects/BusinessObject/BusinessIdentifiers/BusinessIdentifier
return
<BIKey>
{
string-join(
for $bo in Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, '|'),
':'
)
}
</BIKey>
<BKey>data {$bi/Bkey}</BKey>
<Bvalue>data {$bi/Bvalue}</Bvalue>
for $bo in Input/BusinessObjects/BusinessObject return <BOID>{string-join($bo//BValue, ':')}<BOID>
}
</BusinessObjects>
</Ouput>
the description for the output fields as follows
BIKey-->it has formed with all the Bvalues of 'Business Identifier' concatenated with ':' and then for each businessobject it is separed with '|'
Bkey-->Straight mapping with bkey
Bvalue-->Straight mapping with Bvalue
BOID--> it has to formed for each businessobject, need to concatenate the values Bvalues of Business Identifiers with ':'
Any suggestions, i believe that i have to two complex loops in here, but not able to crack it.
Thanks
eclipse xquery oracle-service-bus
eclipse xquery oracle-service-bus
edited Nov 22 '18 at 15:57
sivakumar kala
asked Nov 22 '18 at 13:53


sivakumar kalasivakumar kala
114
114
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
With the query
<Output>
<BusinessObjects>
{
//BusinessIdentifier
!
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject!string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject!string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
at https://xqueryfiddle.liberty-development.net/948Fn5g I get the result
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
In XQuery 1 you don't have the !
simple map operator but you should be able to use for .. return
instead, see https://xqueryfiddle.liberty-development.net/948Fn5g/1 with
<Output>
<BusinessObjects>
{
for $bi in //BusinessIdentifier
return
<BusinessObject>
<BIKey>{string-join($bi/ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
$bi/BKey,
$bi/BValue
}
<BOID>{$bi/ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
or simple steps constructing a new element, see https://xqueryfiddle.liberty-development.net/948Fn5g/2 with
<Output>
<BusinessObjects>
{
//BusinessIdentifier/
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives likefor .. return
or a step with an element constructor instead of the!
map operator. As forancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.
– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
asfor $bo in $bi return string-join($bo//Value, ':')
.
– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432504%2fcompleted-xquery-for-multiple-for-loops%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
With the query
<Output>
<BusinessObjects>
{
//BusinessIdentifier
!
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject!string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject!string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
at https://xqueryfiddle.liberty-development.net/948Fn5g I get the result
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
In XQuery 1 you don't have the !
simple map operator but you should be able to use for .. return
instead, see https://xqueryfiddle.liberty-development.net/948Fn5g/1 with
<Output>
<BusinessObjects>
{
for $bi in //BusinessIdentifier
return
<BusinessObject>
<BIKey>{string-join($bi/ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
$bi/BKey,
$bi/BValue
}
<BOID>{$bi/ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
or simple steps constructing a new element, see https://xqueryfiddle.liberty-development.net/948Fn5g/2 with
<Output>
<BusinessObjects>
{
//BusinessIdentifier/
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives likefor .. return
or a step with an element constructor instead of the!
map operator. As forancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.
– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
asfor $bo in $bi return string-join($bo//Value, ':')
.
– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
|
show 3 more comments
With the query
<Output>
<BusinessObjects>
{
//BusinessIdentifier
!
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject!string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject!string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
at https://xqueryfiddle.liberty-development.net/948Fn5g I get the result
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
In XQuery 1 you don't have the !
simple map operator but you should be able to use for .. return
instead, see https://xqueryfiddle.liberty-development.net/948Fn5g/1 with
<Output>
<BusinessObjects>
{
for $bi in //BusinessIdentifier
return
<BusinessObject>
<BIKey>{string-join($bi/ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
$bi/BKey,
$bi/BValue
}
<BOID>{$bi/ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
or simple steps constructing a new element, see https://xqueryfiddle.liberty-development.net/948Fn5g/2 with
<Output>
<BusinessObjects>
{
//BusinessIdentifier/
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives likefor .. return
or a step with an element constructor instead of the!
map operator. As forancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.
– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
asfor $bo in $bi return string-join($bo//Value, ':')
.
– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
|
show 3 more comments
With the query
<Output>
<BusinessObjects>
{
//BusinessIdentifier
!
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject!string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject!string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
at https://xqueryfiddle.liberty-development.net/948Fn5g I get the result
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
In XQuery 1 you don't have the !
simple map operator but you should be able to use for .. return
instead, see https://xqueryfiddle.liberty-development.net/948Fn5g/1 with
<Output>
<BusinessObjects>
{
for $bi in //BusinessIdentifier
return
<BusinessObject>
<BIKey>{string-join($bi/ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
$bi/BKey,
$bi/BValue
}
<BOID>{$bi/ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
or simple steps constructing a new element, see https://xqueryfiddle.liberty-development.net/948Fn5g/2 with
<Output>
<BusinessObjects>
{
//BusinessIdentifier/
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
With the query
<Output>
<BusinessObjects>
{
//BusinessIdentifier
!
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject!string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject!string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
at https://xqueryfiddle.liberty-development.net/948Fn5g I get the result
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BuType</BKey>
<BValue>123</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
In XQuery 1 you don't have the !
simple map operator but you should be able to use for .. return
instead, see https://xqueryfiddle.liberty-development.net/948Fn5g/1 with
<Output>
<BusinessObjects>
{
for $bi in //BusinessIdentifier
return
<BusinessObject>
<BIKey>{string-join($bi/ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
$bi/BKey,
$bi/BValue
}
<BOID>{$bi/ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
or simple steps constructing a new element, see https://xqueryfiddle.liberty-development.net/948Fn5g/2 with
<Output>
<BusinessObjects>
{
//BusinessIdentifier/
<BusinessObject>
<BIKey>{string-join(ancestor::BusinessObjects/BusinessObject/string-join(.//BValue, ':'), '|')}</BIKey>
{
BKey,
BValue
}
<BOID>{ancestor::BusinessObject/string-join(.//BValue, ':')}</BOID>
</BusinessObject>
}
</BusinessObjects>
</Output>
edited Nov 22 '18 at 14:21
answered Nov 22 '18 at 14:10
Martin HonnenMartin Honnen
112k66278
112k66278
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives likefor .. return
or a step with an element constructor instead of the!
map operator. As forancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.
– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
asfor $bo in $bi return string-join($bo//Value, ':')
.
– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
|
show 3 more comments
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives likefor .. return
or a step with an element constructor instead of the!
map operator. As forancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.
– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
asfor $bo in $bi return string-join($bo//Value, ':')
.
– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
Thanks Martin, but just want to make sure that i am using Xquery version of 1.0. Will 'ancestor' works in this version?
– sivakumar kala
Nov 22 '18 at 14:15
See the edit where I have tried to use XQuery 1 alternatives like
for .. return
or a step with an element constructor instead of the !
map operator. As for ancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.– Martin Honnen
Nov 22 '18 at 14:24
See the edit where I have tried to use XQuery 1 alternatives like
for .. return
or a step with an element constructor instead of the !
map operator. As for ancestor
, for sure that is supported in XQuery 1 as specified, I can't tell whether any of the often rather restricted or primitive XQuery support attempts in various SQL databases have that. Anyway, if you target a certain version or certain environment, add tags for them to your question to make sure people trying to answer know your restrictions.– Martin Honnen
Nov 22 '18 at 14:24
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
Hi Martin, i am trying to embedd this code into my actual code but i ended up like below {err}XP0004 [{bea-err}XP0004b]: Found type mismatch in expression. Only empty sequence satisfies type checking rules. Expected type: node*. Actual type: {w3.org/2001/XMLSchema}string*. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery Any Idea on this?
– sivakumar kala
Nov 22 '18 at 14:53
1
1
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like
$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
as for $bo in $bi return string-join($bo//Value, ':')
.– Martin Honnen
Nov 22 '18 at 15:46
Well, if your environment says "Try using the web test console to test this XQuery" then do that, hopefully it gives you a detailed error message with details about which part of the query causes the error. Or as I said, edit your question and tag it with details of the XQuery processor/enviroment you use, then hopefully someone with expertise on the XQuery dialect or version you have available can help with some fitting code. You could also try rewriting stuff like
$bi/ancestor::BusinessObject/string-join(.//BValue, ':')
as for $bo in $bi return string-join($bo//Value, ':')
.– Martin Honnen
Nov 22 '18 at 15:46
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
Hi Martin, i am not able to deploy to the server until i have clear the error from eclipse. Any thoughts how to prcoeed with eclipse? BTW, i am using the Xquery transfomration in an OSB Project.
– sivakumar kala
Nov 23 '18 at 11:53
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432504%2fcompleted-xquery-for-multiple-for-loops%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown