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 » XML to XMLNS

Post new topic  Reply to topic
 XML to XMLNS « View previous topic :: View next topic » 
Author Message
LH33
PostPosted: Wed Jan 17, 2007 11:39 am    Post subject: XML to XMLNS Reply with quote

Master

Joined: 21 Nov 2002
Posts: 200

I am searching the forum to try to find some help in modifying a message flow to produce XML in XMLNS format where it currently does not. It currently produces the following transaction:
********************
CancelJob revision="1.0.0" environment="Test">
<ApplicationArea>
<Sender>
<Component>Test</Component>
<AuthorizationId>123</AuthorizationId>
</Sender>
<CreationDateTime>2006-09-12T15:55:00-05:00</CreationDateTime>
<BODId>123456789</BODId>
</ApplicationArea>
<DataArea>
<Job>
<JobNumber>123456</JobNumber>
</Job>
</DataArea>
</CancelJob>
***************

I am trying to modify the message flow to produce the following transaction:
***********************
<?xml version='1.0' encoding='utf-8' ?>
<CancelJob xmlns:us='http://www.testns.com/XXX-1_1'
xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:oa='http://www.openapplications.org/oagis'
revision='1.1.0'
environment='Test'>
<oa:ApplicationArea>
<oa:Sender>
<oa:Component>Test</oa:Component>
<oa:AuthorizationId>123</oa:AuthorizationId>
</oa:Sender>
<oa:CreationDateTime>2006-09-12T15:55:00-05:00</oa:CreationDateTime>
<oa:BODId>123456789</oa:BODId>
</oa:ApplicationArea>
<oa:DataArea>
<us:Job>
<us:JobNumber>123456</us:JobNumber>
</us:Job>
</oa:DataArea>
</CancelJob>
***************************

Any help would be appreciated!

Thanks!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 11:48 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Code:
declare namespace oa 'http://www.openapplications.org/oagis';
...
set OutputRoot.XMLNS.CancelJob.oa:ApplicationArea.oa:Sender.oa:Component = InputRoot.XML.CancelJob.ApplicationArea.Sender.Component;


or some such.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
LH33
PostPosted: Wed Jan 17, 2007 12:02 pm    Post subject: Reply with quote

Master

Joined: 21 Nov 2002
Posts: 200

Thanks!

I do have two additional questions.

1. Am I right in asuming I will have to go line through line adding the prefixes?

2. If an incoming transaction varies in the number of tags, is there a looping way to add the prefix? For example, I could get the following:

<Filters>
<Filter index="1"/>
<Filter index="2"/>
<Filter index="3"/>
</Filters>

or I could get 20 occurences of the Filter tag.

Thanks!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 12:12 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

1) Probably. You could model your XMLNS message in MRM and use that, instead. Then if the output message had the same logical structure as the input message, you could just do "Set OutputRoot.MRM = InputRoot.XML". But your #2 suggests that that's not the case...

2) You'll probably have to do that yourself.

Also, you don't say what version of WMB you're using - hopefully it's version 6. The Mapping node might be helpful for this.

Or if you have a lot of XSLT smarts, you could define an XSLT to perform this conversion, and then use the XMLTransformation node.

But the ESQL is likely the most straight forward way.

Try not to think too much that you're just "modifying" the message. You're really doing a full transform from one logical structure (the XML without namespaces) to a different logical structure - and so it's just as complicated (or not) as mapping to or from a Cobol record.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
LH33
PostPosted: Wed Jan 17, 2007 12:21 pm    Post subject: Reply with quote

Master

Joined: 21 Nov 2002
Posts: 200

Thanks!!

I am using version 5.0.4 so it looks like ESQL is the best way.

Will I need to change the Message Domain on the output nodes from XMl to XMLNS?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 12:31 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

No, just make sure you always say "OutputRoot.XMLNS" and not "OutputRoot.XML".

This will update the Properties tree to use the right domain, so the output node will use the right parser to serialize the message tree into a bitstream.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 17, 2007 3:06 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi LH33,

You need to do the following:

- Change the output message tree from XML domain to XMLNS domain. You can do this by altering the path in all your SET OutputRoot.XML... statements. Or if you designed your original ESQL using references, you can just alter one line
- Assign a namespace to every element in the output message tree. Jeff has shown you how to do that ( DECLARE NAMESPACE myPrefix 'myURI' etc)
- Add namespace declarations to the output message tree. If you do not do this, the XMLNS serializer will assign namespace prefixes 'NS1', NS2'. Strictly speaking the prefix does not matter but most users prefer to see their own prefixes in the output XML. See the docs for some good examples: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac26040_.htm
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 17, 2007 3:10 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi LH33,

You need to do the following:

- Change the output message tree from XML domain to XMLNS domain. You can do this by altering the path in all your SET OutputRoot.XML... statements. Or if you designed your original ESQL using references, you can just alter one line
- Assign a namespace to every element in the output message tree. Jeff has shown you how to do that ( DECLARE NAMESPACE myPrefix 'myURI' etc)
- Add namespace declarations to the output message tree. If you do not do this, the XMLNS serializer will assign namespace prefixes 'NS1', NS2'. Strictly speaking the prefix does not matter but most users prefer to see their own prefixes in the output XML. See the docs for some good examples: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac26040_.htm
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 » XML to XMLNS
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.