Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSD syntax for declaring an element that cannot have a child elementor other content

Reply
Thread Tools

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

 
 
Olumide
Guest
Posts: n/a
 
      04-04-2012
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>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-05-2012
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 xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/>


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
How to prevent duplicate child element definitions in the XSD johkar XML 0 12-16-2009 07:14 PM
XPath expression for element based on content of other element withsame parent Ian Wilson XML 2 07-26-2007 04:11 PM
xsd:any as a child of xsd:all Peter Aberline XML 0 04-05-2004 03:38 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments