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

O

Olumide

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>
 
M

Martin Honnen

Olumide said:
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"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top