Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   XSD syntax for declaring an element that cannot have a child elementor other content (http://www.velocityreviews.com/forums/t945123-xsd-syntax-for-declaring-an-element-that-cannot-have-a-child-elementor-other-content.html)

Olumide 04-04-2012 05:31 PM

XSD syntax for declaring an element that cannot have a child elementor other content
 
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 04-05-2012 10:22 AM

Re: XSD syntax for declaring an element that cannot have a childelement or other content
 
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/


All times are GMT. The time now is 04:42 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57