Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
XML
XML Schema never-never occurence of declared elements / attributes
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Soren Kuula, post: 781991"] Hi, 1) If I have a definition + declaration like <complexType name="fattype"> <complexContent> <element name="bar" minOccurs="0" maxOccurs="342"/> </complexContent> <attribute name="shanyang"/> </complexType> <element name="foo" type="fattype"></element> and I want to make a derived-by-restriction subtype where the bar element never appears, is there ANY other way to go than: <element name="thinfoo"> <complexType><complexContent> <restriction base="fattype"> <element name="bar" maxOccurs="0"/> </complexContent> <attribute name="shanyang" use="prohibited"/> </complexType> </element> OK - my question really is: Looking at the declaration of thinfoo, I have to make a set of element names that may occur as child elements of thinfoo in any valid instance document. They don't HAVE to appear, there just must a the possibility that they do. Now there is an element in the content model of thinfoo that is declared, but never appears in an instance, and thus should not be included in my set. Can any of you guys / girls tell my whether this approach is safe: Case: E is derived by restriction, or implicitly by extension from anyType: - I traverse the whole content model of the E declaration recursively. If I encounter an element with a minOccurs="0" (actual value) attribute, then I ignore the element and its subelements. Otherwise, if the element is an element declaration and it has a name, I add the name to my set, but don't recurse. If it is an element declaration with a ref attribute, I add it to my set, too. Case: E is derived by extension (explicitly): - I traverse the declaration like above. Then, I run the same algorithm on the type that the base attribute refers to, and add the result of that to my set. -- will this get me the right set? Or are there other ways a declared element may actually never appear in an instance? And: Are there, likewise, any other way a declared attribute may never appear, than a use="prohibited" attribute on its declaration? Can anyone see any reason that I should bother to look at the base declaration in the case of a derivation by restriction? Hope there's a Schema expert out there who can help me -- and that some sort of Medal of Honar may be awarded to those who have read the entire spec with no nervous breakdowns. Soren [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
XML
XML Schema never-never occurence of declared elements / attributes
Top