Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XSD syntax for declaring an element that cannot have a child element or other content

2 views
Skip to first unread message

Olumide

unread,
Apr 4, 2012, 1:31:33 PM4/4/12
to
Would this be the proper method of declaring an XML element Foo that
cannot have a child element or other content?

<xs:element name="Image" type="xs:string" fixed="" nillable="true" />

The valid uses of this element in an XML document would be:

<Foo></Foo>
<Foo />

Anything else would be invalid, e.g.:

<Foo>stuff</Foo>

Thanks,

- Olumide


PS:
Its just occurred to me that

<Foo>
</Foo>

might be invalid also because of the newline character and other
whitespace characters that appear between the <Foo> and </Foo>

Martin Honnen

unread,
Apr 5, 2012, 6:22:02 AM4/5/12
to
Olumide wrote:
> Would this be the proper method of declaring an XML element Foo that
> cannot have a child element or other content?
>
> <xs:element name="Image" type="xs:string" fixed="" nillable="true" />
>
> The valid uses of this element in an XML document would be:
>
> <Foo></Foo>
> <Foo />
>
> Anything else would be invalid, e.g.:
>
> <Foo>stuff</Foo>

Well if you put 'nillable="true"' on the element then valid markup also is
<Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/>


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
0 new messages