我是专门使用 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);
}
}