Re: Allowing any sub-element while requiring one particular sub-element

Hi Tom,

> I am building an XML Schema and I would like one of the elements to
> allow any sub-elements of any type (I won't know what they are) and
> require that there is one particular sub-element.  The schema and sample
> XML is included below.  The element 'Recipient' is the one that I want
> to allow any number of sub elements (such as 'FirstName'), but require
> the 'email' element be there.

Have you tried using xsd:any?
xsd:any let you have any Well-Formed XML and you can specify if you want the
processor to validate the content and from which namespace the elements can
be declared in. Have a look at [1] for more details.

In your schema you could declare your element Recipient like:

<xsd:element name="Recipient">
         <xsd:element name="email" type="xsd:string"/>
         <xsd:any processContents="skip" namespace="##any" minOccurs="0"



Received on Wednesday, 13 June 2001 19:52:00 UTC