0
<?xml version="1.0" encoding="UTF-8"?>
<collection>
 <movie>
    <opis title="aaa" genre="Drama" persnal_rating="7">
        <year>2013</year>
        <country>USA</country>
        <director>Ric Roman Waugh</director>
        <writers>Justin Haythe</writers>
        <actors>Dwayne Johnson</actors>
    </opis>
</movie>
</collection>


<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

        <xsd:element name="collection">
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element name="movie" type="TypMovie" maxOccurs="unbounded"/>

                        </xsd:sequence>
                </xsd:complexType>
                                </xsd:element>

                <xsd:complexType name="TypMovie">                

                <xsd:sequence>
                        <xsd:element name="year" type="xsd:string"/>
                        <xsd:element name="country" type="xsd:string"/>
                        <xsd:element name="director" type="xsd:string"/>
                        <xsd:element name="writers" type="xsd:string"/>
                                                <xsd:element name="actors" type="xsd:string"/>
                </xsd:sequence>
                                                <xsd:attribute name="title" />
                                                <xsd:attribute name="genre"   />
                                                <xsd:attribute name="persnal_rating"  />
        </xsd:complexType>


</xsd:schema>

如何添加元素“opis”?我不知道该怎么做。

4

1 回答 1

0

您可以在架构中嵌套复杂类型,如下所示:

<xs:element name = "movie">
    <xs:complexType>
        <xs:sequence>
            <xs:element name = "opis">
                <xs:complexType>
                    <xs:sequence>
                        xsd:element name="year" type="xsd:string"/>
                        <xsd:element name="country" type="xsd:string"/>
                        <xsd:element name="director" type="xsd:string"/>
                        <xsd:element name="writers" type="xsd:string"/>
                        <xsd:element name="actors" type="xsd:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

希望这会有所帮助!

于 2013-11-08T13:20:42.003 回答