Author |
Message
|
lanny boy |
Posted: Fri Nov 19, 2004 2:44 am Post subject: XMLNS and Cardinality |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Hi
I am having trouble accessing the cardinality of a message in the XMLNS domain.
Consider the following XML Message.
<Elem1>
<Elem2>Fisrt</Elem2>
<Elem2>Second</Elem2>
<Elem1>
If I do the following while in the XML domain ,X =2 which is what i would expect...
Set X = Cardinality(InputRoot.XMLNS.Elem1.Elem2[]);
However If i am in the XMLNS domain X = 0.
I am confused as to why this should be. I have tried using
Set X = Cardinality("InputRoot.XMLNS.Elem1[]);
This gives me a value of 1(correct), but i can't seem to return a cardinality value further down the tree.
Any ideas? I am on WBIMB V5 CSD 04
Thanks
Lanny Boy |
|
Back to top |
|
 |
TonyD |
Posted: Fri Nov 19, 2004 2:34 pm Post subject: |
|
|
Knight
Joined: 15 May 2001 Posts: 540 Location: New Zealand
|
Elem1 and Elem2 will have to be preceded with the namespace or its specified prefix:
Quote: |
Set X = Cardinality(InputRoot.XMLNS.myNS:Elem1.myNS:Elem2[]);
|
|
|
Back to top |
|
 |
lanny boy |
Posted: Mon Nov 22, 2004 1:18 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Thanks for that TonyD,
There is no prefix because it has been passed through an RCD in the node before which resets the Domain to XMLNS.
As a result the message elements "appear" (in debug) to change from .myNS:Elem1 before the RCD to .Elem1 after.
Does the XMLNS not change the logical message tree by removing the prefix??
Lanny Boy |
|
Back to top |
|
 |
juddg |
Posted: Mon Nov 22, 2004 7:02 am Post subject: |
|
|
Apprentice
Joined: 22 Nov 2004 Posts: 33
|
Lanny Boy,
Is the example message you give the actual message you are inputting to the message flow ? If not please can you post the actual message. Your last reply indicates that the inpt message may be using namespaces and namespace prefixes. Also please can you supply the sequence of nodes in your flow, the domain on the input node, the domain on the RCD node and the ESQL you are using in any compute nodes.
Thanks,
Geoff. |
|
Back to top |
|
 |
lanny boy |
Posted: Mon Nov 22, 2004 7:37 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Geoff,
My situation is as follows. I will receive XML messages from a variety of third party providers, each of which could potentially use a different namespace/prefix. These messages are wrapped in another XML "header" message which needs to be removed before parsing can be done. This header does not use namespaces.
As a result the input node i have uses the XML domain, and a subsequent compute node extracts necessary header information and sends on the main XML message (complete with namespaces). At this stage the message looks like this......
<abc:Document xmlns:abc="urn:abc:msgtype.xyz.123.rst"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<abc:msgtype.xyz.123.rst>
<abc:Elem1>
<abc:Child1>ABCD</abc:Child1>
</abc:Elem1>
<abc:Elem2>
<abc:Child2>
<abc:GrandChild2>Data</abc:GrandChild2>
</abc:Child2>
</abc:Elem2>
</abc:msgtype.xyz.123.rst>
In order to remove the prefixes I pass this message through an RCD which resets the domain to XMLNS. When i view this in debug it appears that the prefixes have been removed, see below
<msgtype.xyz.123.rst>
<Elem1>
<Child1>ABCD</Child1>
<Elem1>
<Elem2>
<Child2>
<GrandChild2>Data</GrandChild2>
<Child2>
<Elem2>
<msgtype.xyz.123.rst>
However I cannot interrogate the tree and retrieve element data.....
Any Idea's....... |
|
Back to top |
|
 |
alexey |
Posted: Mon Nov 22, 2004 7:56 am Post subject: |
|
|
 Acolyte
Joined: 18 Dec 2003 Posts: 62 Location: Israel
|
Hi,
Quote: |
Does the XMLNS not change the logical message tree by removing the prefix?? |
Actually, RCD does no changes on the data, but re-parses it according to the domain/set/type... So the namespaces are not gone, they are just not shown in the debugger.
You can use "*:elem" to use "any namespace", if you can't hard code it, or use
DECLARE NS CHAR FIELDNAMESPACE(elem);
(this way you could also check if there actually is a namespace on your field)
and later in your code
SET ... = ... {NS}:elem.
This should work too.
You could get some warnings on the unresolvable references - ignore.
Alexey. |
|
Back to top |
|
 |
juddg |
Posted: Mon Nov 22, 2004 9:36 am Post subject: |
|
|
Apprentice
Joined: 22 Nov 2004 Posts: 33
|
Hi,
I am in agreement with the last reply. It is also worth noting that XML instance documents that do not use namespaces can still be parsed using the XMLNS domain.
Regards,
Geoff. |
|
Back to top |
|
 |
lanny boy |
Posted: Tue Nov 23, 2004 1:35 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Thanks Alexey / Geoff for you replies.
I am however a little confused where you say I can use "*" as a wildcard character to replace the prefix.
Quote: |
You can use "*:elem" to use "any namespace", if you can't hard code it . |
I know I can use it if i use an XML schema within an RCD, by changinf the schema definition, but in this case i am resetting the domain only. I am not validating it against a schema, I am only trying to remove the prefix...
If i have understood Alexey's post correctly then "*" is treated as a wildcard within ESQL?
I have tried it and it just seems to treat * as a normal character...
Set X = CARDINALITY("InputBody"."*:Document"."*:msgtype.xyz.123.rst")
X is set to 0 in this case.
Have I completely missed the point here!!!
Lanny Boy |
|
Back to top |
|
 |
juddg |
Posted: Tue Nov 23, 2004 2:52 am Post subject: |
|
|
Apprentice
Joined: 22 Nov 2004 Posts: 33
|
Hi,
I would like to try and reproduce the problem you are seeing. Please can you post the example message with is headers and the ESQL that you are using to remove the headers and pass on the body of the message to the RCD node.
Thanks,
Geoff. |
|
Back to top |
|
 |
lanny boy |
Posted: Tue Nov 23, 2004 3:19 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Hi Geoff
My inbound message is in the following format
<?xml version='1.0' encoding='UTF-8'?>
<HeaderLevel1>
<HeaderLevel2>
<HeaderLevel4>
<Sender>correspondent2</Sender>
<Target>correspondent1</Target>
<Service>service!a</Service>
<Reference>ABCD1234poiu</Reference>
</HeaderLevel4>
<HeaderLevel3>
<abc:Document xmlns:abc="urn:msg:abc:MsgType.ABC"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<abc:MsgType.ABC>
<abc:OrderReference>
<abc:Ref>ABCD</abc:Ref>
</abc:OrderReference>
<abc:DealDetails>
<abc:IndvDtls>
<abc:OrdrRef>DEAL1</abc:OrdrRef>
<abc:OrdrTp>SELL</abc:OrdrTp>
<abc:Product>
<abc:Type>XXXX122548</abc:Type>
</abc:Product>
<abc:Amt Ccy="EUR">54342.87</abc:Amt>
</abc:IndvDtls>
<abc:IndvDtls>
<abc:OrdrRef>DEAL2</abc:OrdrRef>
<abc:OrdrTp>SELL</abc:OrdrTp>
<abc:Product>
<abc:Type>XXXX698451</abc:Type>
</abc:Product>
<abc:Amt Ccy="EUR">1222.87</abc:Amt>
</abc:IndvDtls>
</abc:DealDetails>
</abc:MsgType.ABC>
</abc:Document>
</HeaderLevel3>
</HeaderLevel2>
</HeaderLevel1>
The input node sets the domain to XML.
The first compute node retreives the data from the block <HeaderLevel4>
I then discard the header and send on the message using the following code.
--Now set the output root to be the document
SET OutputRoot."XML".{FieldReference} = "InputBody"."HeaderLevel1"."HeaderLevel2"."HeaderLevel3".{FieldReference};
(Where Field Reference = abc:Document)
It is then passed through and RCD that resets the domain to be XMLNS. It is in the next compute node that I cannot access the cardinality of the lower elements......
I have tried using the * wildcard to no avail...
Lanny Boy |
|
Back to top |
|
 |
juddg |
Posted: Tue Nov 23, 2004 6:23 am Post subject: |
|
|
Apprentice
Joined: 22 Nov 2004 Posts: 33
|
Hi,
If you remove the * and : from the quotes so that the ESQL recogises it as a wildcard it should work.
eg. Set X = CARDINALITY("InputBody".*:"Document".*:"msgtype.xyz.123.rst")
Also you could remove the requirement for an RCD node by setting the Domain on the input to be XMLNS and then in the ESQL for the first compute node specifying the following to remove the headers.
DECLARE abc NAMESPACE "urn:msg:abc:MsgType.ABC";
SET OutputRoot."XMLNS".abc:"Document" = "InputBody"."HeaderLevel1"."HeaderLevel2"."HeaderLevel3".abc:"Document";
Regards,
Geoff. |
|
Back to top |
|
 |
lanny boy |
Posted: Tue Nov 23, 2004 7:15 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2003 Posts: 79 Location: UK
|
Thanks very much for your help Geoff. That worked!!
Lanny Boy |
|
Back to top |
|
 |
|