Java:VTD-XML 2.10:如何:在不知道名称空间的情况下获取属性 val?

发布于 2024-11-15 01:30:30 字数 917 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与君绝 2024-11-22 01:30:30

您将需要使用扩展的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文