Author |
Message
|
LH33 |
Posted: Wed Jan 17, 2007 11:39 am Post subject: XML to XMLNS |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jan 17, 2007 11:48 am Post subject: |
|
|
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 |
|
 |
LH33 |
Posted: Wed Jan 17, 2007 12:02 pm Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jan 17, 2007 12:12 pm Post subject: |
|
|
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 |
|
 |
LH33 |
Posted: Wed Jan 17, 2007 12:21 pm Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jan 17, 2007 12:31 pm Post subject: |
|
|
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 |
|
 |
kimbert |
Posted: Wed Jan 17, 2007 3:06 pm Post subject: |
|
|
 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 |
|
 |
kimbert |
Posted: Wed Jan 17, 2007 3:10 pm Post subject: |
|
|
 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 |
|
 |
|