So basically I want class A to have a sequence of options (Day, Week for example) then I want B to inherit from A and have all of A's options and an additional 2 or 3 options like hours, seconds.推荐答案这是我想出的架构:<?xml version="1.0" encoding="utf-8"?><xs:schema id="inheritance" targetNamespace="http://test.com" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:test="http://test.com"> <xs:element name="Time"> <xs:complexType> <xs:sequence> <xs:element name="First" type="test:A" /> <xs:element name="Second" type="test:B" /> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="shortOptions"> <xs:sequence> <xs:element name="Day" /> </xs:sequence> </xs:complexType> <xs:complexType name="longOptions"> <xs:complexContent> <xs:extension base="test:shortOptions"> <xs:sequence> <xs:element name="Week" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="A"> <xs:sequence> <xs:element name="options" type="test:shortOptions" /> </xs:sequence> </xs:complexType> <xs:complexType name="B"> <xs:sequence> <xs:element name="options" type="test:longOptions" /> </xs:sequence> </xs:complexType></xs:schema>这似乎适合这个xml:Which seems to fit this xml:<?xml version="1.0" encoding="utf-8" ?><Time xmlns="http://test.com"> <First> <options> <Day>Today</Day> </options> </First> <Second> <options> <Day>Tomorrow</Day> <Week>This Week</Week> </options> </Second></Time> 这篇关于Xsd 和继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 23:52