Author |
Message
|
sravan |
Posted: Tue Aug 23, 2011 4:44 pm Post subject: adding name space declaration in cdata section. |
|
|
Centurion
Joined: 02 Apr 2010 Posts: 104 Location: Charlotte
|
currently I have an XML in which I am declaring a cdata section as below.
I am unable to add the name space declaration <?xml version="1.0"?>
in the cdata section.Please give some idea about this.I want
<REQUEST_DOCUMENT_CLOB_DATA>
<![CDATA[
<?xml version="1.0"?>
<REQUEST_VARIABLE_DATA>
current XML with CData section is below.
<REQUEST_DOCUMENT_CLOB_DATA>
<![CDATA[
<REQUEST_VARIABLE_DATA>
<VARIABLE_DATA_TXT>
<VARIABLE_DATA>
<CHECK_DATE>01/01/2011</CHECK_DATE>
<CLIENT_SERVICES_NAME>Fidelity HR Solutions
</CLIENT_SERVICES_NAME>
<CLIENT_SERVICES_PHONE_NUMBER>800-835-5099
</CLIENT_SERVICES_PHONE_NUMBER>
</VARIABLE_DATA>
</VARIABLE_DATA_TXT>
</REQUEST_VARIABLE_DATA>]]>
</REQUEST_DOCUMENT_CLOB_DATA> _________________ skr_wmb |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Aug 23, 2011 7:48 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
AFAIK you're only allowed 1 XML declaration per document (<?xml version="1.0" ?>)...
So if you need to add this to a Cdata field, you might have to assign the Cdata field to a variable, parse it in the environment (assigning a parser domain) add the declaration and use ASBITSTREAM to get back to the string for the Cdata. Finally replace the Cdata with the new string...
A lot of work... might be simpler to just concatenate the declaration with the Cdata existing content and put it back into cdata...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 24, 2011 1:19 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It is illegal for an xml document to have more than one <xml declaration in it.
You should base64 encode your payload, if you wish to preserve it's contents without it being subject to the XML parsing rules - including what legal characters are. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Aug 24, 2011 2:08 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
The contents of a CDATA section are not parsed by the XML parser, so a CDATA section is allowed to contain an XML declaration. As far as the XML parser is concerned, it is not 'another XML declaration'. It's just 'character data'.
I agree with fjp_saper: unless you are already using XMLNSC to write the contents of the CDATA section, just use string concatenation.
mqjeff is correct about the limitations of CDATA - base64 encoding is the only way to *guarantee* that the contents of the CDATA section will parse successfully. |
|
Back to top |
|
 |
sravan |
Posted: Wed Aug 24, 2011 5:28 am Post subject: |
|
|
Centurion
Joined: 02 Apr 2010 Posts: 104 Location: Charlotte
|
Thanks guys It worked by adding the declaration as a string. _________________ skr_wmb |
|
Back to top |
|
 |
sravan |
Posted: Wed Aug 24, 2011 5:29 am Post subject: |
|
|
Centurion
Joined: 02 Apr 2010 Posts: 104 Location: Charlotte
|
DECLARE MessageMsgBlob BLOB ASBITSTREAM(OutputRoot.XMLNSC.Out.MESSAGE.MESSAGE_DOCUMENT_CLOB_DATA.MESSAGE_VARIABLE_DATA
OPTIONS FolderBitStream);
DECLARE MessageMsgChar CHAR
CAST(MessageMsgBlob AS CHAR CCSID InputRoot.Properties.CodedCharSetId );
c
-- Create Message CData Section out of XML.
SET OutputRoot.XMLNSC.Out.MESSAGE.MESSAGE_DOCUMENT_CLOB_DATA = NULL;
--concatenate strings to add name space declaration.
SET MessageMsgChar = NamespaceMsgChar||MessageMsgChar;
SET OutputRoot.XMLNSC.Out.MESSAGE.MESSAGE_DOCUMENT_CLOB_DATA.(XML.CDataSection)= MessageMsgChar; _________________ skr_wmb |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 24, 2011 5:36 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
sravan wrote: |
SET OutputRoot.XMLNSC.Out.MESSAGE.MESSAGE_DOCUMENT_CLOB_DATA.(XML.CDataSection)= MessageMsgChar; |
This is wrong.
Use XMLNSC.CDataField. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Aug 24, 2011 6:11 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
sravan |
Posted: Wed Aug 24, 2011 6:27 am Post subject: |
|
|
Centurion
Joined: 02 Apr 2010 Posts: 104 Location: Charlotte
|
Thanks for teh suggestions,I made the change. _________________ skr_wmb |
|
Back to top |
|
 |
|