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 » Get SchemaLocation using JAVACompute Node

Post new topic  Reply to topic
 Get SchemaLocation using JAVACompute Node « View previous topic :: View next topic » 
Author Message
flahunter
PostPosted: Tue Oct 12, 2010 1:25 am    Post subject: Get SchemaLocation using JAVACompute Node Reply with quote

Acolyte

Joined: 30 Oct 2008
Posts: 62

Hi, buddies

I have a XML file as below:
<Message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./test.xsd">
<tag1>111</Tag1>
</Message>

I'm trying to get schema file name "./test.xsd" using JAVACompute node, but failed.

String SchemaName = (String)inMessage.getRootElement().getLastChild().getFirstChild().evaluateXPath("string(xsi:noNamespaceSchemaLocation)");

I'm using XMLNS as the parser. Is there anyone who can tell me how to do this?
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Oct 12, 2010 1:38 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You need to access an element which has
- namespace = 'http://www.w3.org/2001/XMLSchema-instance'
- name = 'noNamespaceSchemaLocation'

You can probably get away without specifying the namespace prefix, like this
Code:
inMessage.getRootElement().getLastChild().getFirstChild().evaluateXPath("./noNamespaceSchemaLocation);


but if you want to do it accurately, you will need to map the 'xsi' prefix to the xsi namespace URI using MbXPath.addNamespacePrefix(...) as described here:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.plugin.doc/com/ibm/broker/plugin/MbXPath.html
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 12, 2010 2:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

And you also really want to use XMLNSC instead of XMLNS.
Back to top
View user's profile Send private message
flahunter
PostPosted: Tue Oct 12, 2010 3:36 am    Post subject: Reply with quote

Acolyte

Joined: 30 Oct 2008
Posts: 62

Thank you so much. I have resolved the issue.

MbXPath xp = new MbXPath("/Message/@xsi:noNamespaceSchemaLocation");
xp.addNamespacePrefix("xsi", "http://www.w3.org/2001/XMLSchema-instance");
List nodeset = (List)inMessage.getRootElement().getLastChild().evaluateXPath(xp);
MbElement el = (MbElement)nodeset.get(0);
String fileName = el.getValueAsString();
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 » Get SchemaLocation using JAVACompute Node
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.