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 » Changing Namespace Prefix

Post new topic  Reply to topic
 Changing Namespace Prefix « View previous topic :: View next topic » 
Author Message
martc
PostPosted: Tue Aug 28, 2007 8:59 am    Post subject: Changing Namespace Prefix Reply with quote

Apprentice

Joined: 23 Mar 2005
Posts: 39

Hi,

Is there a simple ESQL command to change the namespace prefix ONLY, leaving the namespace intact.

We have a client that hardcoded for a specific prefix and a temporary solution until they fix their issue was to change the prefix to their expectation.

thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Aug 28, 2007 9:08 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you're using MRM-XML, you can configure this on the message properties.

If you're using XMLNS or XMLNSC... You can set a Namespace Declaration.

Set OutputRoot.XMLNSC.(XMLNSC.NamespaceDecl)xmlns:prefix='namespace';

Set OutputRoot.XMLNS.(XML.NamespaceDecl)xmlns:prefix='namespace';

or something similar.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
martc
PostPosted: Tue Aug 28, 2007 2:25 pm    Post subject: Reply with quote

Apprentice

Joined: 23 Mar 2005
Posts: 39

Thanks Jeff, the DECLARE did not change an existing prefix for me.

My approach was to strip the namespaces first and then recreate them using these procs which I got from another link. The strip works nicely but the setnamespace only sets the namespace and not the prefix. The command SET FieldRefPtr.(XML.NamespaceDecl)xmlns:svc = namespace; actually placed this namespace on every tag which is not what i was hoping for.




CREATE PROCEDURE StripNamespac(IN StartRefPtr REFERENCE)
BEGIN
DECLARE FieldRefPtr REFERENCE TO StartRefPtr;

MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
END IF;

WHILE LASTMOVE(FieldRefPtr) DO
CALL StripNamespac(FieldRefPtr);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END;


CREATE PROCEDURE SetNamespace(IN StartRefPtr REFERENCE, IN namespace CHARACTER)
BEGIN
DECLARE FieldRefPtr REFERENCE TO StartRefPtr;

MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
END IF;

WHILE LASTMOVE(FieldRefPtr) DO
CALL SetNamespace(FieldRefPtr,namespace);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
--SET FieldRefPtr.(XML.NamespaceDecl)xmlns:svc = namespace;

END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END;
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Aug 28, 2007 2:38 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Thanks Jeff, the DECLARE did not change an existing prefix for me.
What?! Jeff never said anything about using DECLARE!

You need to understand how the XMLNS and XMLNSC parsers use namespaces.
a) Every field in the message tree has a namespace, which may be the empty string if the element does not have one.
b) When parsing, <prefix:el xmlns:prefix="myNamespace"/> causes the element 'el' to be put into the message tree with a child 'attribute' representing the namespace declaration. The child 'attribute' has type 'XML.NamespaceDecl'
c) When writing a message tree, the XMLNS parser scans for elements with Type set to 'XML.NamespaceDecl' and modifies the prefixes in the output bitstream accordingly. So if you don't change the parsed message tree, the prefixes will be the same in the ouput XML as they were in the input XML.
d) If you want to change the prefixes, you have exactly one option : change the namespace declarations in the message tree.
Back to top
View user's profile Send private message
martc
PostPosted: Fri Sep 07, 2007 1:11 pm    Post subject: Reply with quote

Apprentice

Joined: 23 Mar 2005
Posts: 39

Hey guys, thanks for the tip. I got it working by setting the namespace as you suggested.
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 » Changing Namespace 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.