0

これらの子要素のいずれかを任意の順序で配置しようとしています。ただし、追加の要素も考慮に入れたいと思います。選択リストに定義されていない新しい要素を追加すると、「要素は要素の下で許可されていません」という検証エラーが発生します。

<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://www.w3.org/2005/Atom" elementFormDefault="qualified" 
    attributeFormDefault="unqualified"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:annotation>
        <xsd:documentation>
                This version of the Atom schema is based on version 1.0 of the format specifications,
                found here http://www.atomenabled.org/developers/syndication/atom-format-spec.php.
            </xsd:documentation>
    </xsd:annotation>
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd" />
    <xsd:annotation>
        <xsd:documentation>
            An Atom document may have two root elements, feed and entry, as defined in section 2.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:element name="feed" type="atom:feedType"/>
    <xsd:element name="entry" type="atom:entryType"/>

..。

<xsd:complexType name="feedType">
        <xsd:annotation>
            <xsd:documentation>
                The Atom feed construct is defined in section 4.1.1 of the format spec.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice minOccurs="3" maxOccurs="unbounded">
            <xsd:element name="author" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="category" type="atom:categoryType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="contributor" type="atom:personType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="generator" type="atom:generatorType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="icon" type="atom:iconType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="id" type="atom:idType" minOccurs="1" maxOccurs="1" />
            <xsd:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="logo" type="atom:logoType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="rights" type="atom:textType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="subtitle" type="atom:textType" minOccurs="0" maxOccurs="1" />
            <xsd:element name="title" type="atom:textType" minOccurs="1" maxOccurs="1" />
            <xsd:element name="updated" type="atom:dateTimeType" minOccurs="1" maxOccurs="1" />
            <xsd:element name="entry" type="atom:entryType" minOccurs="0" maxOccurs="unbounded" />
            <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:choice>
        <xsd:attributeGroup ref="atom:commonAttributes"/>
    </xsd:complexType> 
4

1 に答える 1

1

<xsd:any>デフォルトでは、ドキュメントに古いガフを入れることはできません。それでも、パーサーはその要素のスキーマを持っている必要があり、そのスキーマに対して検証する必要があります。

その要素の検証を無効にする場合は、を使用しますprocessContents="skip"

<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>

MSDNprocessContentsには適切な説明があり、侵入不可能なXMLスキーマ仕様よりもはるかに明確です。

于 2012-05-15T17:33:20.477 に答える