1
我與XML專門驗證是新的,我一直在問驗證XML之前,我們打個電話爲Adobe服務器生成PDF,我有以下的,我們通過對象來獲取XML然後我們打電話。任何機構可以幫助我一步一步驗證XML如果有任何元素爲null或空白,停止PDF生成XML空/空驗證
public class MyJAXBUtil {
public static String obj2Xml(Class<?> class, Object object) throws ServiceException {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
StringWriter writer = new StringWriter();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
jaxbMarshaller.marshal(object, writer);
return writer.getBuffer().toString();
} catch (JAXBException jaxbException) {
throw new ServiceException(jaxbException);
}
}