Author |
Message
|
Maniel |
Posted: Thu Feb 16, 2006 9:18 pm Post subject: How To Generate Empty Tags On XML Message? |
|
|
Newbie
Joined: 23 Jul 2003 Posts: 4
|
Hi,
I'm very new to WMB product and working on PoC exercise with WMB v6. I'm trying to map a fix-length message to an xml message using mapping node and pre-defined xml schema. Sound like the WMB generates only the mapped fields and ignored those empty tags. For some reasons, it does not generate xml according to the message set schema.
We did a work around by inserting '' into each empty tag field within the mapping node, then it can generate those empty tags.
It won't be the best solution when map the huge xml schema, would like to hear other suggestion? _________________ Thanks & Regards
Maniel |
|
Back to top |
|
 |
kimbert |
Posted: Fri Feb 17, 2006 1:34 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
For some reasons, it does not generate xml according to the message set schema. |
I think I know what you mean, but can you give an example ( what's in the schema, what you expected on the output side, what you actually got). |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Feb 17, 2006 1:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Are the empty tags not being generated defined as mandatory or optional?
If defined as optional it is working as designed.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Maniel |
Posted: Fri Feb 17, 2006 9:15 am Post subject: |
|
|
Newbie
Joined: 23 Jul 2003 Posts: 4
|
kimbert wrote: |
I think I know what you mean, but can you give an example ( what's in the schema, what you expected on the output side, what you actually got). |
This is my input xml schema
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Body">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Tag_A"/>
<xsd:element ref="Tag_B"/>
<xsd:element ref="Tag_C"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Body"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Tag_A" type="xsd:string"/>
<xsd:element name="Tag_B" type="xsd:string"/>
<xsd:element name="Tag_C" type="xsd:string"/>
</xsd:schema> |
If I map something to Tag_A only, Tag_B & Tag_C won't appear in the xml message.
Code: |
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<Tag_A>AAAAA</Tag_A>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
I expect it can generate empty tags <Tag_B> & <Tag_C>, even they are empty.
Code: |
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<Tag_A>AAAAA</Tag_A>
<Tag_B></Tag_B>
<Tag_C></Tag_C>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
_________________ Thanks & Regards
Maniel |
|
Back to top |
|
 |
Maniel |
Posted: Fri Feb 17, 2006 9:18 am Post subject: |
|
|
Newbie
Joined: 23 Jul 2003 Posts: 4
|
fjb_saper wrote: |
Are the empty tags not being generated defined as mandatory or optional?
If defined as optional it is working as designed.
Enjoy  |
In the .mxsd file, I specify the Min Occurs to '1'. Not sure where else I should define this field is mandatory? _________________ Thanks & Regards
Maniel |
|
Back to top |
|
 |
mustache |
Posted: Fri Mar 31, 2006 1:34 am Post subject: use this esql code can generate null value XML tag |
|
|
Newbie
Joined: 21 Feb 2003 Posts: 9
|
SET OutputRoot.XML.A.DATA VALUE=null; |
|
Back to top |
|
 |
sirsi |
Posted: Wed Apr 05, 2006 12:22 pm Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
also this should work i think..
SET OutputRoot.XML.A.DATA ='';
Last edited by sirsi on Fri Apr 21, 2006 11:29 am; edited 1 time in total |
|
Back to top |
|
 |
kimbert |
Posted: Thu Apr 06, 2006 12:20 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Setting minOccurs will not affect this scenario. The XML writer will output whatever is in the message tree. If you have not mapped B and C, no tags will be generated. If you want B and C in the output ( as empty tags) you will have to do as sirsi suggests. |
|
Back to top |
|
 |
shalabh1976 |
Posted: Thu Apr 06, 2006 12:49 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
I haven't worked in MB6 but shouldn't :
Code: |
CREATE FIELD OutputRoot.XML.A.DATAVALUE; |
give the same result _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
sirsi |
Posted: Fri Apr 21, 2006 12:27 pm Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
info:
http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/index.jsp?topic=/com.ibm.etools.mft.doc/ac17250_.htm
Quote: |
You might want an empty element in the output message. On input, an empty element of the form <tag></tag> is interpreted as identical to one of the form <tag/>. On output, the default behavior of the generic XML parser is to generate empty elements in the first of these two forms. If you require the second (short) form of empty element, set the content of the element to NULL. The statement:
SET OutputRoot.XML.Invoice.Cashier.(XML.Content) = NULL;
|
|
|
Back to top |
|
 |
|