*/
private void marshal(IMarshallingContext ctx) throws JiBXException {
if (marshallerIndex < 0) {
((IMarshallable)dataObject).marshal(ctx);
} else {
IXMLWriter wrtr = ctx.getXmlWriter();
int nsidx = 0;
boolean nsfound = true;
if (!"".equals(elementNamespaceUri)) {
nsfound = false;
for (nsidx = wrtr.getNamespaceCount()-1; nsidx > 1; nsidx--) {
if (elementNamespaceUri.equals(wrtr.getNamespaceUri(nsidx))) {
nsfound = true;
break;
}
}
}
try {
if (nsfound) {
wrtr.startTagOpen(nsidx, elementName);
} else {
nsidx = wrtr.getNamespaceCount();
String[] uris = new String[] { elementNamespaceUri };
int[] indexes = new int[] { nsidx };
String[] prefixes = new String[] { "" };
wrtr.pushExtensionNamespaces(uris);
wrtr.startTagNamespaces(nsidx, elementName, indexes, prefixes);
}
IMarshaller mrsh = ctx.getMarshaller(marshallerIndex,
bindingFactory.getMappedClasses()[marshallerIndex]);
mrsh.marshal(dataObject, ctx);
wrtr.endTag(nsidx, elementName);
if (!nsfound) {
wrtr.popExtensionNamespaces();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}