问题标签 [vtd-xml]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - Remove the remaining new line after using VTD-XML to remove an element
I'm trying to remove a set of child elements from a parent element using VTD-XML.
Unfortunately after removing an element, it leaves behind the new line that the removed element previously occupied. This behaviour is also observed by a reader of an article on VTD-XML by the VTD-XML author here. I'm trying to work out how to remove this new line.
I managed to achieve a modicum of success by manipulating the length value stored in the underlying 64-bit VTD token to cover the new line character (additional 2 bytes). Code snippet is as follows:
I've tested that this works well on the old_cd.xml
provided in ex_16
of the VTD-XML Examples.
However when I try this same approach on my working file, a ModifyException
error is thrown when I attempt to call modifier.output()
, specifically it is thrown by modifier.check2()
.
Questions
1. Why would the above approach cause See Update.check2()
to fail? I don't think I'm overflowing the bits on the VTD token, file is < 2MB.
2. Is there a better approach to remove the remaining new line?
I'm still fairly new to VTD-XML so I would greatly appreciate any advice and insight and learn from more experienced users.
Thanks for your help.
Update
Wow, in the process of writing this question I realise that I forgot to consider the different character encodings and updating the adjusting long value to 1 byte fixed the check2()
problem! (another reason to take the time to pause and rethink/write out the problem).
I'd still like to know from more experienced users if there are better approaches to this.
vtd-xml - 在 VTD-XML 中,如何将新属性添加到具有现有属性的标签中?
我正在使用 VTD-XML 来更新 XML 文件。在这方面,我试图获得一种灵活的方式来维护元素的属性。因此,如果我的原始元素是:
我希望能够将其更新为:
我正在使用 Map 来管理代码中的属性/值对,当我更新 XML 时,我正在执行以下操作:
这适用于更新现有属性,但是当属性不存在时,它会命中插入(insertAttribute)并且我得到“ModifyException”
我的猜测是,由于我没有直接操作偏移量,因此这可能是意料之中的。但是,我看不到在元素中的某个位置(最后)插入属性的功能。
我的怀疑是我需要在“偏移”级别使用 xm.insertBytesAt(int offset, byte[] content) 之类的东西 - 因为这是我需要进入的领域,但有没有办法计算我可以插入的偏移量(就在标签末尾之前)?
当然,我可能在这里以某种方式误用了 VTD——如果有更好的方法来实现这一点,那么很高兴被指导。
谢谢
jasper-reports - Jasper 的 VTD-XML
有没有人使用 VTD-XML 作为 XPath 引擎?我找不到对这种组合的任何参考。
这在以下行中:JasperReports fillReport too slow and resource sumption
我应该创建使用 VTD 的 JRXpathExecutor 的自定义实现吗?
更新:一直在做一些阅读......在这个上下文中遇到了另一个问题(不想在这个问题上开始一个新的 Q):JRXpathExporter 接口期望在给定 XPath 表达式时创建一个 NodeList。使用 VTD-XML 创建 NodeList 或 Node 似乎有点迂回。我可以使用 VTD-XML 创建 NodeList 吗?我是不是该?
java - Android - XPath 评估很慢
我正在XPath
用来查询我XML-file
目前有哪些关于100KB
.
我正在迭代一个数组并查询列表中的每个值。
不幸的是,在调试器下单个查询大约需要 3-4 秒,而在禁用调试器的情况下会稍微少一些。
有什么想法为什么这么慢?我使用 aGalaxy S2
进行测试。
这是我的代码:
更新
当我省略时XPathConstants.NODESET
,评估很快就完成了,但我没有得到NodeList
. 它返回一个空字符串而不是......
java - VTD-XML:初始化对象后,它们仍然引用 null
问题是:在构造函数中初始化 VTDGen、VTDNav 或 AutoPilot 后,在其他方法中它们引用 null 并引发相应的异常。
结果是:
例外:
为什么 autoPilot 引用 null?
java - 通过 VTD-XML 将几个元素写入 XML
我想在一个父级中编写几个元素,我有以下代码:
和调用方法:
而是这个结果:
我只有这个:
看起来writeElement
每次都重写相同的元素。为什么会发生这种情况,我该如何解决?
java - Java 中的 VTD-XML - 多个“insertAfterHead”的顺序使用不起作用
我需要一次粘贴 int XML 文件中的几个元素,所以我有代码:
我按顺序多次调用此方法:
但结果是:
为什么只执行最后一次调用方法?以及如何更改代码来解决问题?
java - 从 XML 递归打印树结构在 java 中有奇怪的行为
我正在读取一个 XML 文件并重新创建结构以重新打印减去所有属性、值和文本。据我所知,它工作正常,但是当我尝试在控制台中重新打印它时,我得到了非常奇怪的行为。
我得到以下输出
最初我打印的是“\t”而不是缩进,但我注意到结构看起来不对。现在我正在摸索机器中可能存在的鬼影导致我的“缩进”变量具有两个单独的值,而没有对其进行任何更改。更不用说这些怪事在某种程度上是可以预测的。D 元素应该在 E 的左侧而不是右侧(因为它们是 E 的父级)。
有任何想法吗?
java - 为 vtd-xml 重新构建 jar 文件时,build.bat 会抛出诸如“java_cup\parser.java:695: package java_cup.runtime does not exist”之类的错误
对于几乎所有试图编译的文件,我都会遇到这样的错误。因此,没有创建任何类文件,因此 jar 不可用。
有什么建议么?
我根本没有更改 build.bat 文件,但无论如何都在这里。
所有建议的路径都在那里。
java - 如何在 VTD-XML 中以不区分大小写的模式应用 xpath
我正在使用 VTD-XML 和 java 使用 xpath 解析 XML 文件。我需要在不区分大小写的模式下应用 xpath?你能建议怎么做吗?