[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: help - Writing schema

writing xml schema
Hi Pradeep,

> I need to write XML schema for the following XML

It's best to direct questions about XML Schema to xmlschema-dev@w...
rather than XML-Dev.

>    <Attribute>
>          <AttributeName>
>                   <id />
>          </AttributeName>
>          <TagName>
>            <emp/>
>          </TagName>
>    </Attribute>
> The element under AttributeName and TagName is unknown but it should
> contain only one element.
> The tags AttributeName and TagName  should not be empty.

To indicate an 'unknown' element, you need to use the wildcard xs:any.
xs:any takes minOccurs and maxOccurs attributes to indicate how many
unknown elements should occur; in your case, you just want one and
only one unknown element, so you can leave those to default (they both
default to 1).

xs:any also takes a namespace attribute to indicate which namespaces
the element(s) can belong to. If you want to allow elements in any
namespace, you can use the keyword '##any'; again, that's the default,
so you don't have to add a namespace attribute to allow any element in
any namespace.

Finally, xs:any takes a processContents attribute to indicate what
should be done about validating the 'unknown' element. Probably in
this case you should just skip them or use lax validation (whereby
they're validated if they're declared, and not if they aren't). The
default is 'strict' (it's an error if the elements aren't declared),
so probably you should change that.

So a complex type that allows a single unknown element would be:

<xs:complexType name="unknownElement">
    <xs:any processContents="lax" />

The Attribute element contains an AttributeName element followed by a
TagName element, both of which are of the type 'unknownElement':

<xs:element name="Attribute">
      <xs:element name="AttributeName" type="unknownElement" />
      <xs:element name="TagName" type="unknownElement" />



Jeni Tennison


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.