gpt4 book ai didi

java - Eclipse RCP 中的 XML 验证

转载 作者:行者123 更新时间:2023-12-01 04:47:38 24 4
gpt4 key购买 nike

我正在构建一个 Eclipse 插件,我需要在其中“即时”验证 XML 文件。

我创建了一个新的内容类型,以 org.eclipse.core.runtime.xml 作为基本类型,并创建了一个扩展 org.eclipse.wst.sse.ui.StructuredTextEditor 的新编辑器对于此内容类型。我还为 org.eclipse.wst.validation.validatorV2 做出了贡献,以使用 org.eclipse.wst.xml.core.internal.validation.eclipse.Validator 创建 validator > 验证我的 XML 文件。

这是我的plugin.xml

<plugin>  
<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
file-extensions="example"
id="com.example.editor.content.example"
name="Example Files"
priority="normal">
</content-type>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="com.example.editor.ExampleEditor"
id="com.example.editor.example"
name="Example editor">
<contentTypeBinding
contentTypeId="com.example.editor.content.example">
</contentTypeBinding>
</editor>
</extension>
<extension
id="com.example.validator.ExampleValidator"
name="Example validator"
point="org.eclipse.wst.validation.validatorV2">
<validator
build="true"
class="org.eclipse.wst.xml.core.internal.validation.eclipse.Validator"
manual="true">
<include>
<rules>
<contentType
id="com.example.editor.content.example">
</contentType>
</rules>
</include>
</validator>
</extension>
</plugin>

手动验证(右键单击 -> 验证)有效,但文件未“即时”验证(即在用户键入或保存文件时)。

有没有办法在每次保存文件时验证文件以显示可能的错误?

最佳答案

我不久前确实注意到了这个错误。此 org.eclipse.wst.sse.ui.StructuredTextEditor 编辑器无法包含对编辑器的验证。您是否尝试过扩展内置 XML 编辑器?我想这是可能的,因为在扩展 XML 编辑器的内容类型之后,我不想为我的扩展扩展编辑器。它会自动验证编辑器。

关于java - Eclipse RCP 中的 XML 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15572057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com