XML 验证 - 已知和未知属性可选? [英] XML validation - known and unknown attributes optional?

查看:22
本文介绍了XML 验证 - 已知和未知属性可选?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我是否可行,如果可能,请告诉我.如何在 xsd 中声明,我的 xml 中的所有属性都是可选的.我无法声明所有属性,因为我的 xml 具有不同数量的属性,包括已知和未知.

please tell me whether it is possible and, if possible. How to declare in the xsd, that all attributes in my xml are optional. I cannot declare all attributes, because my xml has different number of attributes, both known and unknown.

        schema = factory.newSchema(new StreamSource(xsdFileInputStream));
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(new StringReader(xmlString)));

谢谢.

推荐答案

我找到了解决方案!

<xs:anyAttribute processContents="skip"/>

这篇关于XML 验证 - 已知和未知属性可选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆