实现条件XSD中元素的最大出现取决于其元素

时间:2012-06-15 10:01:33

标签: xsd xsd-validation

我正在制作一些架构。

我的架构结构如下所示。

架构1(嵌入式架构):     它有两个领域:         1.select:Drop Down允许两个值“标题”和“标题”         2.text

架构2:    它有以下字段;

    1.First--of Type Schema 1: As a field. Max occurrence is 4

主模式的源代码如下:

    <xsd:schema elementFormDefault="qualified" xmlns:tcmi="http://www.tridion.com/ContentManager/5.0/Instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:import namespace="http://www.tridion.com/ContentManager/5.0/Instance"></xsd:import>
    <xsd:annotation>
        <xsd:appinfo>
            <tcm:Labels xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
                <tcm:Label ElementName="select" Metadata="false">select</tcm:Label>
                <tcm:Label ElementName="text" Metadata="false">text</tcm:Label>
            </tcm:Labels>
        </xsd:appinfo>
    </xsd:annotation>
    <xsd:complexType name="Content">
        <xsd:sequence>
            <xsd:element name="select" minOccurs="0" maxOccurs="1">
                <xsd:annotation>
                    <xsd:appinfo>
                        <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
                        <tcm:Size xmlns:tcm="http://www.tridion.com/ContentManager/5.0">1</tcm:Size>
                        <tcm:listtype xmlns:tcm="http://www.tridion.com/ContentManager/5.0">select</tcm:listtype>
                    </xsd:appinfo>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:restriction base="xsd:normalizedString">
                        <xsd:enumeration value="Heading"></xsd:enumeration>
                        <xsd:enumeration value="Title"></xsd:enumeration>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="text" minOccurs="1" maxOccurs="1" type="tcmi:MultiLineText">
                <xsd:annotation>
                    <xsd:appinfo>
                        <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
                        <tcm:Size xmlns:tcm="http://www.tridion.com/ContentManager/5.0">2</tcm:Size>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

此架构在主架构中称为“Field” - First

    <xsd:schema elementFormDefault="qualified" targetNamespace="some name space" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="some name space" xmlns:tcmi="http://www.tridion.com/ContentManager/5.0/Instance">
                    <xsd:import namespace="http://www.tridion.com/ContentManager/5.0/Instance" schemaLocation="location.xsd"></xsd:import>
                    <xsd:include schemaLocation="Schema 1 location"></xsd:include>
                    <xsd:annotation>
                        <xsd:appinfo>
                            <tcm:Labels xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
                                <tcm:Label ElementName="First" Metadata="false">First</tcm:Label>
                            </tcm:Labels>
                        </xsd:appinfo>
                    </xsd:annotation>
                    <xsd:element name="Content">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name="First" minOccurs="1" maxOccurs="4" type="Content">
                                    <xsd:annotation>
                                        <xsd:appinfo>
                                            <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
                                            <tcm:EmbeddedSchema xlink:href="Schema 1 location" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xlink:title="abcd"></tcm:EmbeddedSchema>
                                        </xsd:appinfo>
                                    </xsd:annotation>
                                </xsd:element>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:schema>

字段“First”跟随Schema 1.所以反过来它有2个字段。 我的需要是否为“第一”字段的出现是4.我还想再应用一个条件。

条件:

    1.No Of occurrence of the "First" is 4.
    2. As Schema 1 has drop down to select values "Heading" and "Title".
        I want to restrict that out of 4 occurrence of "First", 
        Heading can occur Maximum  2 times and Title can occur maximum of 2 two times.

任何人都可以帮助如何实现这一目标。

0 个答案:

没有答案