ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Getting error while creating namespaces in XML

Post new topic  Reply to topic
 Getting error while creating namespaces in XML « View previous topic :: View next topic » 
Author Message
bharadwaj
PostPosted: Wed Dec 28, 2016 6:38 pm    Post subject: Getting error while creating namespaces in XML Reply with quote

Newbie

Joined: 28 Dec 2016
Posts: 2

i am trying to create the below xml using esql

<gesmes:Envelope xmlns:gesmes="namespace1" xmlns="namespace2">
<Cube>
<Cube time="2016-05-18">
<Cube currency="EUR" rate="4.4260" />
</Cube>
</Cube>
</gesmes:Envelope>

Following is my code in esql

DECLARE gesmes NAMESPACE 'namespace1';
DECLARE eurofxref NAMESPACE 'namespace2';

SET OutputRoot.XMLNSC.gesmes:Envelope.XMLNSC.NamespaceDecl)xmlns = eurofxref;
SET OutputRoot.XMLNSC.gesmes:Envelope.Cube.Cube.(XMLNSC.Attribute)time = InputRoot.XMLNSC.ExchangeRatesSeries.Rates.Rate.EffectiveDate;
SET OutputRoot.XMLNSC.gesmes:Envelope.Cube.Cube.(XMLNSC.Attribute)currency = InputRoot.XMLNSC.ExchangeRatesSeries.Code;

When i execute, I am getting error as

Element must have a namespace specified if there is a default namespace in scope

Also instead of gesmes I am getting ns1 in output i.e

<NS1:Envelope xmlns:NS1="namespace1" xmlns="namespace2">


Can anyone suggest where I am doing wrong please..

Thanks in advance.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Dec 28, 2016 11:00 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

In your code
Code:

SET OutputRoot.XMLNSC.gesmes:Envelope.Cube.Cube.


You have to specify the exact namespace for each element
Code:

SET OutputRoot.XMLNSC.gesmes:Envelope.MyNameSpace1:Cube.MyNameSpace2Cube.


or similar.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
bharadwaj
PostPosted: Thu Dec 29, 2016 1:36 pm    Post subject: Modified my esql and it worked. Reply with quote

Newbie

Joined: 28 Dec 2016
Posts: 2

Modified my Esql as below and it worked

DECLARE ns NAMESPACE 'namespace1';
DECLARE ns1 NAMESPACE 'namespace2';

SET OutputRoot.XMLNSC.ns:Envelope.(XMLNSC.NamespaceDecl)xmlns:gesmes = ns;

DECLARE refOutEnvelope REFERENCE TO OutputRoot.XMLNSC.ns:Envelope;

SET refOutEnvelope.(XMLNSC.NamespaceDecl)xmlns = ns1;

-- Should specify some namespace below,otherwise will get "Element must have a namespace specified if there is a default namespace in scope"
SET refOutEnvelope.ns1:Cube.ns1:Cube.(XMLNSC.Attribute)time = InputRoot.XMLNSC.ExchangeRatesSeries.Rates.Rate.EffectiveDate;

I am getting output as

<gesmes:Envelope xmlns:gesmes="namespace1" xmlns="namespace2">
<Cube>
<Cube time="2016-12-23"/>
</Cube>
</gesmes:Envelope>

Now i am modifying my esql to get output as below

<Cube>
<Cube time="2016-05-18">
<Cube currency="EUR" rate="4.4260" />
</Cube>
</Cube>

So I need the time attribute should be coming in one cube element and currency and rate should be coming in other cube element.

I am writing the below esql to achieve that

SET refOutEnvelope.ns1:Cube.ns1:Cube.(XMLNSC.Attribute)time = InputRoot.XMLNSC.ExchangeRatesSeries.Rates.Rate.EffectiveDate;

SET refOutEnvelope.ns1:Cube.ns1:Cube.(XMLNSC.Attribute)currency = InputRoot.XMLNSC.ExchangeRatesSeries.Code;

But I am getting output as

<Cube>
<Cube time="2016-12-23" currency="EUR"/>
</Cube>

Any suggestions are welcome..
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Dec 29, 2016 11:07 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Please learn to use the [C O D E] tags to make your posts easier to read. They are located right above the edit box. See my previous post and you can see what it does. Isn't that easier to read and understand?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Dec 29, 2016 11:11 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Have you looked at any of the samples provided with the product?
some of them you know, use namespaces. They are an invaluable tool to help you get going.
The answer to your problem is probably elsewhere in this forum.
There is a search tool available on the upper right of the page. Have you searched for things like namespaces to see if there is a solution you can use?

We like people to try to help themselves. That way you learn a lot quicker.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
timber
PostPosted: Fri Dec 30, 2016 3:01 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

smdavies99 said:
Quote:
Please learn to use the [C O D E] tags
Seconded. If we cannot read your question easily then we may not bother to answer it.

To create the second <Cube> tag, use a CREATE statement to create your output field and specify NEXTSIBLING as the position. Or use an index on the SET statement (but that is less efficient and not a good coding habit).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Getting error while creating namespaces in XML
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.