现在已经为应用程序创建了联网和 XML 生成代码。CrnpClient 构造函数将调用 setupXmlProcessing 方法。此方法将创建 DocumentBuilderFactory 对象,并在该对象上设置各种解析属性。JAXP 文档详细介绍了此方法。请参见 http://java.sun.com/xml/jaxp/index.html。
创建实现上述逻辑的 Java 代码。
private void setupXmlProcessing() throws Exception { dbf = DocumentBuilderFactory.newInstance(); // We don't need to bother validating dbf.setValidating(false); dbf.setExpandEntityReferences(false); // We want to ignore comments and whitespace dbf.setIgnoringComments(true); dbf.setIgnoringElementContentWhitespace(true); // Coalesce CDATA sections into TEXT nodes. dbf.setCoalescing(true); }