Axiom一直将巨大的CDATA块分成几个CDATA块

时间:2015-11-19 09:23:15

标签: java w3c cdata axiom

我遇到了以下问题我需要通过SOAP服务向一个巨大的CDATA块发送XML消息。当AXIOM执行处理参数时,它一直将一个大的CDATA块分成像这样的较小块

我如何解决这个问题?

try {
   String str = ""; // string which contains xml

   java.io.StringReader stringReader = new java.io.StringReader(str);
   javax.xml.stream.XMLInputFactory inputFactory = javax.xml.stream.XMLInputFactory.newInstance();
   inputFactory.setProperty(javax.xml.stream.XMLInputFactory.IS_COALESCING, false);   
   javax.xml.stream.XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stringReader);      
   org.apache.axiom.om.impl.builder.StAXOMBuilder builder =
                                  new org.apache.axiom.om.impl.builder.StAXOMBuilder(streamReader);



       System.out.println("xml = " + builder.getDocumentElement());                                           
} catch (XMLStreamException e) {               
    e.printStackTrace();

处理测试XML后:

<ns1:customerData><![CDATA[<Root><Project><UserList><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User><User> <ProjectTableID></ProjectTableID> <UserTableID></UserTableID> <OrgLevelName></OrgLevelName> <UserID></UserID> <UserType></UserType> <ShortName> </ShortName> <UserFullName></UserFullName> <UserEmail></UserEmail> <UserPhone></UserPhone> <UserPosition></UserPosition> <IsTerrBank></IsTerrBank> <UnitPostAddress></UnitPostAddress> <UnitPostIndex></UnitPostIndex> </User></UserList></Project></Root>]]></ns1:customerData>

将是

<ns1:customerData><![CDATA[....previous xml piece....]]><![CDATA[....previous xml piece....]]></ns1:customerData>

1 个答案:

答案 0 :(得分:0)

假设您使用Woodstox作为StAX实现,您可以尝试配置以下属性:

inputFactory.setProperty("com.ctc.wstx.minTextSegment", 
                         Integer.valueOf(Integer.MAX_VALUE));