IBM Support

toXML() function on element containing "@" or "#"

Question & Answer


Question

How can you use toXML() function on element containing "@" or "#" to generate XML?

Cause

Using toXML() function on element containing "@" or "#" to generate XML results in CTGDIS809E handleException. This works as intended. An XML element name cannot contain either "@" or "#".

Answer

If you want to generate illegal XML anyway, you can create your own toXML() function and use it like this:

function toXML(entry) {

var XMLParser = system.getParser("ibmdi.XML2")
XMLParser.setParam("omit.xml.decl.on.writing", "true")
XMLParser.setParam("indent.output", "true")

// Allow illegal characters
XMLParser.setParam("invalid.xml.char", "true")

var sw = java.io.StringWriter()
XMLParser.setOutputStream(sw)
XMLParser.initParser()
XMLParser.writeEntry(entry)
XMLParser.closeParser()
return sw.toString()
}

[{"Product":{"code":"SSCQGF","label":"Tivoli Directory Integrator"},"Business Unit":{"code":"BU008","label":"Security"},"Component":"General","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB24","label":"Security Software"}}]

Document Information

More support for:
Tivoli Directory Integrator

Software version:
Version Independent

Document number:
534567

Modified date:
16 June 2018

UID

swg21963931