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 » how to insert node without namespace in one with namespace?

Post new topic  Reply to topic
 how to insert node without namespace in one with namespace? « View previous topic :: View next topic » 
Author Message
pcelari
PostPosted: Wed Mar 18, 2009 1:13 pm    Post subject: how to insert node without namespace in one with namespace? Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

Hi,

my output msgset has namespace enabled. But I need to insert inputBody under a node in the output message tree that has namespace enabled.

Now I got exception upon putting the msg: "Element must have a namespace specified if there is a default namespace in scope"


set OutputRoot.Properties.MessageSet = 'myMessage';
set OutputRoot.Properties.MessageType = 'Message';
set OutputRoot.Properties.MessageFormat = 'XML1';

SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version = '1.0';
SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding = 'UTF-8';
SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)StandAlone = 'No';

SET OutputRoot.XMLNSC.mc:Message.(XMLNSC.NamespaceDecl)xmlns = 'http://ws.mycompany.com/MC';
SET OutputRoot.XMLNSC.mc:Message.(XMLNSC.NamespaceDecl)xmlns:mc = 'http://ws.mycompany.com/MC';

...

-- here I got the above exception message --
set OutputRoot.XMLNSC.mc:Message.mc:Data.*[1] = InputBody;

Any insight would be appreciated.


_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 18, 2009 2:16 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Well you have multiple possibilities.

  • do not use a global namespace (suppress this line:
    SET OutputRoot.XMLNSC.mc:Message.(XMLNSC.NamespaceDecl)xmlns = 'http://ws.mycompany.com/MC'; )

  • reset the global namespace for the Data element
    SET OutputRoot.XMLNSC.mc:Message.mc:Data.(XMLNSC.NamespaceDecl)xmlns='';

  • or loop through the tree that you are adding and set the namespace for each of its elements


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pcelari
PostPosted: Thu Mar 19, 2009 6:04 am    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

Many thanks for the insight, it did the trick!

I took option 2, now the firstchild of Data node has no more namespace attached.

But the global prefix becomes "NS1" instead of "mc" as it supposed to be. the declaration line in the message looks this way:

<?xml version="1.0" encoding="UTF-8" standalone="No"?>
<NS1:Message xmlns:NS1="mc" xmlns="http://ws.mycompany.com/MC" xmlns:mc="http://ws.mycompany.com/MC">

It's weired, I didn't set the xmlns:NS1="mc", nor doees it exist in the msgset.

What am I missing?
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
HOMETOWN47
PostPosted: Thu Mar 19, 2009 8:55 am    Post subject: Reply with quote

Apprentice

Joined: 25 Mar 2003
Posts: 34

Excerpt for MB 6.1 help

Writing
Namespaces and their prefixes are preserved in the message tree when parsing, and are used when the XMLNS and XMLNSC parsers convert a message tree to an XML bitstream.

When serializing a message tree, the parser scans for namespace declarations on each XML element. If any are found, it uses them to select the namespace prefixes in the output document.
If an element in the message tree has a namespace, but there is no in-scope namespace declaration for its namespace URI, a valid namespace prefix is automatically generated and used in the output XML. Auto-generated prefixes have the form NS1, NS2, and so on.

I've seen other posts on this subject in the forum that explains why this is the case but it's the section in bold that is the reason. Kimbert is your main man on the subject !!
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 19, 2009 12:51 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I've just noticed this:
Code:
set OutputRoot.Properties.MessageType = 'Message';
set OutputRoot.Properties.MessageFormat = 'XML1';
XMLNSC never looks at
- MessageType
- MessageFormat
- Information in messageSet.mset
- Physical format information in the message definition files

An XML physical format is intended for use by the MRM parser only.
Hopefully this will save you some time, because some users have tried juggling message set properties and have wondered why XMLNSC did not respond
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 19, 2009 12:59 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

and I've just noticed this as well:
Code:
<NS1:Message xmlns:NS1="mc" xmlns="http://ws.mycompany.com/MC" xmlns:mc="http://ws.mycompany.com/MC">

What is the namespace of root tag 'Message'? It is 'mc'. I strongly suspect that you wanted it to be 'http://ws.mycompany.com/MC'.

So, to answer your question, you are missing this:
Code:
DECLARE mc NAMESPACE 'http://ws.mycompany.com/MC';


In other words, you are building a message tree with the wrong namespace for all elements in the 'mc' namespace.
Changing the namespace declaration on 'Data' would not have broken this, so I suspect it was an accidental change, or else this problem was there before.
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 » how to insert node without namespace in one with namespace?
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.