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 » Adding XML Declaration and Namespaces

Post new topic  Reply to topic
 Adding XML Declaration and Namespaces « View previous topic :: View next topic » 
Author Message
mangoMan
PostPosted: Wed Apr 04, 2007 1:07 pm    Post subject: Adding XML Declaration and Namespaces Reply with quote

Acolyte

Joined: 16 Oct 2003
Posts: 69

The XML message I create in the JCN does not have a declaration nor any namespaces. How can I add them so it looks like this:

Quote:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="urn:AFS:PCS:xml:specification:schema:2.0.0_Phase_8.0" xmlns:ac="urn:AFS:PCS:xml:specification:schema:2.0.0_Phase_8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:AFS:PCS:xml:specification:schema:2.0.0_Phase_8.0
C:\Projects\AFS\AFS.xsd">Req</Request>


currently it looks like this:

Quote:
<Request>Req</Request>



Here is where I create the root element:



Code:
outMessage.getRootElement().createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement outRoot = outMessage.getRootElement();
MbElement outBody = outRoot.getLastChild();   
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 04, 2007 1:15 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Read this entire page.
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac26040_.htm
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mangoMan
PostPosted: Wed Apr 04, 2007 1:36 pm    Post subject: Reply with quote

Acolyte

Joined: 16 Oct 2003
Posts: 69

Thanks Jeff.

I have been able to add the XML_DECLARATION as follows:

Code:

//
// Add XML_DECLARATION
//
MbElement xmlDecl = outBody.createElementAsFirstChild(MbXMLNSC.XML_DECLARATION);
xmlDecl.setName("XmlDeclaration");
MbElement version = xmlDecl.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "Version", "1.0");
MbElement encoding = xmlDecl.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "Encoding", "utf-8");


BUT HOW DO I CREATE THE xmlns, xmlns:xsi, xmlns:ac and the xsi:schemaLocation attributes? The is nothing in there that can help me unless the frustration from the lack of time to solve this puzzle is blinding my acute intellect.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 04, 2007 1:47 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You can add the default xmlns with setNamespace.

The rest you might need to use Broker XPath.

Or you might just be able to treat them as attributes.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mangoMan
PostPosted: Wed Apr 04, 2007 3:31 pm    Post subject: Reply with quote

Acolyte

Joined: 16 Oct 2003
Posts: 69

Thank you.

May you live long and prosper.
Back to top
View user's profile Send private message
mangoMan
PostPosted: Thu Apr 05, 2007 1:56 pm    Post subject: Reply with quote

Acolyte

Joined: 16 Oct 2003
Posts: 69

Oh, just one thing...

when I use the setNamespace() method, it creates a NS1: qualifier for the root tag and the namespace is in the root tag is defined as xmlns:NS1="default.namespace" I just want this xmlns="default.namespace"

I don't need no stinkin NS1 qualifier attached to my XML. Can I prevent that from happening?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Apr 05, 2007 2:04 pm    Post subject: Reply with quote

Grand High Poobah

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

mangoMan wrote:
Oh, just one thing...

when I use the setNamespace() method, it creates a NS1: qualifier for the root tag and the namespace is in the root tag is defined as xmlns:NS1="default.namespace" I just want this xmlns="default.namespace"

I don't need no stinkin NS1 qualifier attached to my XML. Can I prevent that from happening?

Sure, but why would you want to? Other parser recognize this correctly, so where is the problem??
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mangoMan
PostPosted: Thu Apr 05, 2007 2:49 pm    Post subject: Reply with quote

Acolyte

Joined: 16 Oct 2003
Posts: 69

I know what you mean but they want what they want.....what can I do. There must be a way to accomplish what I want.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Apr 05, 2007 5:15 pm    Post subject: Reply with quote

Grand High Poobah

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

mangoMan wrote:
I know what you mean but they want what they want.....what can I do. There must be a way to accomplish what I want.


They won't care as long as you can demonstrate that it works reliably...
Remember the best expert is the one that gets the job done.

My advice: learn what parser they use and if it is capable of handling the prefix, don't bother... just run a field demo... If it works nobody will care how as long as it works reliably... and you can truthfully say ... well we used standard xml...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Thu Apr 05, 2007 5:56 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Plus, remember, XML is only supposed to be machine readable. It's nice if it's also human readable, but in most cases not worth a lot of trouble.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Apr 06, 2007 12:38 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
There must be a way to accomplish what I want.
There is. Just create an XML declaration in the message tree at the appropriate place. There are examples of how to do this using ESQL, you just need to find out how to do it using Java.
Back to top
View user's profile Send private message
hs
PostPosted: Thu May 31, 2007 5:49 am    Post subject: Reply with quote

Novice

Joined: 03 Jun 2005
Posts: 17

How can you achieve this if you are not using the jcn ?

I have the following xml:

Code:

<a>
   <b>1234567890</b>
 </a>


I would like to do the following:

Code:

<ce:a xmlns:ce="http://www.origostandards.com/schema/ce/v2">
  <ce:b>1234567890</ce:b>
<ce:a>


Any suggestions ?
_________________
IBM Certified System Administrator - WebSphere MQ V5.3
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu May 31, 2007 5:56 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

- Decide which domain your message tree will use ( either XMLNS or XMLNSC ).
- Search the docs for examples of how to put an XML Declaration into the message tree. I assure you that such examples do exist.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu May 31, 2007 6:03 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

That's really just setting the namespace of a particular element.

You need to a) use an XML domain that supports a namespace, b) configure that element in that domain to have the given namespace.

In the case of the MRM-XML domain, this is done in the model.

In the case of XMLNS and XMLNSC, this is done in code.
_________________
I am *not* the model of the modern major general.
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 » Adding XML Declaration and Namespaces
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.