Author |
Message
|
blackwhites |
Posted: Thu May 21, 2009 6:27 am Post subject: want to use java computer node to generate the xml problem |
|
|
Novice
Joined: 23 Jan 2009 Posts: 10
|
I want to the following requirement,through the java compute node to generate the following xml to the output
<?xml version="1.0" standalone="no" ?>
<abc>
<a></a>
...
<c></c>
</abc>
<abc>
<a></a>
...
<c></c>
</abc>
it is a String I get from the xml .The following is my code
String outputValue="<abc><a>...</abc> ;
outputBody.createElementAsLastChildFromBitstream(outputValue
.getBytes(), MbXML.PARSER_NAME, "", "", "", 0, 0, 0);
My question is how to add
<?xml version="1.0" standalone="no" ?> to the outAssembly?Can anyone provide some sample code? |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Thu May 21, 2009 7:03 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Why the desire to do this in Java? on the face of it, ESQL will be a much better choice. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Thu May 21, 2009 7:11 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
|
Back to top |
|
 |
kimbert |
Posted: Thu May 21, 2009 11:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
blackwhites |
Posted: Thu May 21, 2009 9:11 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2009 Posts: 10
|
now I can add the <?xml version="1.0" standalone="no" ?> to the output. I am using XMLNSC.But the problem the output is add things like
<?xml version="1.0" standalone="no" ?>
<XMLNSC>
<abc>
<a></a>
...
<c></c>
</abc>
<XMLNSC>
I just want to remove XMLNSC from it.
public void evaluate(MbMessageAssembly assembly, MbInputTerminal in)
throws MbException {
MbMessage inMessage = assembly.getMessage();
MbMessage outMessage = new MbMessage();
// message
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
outMessage);
MbElement inputRoot = inMessage.getRootElement();
MbElement inputBody = inputRoot.getLastChild();
MbElement outputRoot = outMessage.getRootElement();
MbElement outputBody = outputRoot
.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement xmlDecl = outputBody.createElementAsFirstChild(MbXMLNSC.XML_DECLARATION);
xmlDecl.setName("XmlDeclaration");
xmlDecl.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "version", "1.0");
xmlDecl.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "standalone", "yes");
StringBuffer outputsb = new StringBuffer("");
outputBody.append("<abc><a>asas</a></abc>);
outputBody.createElementAsLastChildFromBitstream(outputValue
.getBytes(),MbXMLNSC.PARSER_NAME, "", "", "", 0, 0, 0);
}
} catch (Exception e) {
logErrorGenerateException(this, Constants.METHODNAME,
JRulesComputeNodeMessages.MESSAGE_SOURCE,
JRulesComputeNodeMessages.NO_OUTPUT, "OutPut",
new String[] { outputsb.toString() });
return;
}
// }
getOutputTerminal("Out").propagate(outAssembly);
}
Can anyone help me to reslove this problem? |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 22, 2009 9:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Looks to me like you have a lot to learn...
Get a course on Message Broker. This is not something you can learn just by dreaming about it.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
MQEnthu |
Posted: Sun May 24, 2009 9:52 pm Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 25, 2009 4:23 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
MQEnthu wrote: |
Create the required XML elements using createElement.. method. |
Of course the code is already doing that.
Three times. At least one of which is unnecessary and directly causing the undesired (but correct for the code) result. |
|
Back to top |
|
 |
MQEnthu |
Posted: Mon May 25, 2009 5:09 am Post subject: |
|
|
 Partisan
Joined: 06 Oct 2008 Posts: 329 Location: India
|
mqjeff wrote: |
Of course the code is already doing that. |
Sorry .. may be I was not clear ealrier..
I meant say to create the XML tags <abc>, <a>... as he has described _________________ -----------------------------------------------
It is good to remember the past,
but don't let past capture your future |
|
Back to top |
|
 |
|