XSD (XML schema): Element must have one more more children -


let's have xml element this, , i'm trying write xsd element:

<foo name="bar">     ... </foo> 

the rules element are:

  • its name "foo"
  • it has attribute name "bar"
  • its "bar" attribute value string
  • it must have 1 or more children

this xsd encapsulate of rules except last:

how specify last rule—that element must have children?

use <xs:any> element allow elements child content.

example code match rules:

<xs:schema elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema">   <xs:element name="foo">     <xs:complextype>       <xs:sequence>         <xs:any minoccurs="1" maxoccurs="unbounded" />       </xs:sequence>       <xs:attribute name="bar" type="xs:string" />     </xs:complextype>   </xs:element> </xs:schema> 

you can control allowed elements , validation of foo's children using namespace , processcontents attributes <xs:any> element.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -