简体   繁体   English

如何使用ant验证针对Schema的XML文件?

[英]How do I validate an XML file against a Schema using ant?

As part of my build process I want to validate XML files against a Schema (XSD). 作为构建过程的一部分,我想根据Schema(XSD)验证XML文件。 I'm trying to use the schemavalidate task like this: 我正在尝试使用schemavalidate任务,如下所示:

<schemavalidate noNamespaceFile="schemas/Model.xsd" file="Model.xml"/>

This yields the following error: 这会产生以下错误:

[...]
BUILD FAILED
build.xml:65: The following error occurred while executing this line:
build.xml:59: Parser does not support Xerces or JAXP schema features

I'm using the latest ant distribution (1.7.1). 我正在使用最新的蚂蚁发行版(1.7.1)。 Are any additional libraries needed to get validation to work? 是否需要任何其他库才能使验证工作?

The schemavalidate task is actually working as shown in the question. schemavalidate任务实际上正如问题中所示那样工作。

The problem was that the xsd file was not present. 问题是xsd文件不存在。 Unfortunately, the error message is rather confusing. 不幸的是,错误消息相当混乱。 Ant only complains about the missing file when it is started in verbose mode. Ant只会在详细模式下启动时抱怨丢失的文件。

I'm closing this question. 我正在结束这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM