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 BLOB removed element prefix

Post new topic  Reply to topic
 XML to BLOB removed element prefix « View previous topic :: View next topic » 
Author Message
ceteareth
PostPosted: Tue Feb 18, 2014 11:43 pm    Post subject: XML to BLOB removed element prefix Reply with quote

Acolyte

Joined: 12 Aug 2012
Posts: 51

I have read alot of post and other materials on the web but i still could not sort this out.

I am able to convert a XML into BLOB but the problem is the element prefix/namespace is removed. I would like to retain the prefix of the elements after being changed to BLOB. My xml looks something like below.

Input/Expected Output

<Person xmlns:ns1="xmlns="http://detail/detail" xmlns="http://detail/detail">
<ns1:name>my name</ns1:name>
<ns1:email>myname@email.com</ns1:email>
</Person>

Output:
<Person xmlns:ns1="xmlns="http://detail/detail" xmlns="http://detail/detail">
<name>my name</name>
<email>myname@email.com</email>
</Person>

I have a database node which has the following code. Hope someone could shine some light into this. Thanks in advance

Code:

CREATE LASTCHILD OF RootRef DOMAIN('BLOB') NAME 'BLOB';
DECLARE options INTEGER BITOR( ValidateNone, RootBitStream );
SET RootRef.BLOB.BLOB = ASBITSTREAM( RootRef.XMLNSC OPTIONS options CCSID 1208);
SET RootRef.XMLNSC = NULL;
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Wed Feb 19, 2014 12:03 am    Post subject: Re: XML to BLOB removed element prefix Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

This is not an "element prefix" but a "namespace prefix".

Probably you have to DECLARE and assign them explicity.

To your luck there are like 3 different ways to do it (there is an article in the info center about these)
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
ceteareth
PostPosted: Wed Feb 19, 2014 12:56 am    Post subject: Reply with quote

Acolyte

Joined: 12 Aug 2012
Posts: 51

thanks for quick response mqsiuser.

I am currently searching through info center.

regarding the declare and assign explicity. does this mean that i have to set the namespace prefix on each element one by one?
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Wed Feb 19, 2014 1:09 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Here is the link: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac67194_.htm

I guess you don't have to set them one by one (but you can), someone else might help... it's not always easy with namespaces.

I am sure kimbert can help.
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Wed Feb 19, 2014 1:31 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

I suppose the parser sees no need to add a prefix when the elements concerned are *already* in the proper namespace through the definition of
Code:
xmlns="http://detail/detail"


I suspect that when you remove that definition the prefix will reappear.

By the way, I suppose that
Code:
xmlns:ns1="xmlns="http://detail/detail"
is a typo, right?
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Feb 19, 2014 1:47 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Please describe all of the nodes in your flow.

If the namespace prefixes are being 'removed' then they must have been there in the input message. The XMLNSC parser will not remove them unless your flow does something to make them get removed.

btw, your input XML looks wrong to me. Look at the xmlns attribute again.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Wed Feb 19, 2014 2:08 am    Post subject: Re: XML to BLOB removed element prefix Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

WRONG:
ceteareth wrote:
<Person xmlns:ns1="xmlns="http://detail/detail" xmlns="http://detail/detail">
<ns1:name>my name</ns1:name>
<ns1:email>myname@email.com</ns1:email>
</Person>


BETTER:
Code:
<Person xmlns:ns1="http://detail/detail" xmlns="http://detail/detail">
    <ns1:name>my name</ns1:name>
    <ns1:email>myname@email.com</ns1:email>
</Person>


ALSO BETTER:
Code:
<ns1:Person xmlns:ns1="http://detail/detail">
    <ns1:name>my name</ns1:name>
    <ns1:email>myname@email.com</ns1:email>
</ns1:Person>


OR:
Code:
<Person xmlns="http://detail/detail">
    <name>my name</name>
    <email>myname@email.com</email>
</Person>

_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
ceteareth
PostPosted: Mon Feb 24, 2014 12:12 am    Post subject: Reply with quote

Acolyte

Joined: 12 Aug 2012
Posts: 51

Sorry theres a typo on my previous post. heres a more correct and complete details.

Code:
CREATE DATABASE MODULE BasicMessageFlow_Database
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      DECLARE RootRef REFERENCE TO Root;
      CALL PrepareMessage(RootRef);
      RETURN TRUE;
   END;

   CREATE PROCEDURE PrepareMessage(INOUT RootRef REFERENCE) BEGIN
      
      -- Set XML string to element node
      DECLARE XMLMESSAGE CHARACTER;
      SET XMLMESSAGE = '<xml><name>name1</name></xml>';
      SET RootRef.XMLNSC.*:Person.*:etc = XMLMESSAGE;
      
      -- Create BLOB to hold the messag
      CREATE LASTCHILD OF RootRef DOMAIN('BLOB') NAME 'BLOB';
      DECLARE options INTEGER BITOR( ValidateNone, RootBitStream );
      DECLARE BlobRef REFERENCE TO RootRef.BLOB;
      SET BlobRef.BLOB = ASBITSTREAM( RootRef.XMLNSC OPTIONS options CCSID 1208);      
      
      -- Delete XMLNSC so that only BLOB would remain
      SET RootRef.XMLNSC = NULL;
   END;
END MODULE;


Input
Code:
<Person xmlns:ns1="http://www.ibm.com/persons" xmlns="http://www.ibm.com/persons">
   <ns1:name>Person One</ns1:name>
   <ns1:email>person.one@email.com</ns1:email>
   <ns1:etc>etc</ns1:etc>
</Person>


Output
Code:

<Person xmlns:ns1="http://www.ibm.com/persons" xmlns="http://www.ibm.com/persons">
 <name>Person One</name>
 <email>person.one@email.com</email>
 <etc><xml><name>name1</name></xml></etc>
</Person>
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Mon Feb 24, 2014 1:30 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

If you want the same thing, then hand it through as BLOB.

The ns-prefixes are removed, BUT your XML is "equivalent", because the default namespace (xmlns="http://www.ibm.com/persons") is "namespacing your elements" now:

Code:
<Person xmlns="http://www.ibm.com/persons">
 <name>Person One</name>
 <email>person.one@email.com</email>
 <etc><xml><name>name1</name></xml></etc>
</Person>


So even without explicit "ns1:" the xml(-elements) is(are) logically the same.

Though there may be an option like "Always (use namespace) prefixes for xml-elements&attributes" or "don't use default namespace(s)"

But this option will likely prefix ALL you elements (including "Person"), which is not what you have as INPUT.
_________________
Just use REFERENCEs
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 BLOB removed element prefix
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.