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 » Add namespace to XML output using XML.

Post new topic  Reply to topic
 Add namespace to XML output using XML. « View previous topic :: View next topic » 
Author Message
wmb61_user
PostPosted: Tue May 20, 2008 7:08 pm    Post subject: Add namespace to XML output using XML. Reply with quote

Novice

Joined: 08 May 2008
Posts: 18

Can some one help me with defining namespaces in ESQL.
I currently have an output from comput lieke this.

<OrderHeader>
<OrderIdentifier>ABC123<OrderIdentifier>
<OrderType>3<OrderType>
<CustomerDistributionCenter>02<CustomerDistributionCenter>
</OrderHeader>

I would like to look add namespace information in my compue node.
i.e Add the XML tag and define name space lfob

<?xml version="1.0" encoding="UTF-8"?>
<lfob:OrderInventory xmlns:lfob="http://www.xyz.com/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyz.com/namespace OrderInventory.xsd ">
<lfob:OrderHeader>
<lfob:OrderIdentifier>ABC123</lfob:OrderIdentifier>
<lfob:OrderType>3</lfob:OrderType>
<lfob:CustomerDistributionCenter>02</lfob:CustomerDistributionCenter>
</lfob:OrderHeader>
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue May 20, 2008 7:41 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You need to use XMLNS and you should use XMLNSC.
As well define the namespace:

DECLARE myns NAMESPACE 'http://mynamespace';

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed May 21, 2008 1:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

It's a little more work than that. In your Compute node, you need to set the namespace on every element in your message tree ( defining and using an ESQL namespace prefix is the best way to do that, as fjp_saper says ).

That will produce an output XML document with XML namespace prefixes 'NS1', 'NS2' etc. If you want to choose your own XML namespace prefixes, you will need to add namespace declarations into the message tree.
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67194_.htm
Back to top
View user's profile Send private message
wmb61_user
PostPosted: Wed May 21, 2008 12:23 pm    Post subject: Adding XML namespace Reply with quote

Novice

Joined: 08 May 2008
Posts: 18

Kimbert, Thanks for the response. However I am still not getting it.
Can some post a snippet of code please. I want to know how to apply namespace prefix to the entire message tree.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed May 21, 2008 12:45 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I want to know how to apply namespace prefix to the entire message tree.
Sorry - not possible. The message tree is not an XML document. It is more like a DOM tree. Each node has its own namespace.
If you want to change the namespace for each and every node in the message tree, you need to explicitly set the namespace on each and every node. That means walking the tree recursively.
This has been discussed before - the code snippet in this thread may help, but treat it with care, because I think is contains a defect: http://www.mqseries.net/phpBB2/viewtopic.php?t=25039&postdays=0&postorder=asc&start=15
Back to top
View user's profile Send private message
wmb61_user
PostPosted: Thu May 22, 2008 8:30 am    Post subject: Adding XML namespace Reply with quote

Novice

Joined: 08 May 2008
Posts: 18

Kimbert,

Thanks for the direction so far. I am using the following code and getting a new namspace for each of the elements. How do I get the name space of lfob for all the elements. Thanks a lot for you help.

ECLARE lfob NAMESPACE 'http://www.lfob.com/namespace';
MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000 , 0x03000000) THEN
SET FieldRefPtr.(XMLNSC.NamespaceDecl)xmlns:lfob= 'http://www.lfob.com/namespace';
SET FieldRefPtr NAMESPACE = lfob;
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu May 22, 2008 12:49 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
How do I get the name space of lfob for all the elements

I said:
Quote:
you need to explicitly set the namespace on each and every node. That means walking the tree recursively.

I also provided a link to a code snippet showing how to recursively walk a tree and set namespaces.
Back to top
View user's profile Send private message
wmb61_user
PostPosted: Thu May 22, 2008 12:52 pm    Post subject: Reply with quote

Novice

Joined: 08 May 2008
Posts: 18

Figured it out. Thanks.
Back to top
View user's profile Send private message
wmb61_user
PostPosted: Thu May 22, 2008 1:07 pm    Post subject: Reply with quote

Novice

Joined: 08 May 2008
Posts: 18

I am almost there. Can some one tell me how to add teh xmlns:xsi and
xsi:schemaLocation to the namespace declaration.

Thanks
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu May 22, 2008 1:53 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

xmlns:xsi is just another namespace declaration. So you use XMLNSC.NamespaceDecl as before.

xsi:schemaLocation is an attribute in the xsi namespace. So you have to
- create the field using XMLNSC.Attribute
- set its namespace to the xsi namespace ( not 'xsi' )
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 » Add namespace to XML output using 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.