XmlWithSchemaMapper tMapper = new XmlWithSchemaMapper(tSchemaLocation, "KB.community");
// Test 1: buildXmlWithSchema
System.out.println("buildXmlWithSchema:\n-------------------");
RequestUrl tParams = new HttpParams();
tParams.addParam("KB.community.membershipPolicy", "restricted");
tParams.addParam("KB.community.communication", "FaceToFace");
tParams.addParam("KB.community.contact.name", "Hans");
//tParams.addParam("KB.community.contact.email", "a@siemens.com");
tParams.addParam("KB.community.contact.email", "a@siemens.com");
tParams.addParam("KB.community.sponsor$1.name", "ICM");
tParams.addParam("KB.community.sponsor$1.url", "http://www.icm.de");
tParams.addParam("KB.community.sponsor$2.name", "CIO");
tParams.addParam("KB.community.sponsor$2.url", "http://www.cio.com");
tParams.addParam("KB.community.hasSubCoPs$1", "subCoP1");
tParams.addParam("KB.community.hasSubCoPs$2", "subCoP2");
tParams.addParam("KB.community.hasSubCoPs$3", "subCoP3");
tParams.addParam("KB.community.since", "20x02-12-02");
Document tGenDoc = tMapper.buildXmlWithSchema(tParams, true /*complete*/, false /*CDATA as text*/);
System.out.println(DOM.serializeToString(tGenDoc, "ISO-8859-1"));
KFMSystem.log.setLogLevel(KFMLog.DEBUG_LEVEL);
XmlValidator tValidator = new XmlValidator(KFMSystem.log);
tValidator.reparseDom(tGenDoc, "KB.community");
// Test 2: serializeToHttpParams
System.out.println("\n\nserializeToHttpParams:\n----------------------");
String tXmlFile = "O:/KFM/www-docs/public/Portal/SieMap/DTD/KB_Community.xml";
Document tXmlDoc = DOM.parseToDOM(new File(tXmlFile), true);
HttpParams tParamsGen = (HttpParams)tMapper.serializeToHttpParams(
tXmlDoc,
"KnowledgeBean");
Enumeration tParamNames = tParamsGen.getParameterNames();
String tName = null;
while (tParamNames.hasMoreElements()) {
tName = (String)tParamNames.nextElement();
System.out.println(tName + " = " + tParamsGen.getParam(tName));
}
}