Java:VTD-XML 2.10:如何:在不知道名称空间的情况下获取属性 val?
我正在使用 VTD-XML 来合并大于 800MB 的 xml 文件 文件大小(很有可能达到2GB)。 我已经阅读了可以支持 2GB 的文档(如果命名空间感知是) 设置为假。 话虽如此,我如何正确使用 selecXPath() evalXPath() 和 getAttrVal() 等..? 因为我收到命名空间错误,但如果我可以正常运行 切换到名称空间感知 true。
VTDNav gmlNav = null;
//if(! gen.parseFile(gmlFile, true)) return;
if(! gen.parseFile(gmlFile, false)) return;
gmlNav = gen.getNav();
AutoPilot gmlAutoPilot = new AutoPilot(gmlNav);
//gmlAutoPilot.declareXPathNameSpace("xlink","http://www.w3.org/1999/xlink");
//gmlAutoPilot.declareXPathNameSpace("gml","http://www.opengis.net/gml/3.2");
//sourceAutoPilot.selectXPath("//*[gml:id='123' or gml:id='456']");
sourceAutoPilot.selectXPath("//*[id='123' or id='456']");
while (sourceAutoPilot.evalXPath() != -1) {
//String gmlId = sourceNav.toString(sourceNav.getAttrVal("gml:id"));
String gmlId = sourceNav.toString(sourceNav.getAttrVal("id"));
}
注意:注释的代码是命名空间感知的真实代码。
任何指导表示赞赏。
I am using VTD-XML to merge my xml files which have greater than 800MB
file size (high possibility to reach 2GB).
I've read the documentation that can support 2GB if namespace aware is
set to false.
With that said, how can I use properly the selecXPath() evalXPath() and
getAttrVal() etc.. ?
Because I am receiving a namespace error but can run properly if I
switch to namespace aware true.
VTDNav gmlNav = null;
//if(! gen.parseFile(gmlFile, true)) return;
if(! gen.parseFile(gmlFile, false)) return;
gmlNav = gen.getNav();
AutoPilot gmlAutoPilot = new AutoPilot(gmlNav);
//gmlAutoPilot.declareXPathNameSpace("xlink","http://www.w3.org/1999/xlink");
//gmlAutoPilot.declareXPathNameSpace("gml","http://www.opengis.net/gml/3.2");
//sourceAutoPilot.selectXPath("//*[gml:id='123' or gml:id='456']");
sourceAutoPilot.selectXPath("//*[id='123' or id='456']");
while (sourceAutoPilot.evalXPath() != -1) {
//String gmlId = sourceNav.toString(sourceNav.getAttrVal("gml:id"));
String gmlId = sourceNav.toString(sourceNav.getAttrVal("id"));
}
note:the commented codes are the namespace aware true.
Any guidance is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要使用扩展的 VTD-XML,它在命名空间方面没有标准 vtd-xml 的限制。在标准vtd-xml中,如果启用命名空间感知,则最大文档大小为1GB。
You will need to use extended VTD-XML which doesn't have the limitation of the standard vtd-xml in terms of namespace. In standard vtd-xml, if the namespace awareness is turned on, the maximum document size is 1GB.