Java eclipsercp中的XML验证

Java eclipsercp中的XML验证,java,eclipse-plugin,eclipse-rcp,Java,Eclipse Plugin,Eclipse Rcp,我正在构建一个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.valida

我正在构建一个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创建了一个验证器来验证我的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编辑器的内容类型之后,我没有为扩展扩展扩展编辑器。
它会自动验证编辑器。

谢谢您的回答。我决定尝试扩展一个新的XML编辑器。我选择扩展Rinzo XML编辑器,它完成了这项工作。