Hi all,
I have created a component with differents functions to return a string variable that contains a portion or a full xml, wich will be binded to a xdp form.
When I try to inject the xml, using deserialize(string), is full of < > and other caracters and I can get the binding well inside the form when I render in workspace.
What should I do this to get this work?
Here is one funcion I have in my component, wich get some data from a database and then construct a DOM XML document and converted to a string...
public java.lang.String getConvenios(int region){
try
{
Class.forName("XXXXXXXXXXXXXXXX");
Connection dbConnection = DriverManager.getConnection("XXXXXXXXXXX",user, password);
PreparedStatement sqlStatement;
DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
//get an instance of builder
DocumentBuilder db = dbf.newDocumentBuilder();
//create an instance of DOM
Document dom = db.newDocument();
Element root=dom.createElement("process");
dom.appendChild(root);
Element fechaActual=dom.createElement("date1");
raiz.appendChild(date1);
Element cblist=dom.createElement("cblist");
raiz.appendChild(cblist);
Text textVar;
//cb will be mapped to a drop down list
Element conSelec=dom.createElement("conSelec");
cblist.appendChild(conSelec);
String query="XXXXXXXXXXX";
sqlStatement= dbConnection.prepareStatement(query);
ResultSet rs = sqlStatement.executeQuery();
while(rs.next())
{
Element item=dom.createElement("item");
convenioSeleccionado.appendChild(item);
Element nameCon=dom.createElement("nameCon");
item.appendChild(nameCon);
textVar=dom.createTextNode("Con N°: "+rs.getInt(1)+" - "+rs.getString(2));
nombreConvenio.appendChild(texto);
Element idCon=dom.createElement("idCon");
item.appendChild(idConvenio);
textVar=dom.createTextNode(""+rs.getInt(1));
idConvenio.appendChild(texto);
}
if(!sqlStatement.isClosed())
sqlStatement.close();
if(!dbConnection.isClosed())
dbConnection.close();
/////////////////
//Output the XML
//set up a transformer
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(dom);
trans.transform(source, result);
String xmlString = sw.toString();
return xmlString;
}
catch(Exception e)
{
return "ERROR: "+e.getMessage();
}
}
Any help will be appretiated...
Views
Replies
Total Likes
Since you have constructed an
org.w3c.dom.document object, you may directly return the document object (rather than transforming it into String).
This document object can then be used within your process with simple coercion org.w3c.dom.document -> com.adobe.idp.document
Try this option and let me know the result.
Nith
Views
Replies
Total Likes