Author |
Message
|
KoGor |
Posted: Mon Feb 24, 2014 1:31 am Post subject: Namespace declaration in XMLNSC |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Is it possible in XMLNSC output message to set custom namespace different from default NS1 and etc?
There is no problem with domain XMLNS. As information center says the code is working well:
Code: |
SET OutputRoot.XMLNS.message.(XML.NamespaceDecl)xmlns:space1 = 'http://www.ibm.com/space1';
SET OutputRoot.XMLNS.message.sp1:data1 = 'Hello!';
|
But I still could not figure out how to set it with XMLNSC domain. Is it possible at all?
Thank you in advance! |
|
Back to top |
|
 |
mqsiuser |
Posted: Mon Feb 24, 2014 1:41 am Post subject: Re: Namespace declaration in XMLNSC |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
You have to do some work for your namespaces to work properly.
Define them at the beginning of your code (or in a separate esql (that you probably "include")).
DECLARE sp1 NAMESPACE 'http://www....';
Then use it, and yes it is also possible to get you own names into it (not just NS1, NS2, ... Broker just uses that if it doesn't know better, because you missed to tell him). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
KoGor |
Posted: Mon Feb 24, 2014 1:53 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Here is the sample that I tried. I have manage to set my own namespace (space1) only with XMLNS parser. When I just replace XMLNS with XMLNSC domain WMB (v7006) is changing my namespace to its own default NS1 value.
Code: |
CREATE COMPUTE MODULE TestFlow_Compute1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
DECLARE sp1 NAMESPACE 'http://www.ibm.com/space1';
-- Namespace declaration for prefix 'space1'
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNS' ;
SET OutputRoot.XMLNS.message.(XML.NamespaceDecl)xmlns:space1 = 'http://www.ibm.com/space1';
SET OutputRoot.XMLNS.message.sp1:data1 = 'Hello!';
RETURN TRUE;
END;
|
The output for XMLNS domain:
Code: |
<message xmlns:space1="http://www.ibm.com/space1">
<space1:data1>Hello!</space1:data1>
</message>
|
The output for XMLNSC domain:
Code: |
<message xmlns:NS1="http://www.ibm.com/space1">
<NS1:data1>Hello!</NS1:data1>
</message>
|
|
|
Back to top |
|
 |
mqsiuser |
Posted: Mon Feb 24, 2014 2:16 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
This has been discussed before (2009). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
KoGor |
Posted: Mon Feb 24, 2014 3:43 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Thank you mqsiuser!
I have added double quotation marks to namespace and it worked!
SET OutputRoot.XMLNSC.message.(XMLNSC.NamespaceDecl)xmlns:"space1" = 'http://www.ibm.com/space1'; |
|
Back to top |
|
 |
mqsiuser |
Posted: Mon Feb 24, 2014 3:50 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Thank you too
I like you too
Credits actually belong to Kimbert
And you could try harder on googling the forum/internet, before opening a new thread. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 24, 2014 5:38 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I have added double quotation marks to namespace and it worked! |
I refuse to take the credit for making it work, if you are claiming that changing the quotes was the answer!
A string constant in ESQL is usually single-quoted. Your new code works because you are using XMLNSC.NamespaceDecl instead of XML.NamespaceDecl. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
KoGor |
Posted: Tue Feb 25, 2014 1:06 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Take my words back it is not double quotation marks solved the problem. It really was my mistake. I have not replaced XML.NamespaceDecl by XMLNSC.NamespaceDecl while running the sample . Now I removed double quotation marks and it's working still. Thank you for pointing that out! |
|
Back to top |
|
 |
|