开发者

Validating XMLs with "free" elements using XML Schemas

Is there a way to define an XML schema that allows elements not defined in the schema? I have an XML file that needs validation only on part of the file. like so:

<?xml version="1.0"?>
<xml>
    <ValidatedElement type="PositiveInteger">123</ValidatedElement>
    <OtherStuff>
        <MemoryUsed type="PositiveInteger">356</MemoryUsed>
        <MemoryLeft type="PositiveInteger">44</MemoryLeft>
    </OtherStuff>
</xml>

开发者_高级运维I'd like to schema-validate only certain elements (regardless of position in the XML. If hierarchy could also be ignored - even better)


Using the <any> directive, you can define spots where any content is allowed. If you want to validate elements that can exist in arbitrary positions in a tree of otherwise unvalidated content, you'ld have to look them up and arrange for them to be individually validated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜