Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Hello world (sample) of schemas [Thread Next] Re: Hello world (sample) of schemasTo: NULL Date: 3/3/2008 8:44:00 PM So I have the following, which validates. This is close enough to what I was thinking of. Other people will have other opinions and I can respect many alternatives. It is myopinion that it helps to start a schema tutorial with a sample such as this. I assume tutorial authors will have their own version. I added a noNamespaceSchemaLocation. It is not clear to me what the difference is between that and SchemaLocation, but I have not made enough effort to figure that out so I am not asking for an explanation. Schema ============ <?xml version = "1.0"?> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"> <xsd:element name = "item" /> </xsd:schema> Document ============ <?xml version = "1.0"?> <item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HelloWorld.xsd" > Hello World!!! </item> "Mike C#" <xyz@x...> wrote in message news:e9pMj9zeIHA.4696@T...... > As mentioned, the XML document below is valid against the XML schema I > provided on SQL 2005, and should validate with any XML Schema processor. > > "Sam Hobbs" <samuel@s...> wrote in message > news:O6vBEXjeIHA.4140@T...... >> Yes, that is a good Hello World document. Does the sample schema work for >> that document? If not, then what would the schma be for it? >> >> >> "Mike C#" <xyz@x...> wrote in message >> news:OYNGddaeIHA.5164@T...... >>> BTW, in SQL Server (which may not be accurate in their implementation of >>> this particular feature), the XML Schema does not allow complex content >>> in the item element. On SQL 2005 the example XML doc. fails validation >>> at the foo element. However, an XML document like this is valid on SQL >>> 2005: >>> >>> <?xml version = "1.0"?> >>> <item>Hello World!!!</item> >>> >>> <usenet@t...> wrote in message >>> news:39f2ba8e-8b82-4bd2-8325-22f3a8bf8050@p...... >>> On 26 Feb, 06:22, "Mike C#" <x...@xyz.com> wrote: >>>> >>>> XML Schema >>>> ============ >>>> <?xml version = "1.0"?> >>>> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"> >>>> <xsd:element name = "item" /> >>>> </xsd:schema> >>>> >>>> Valid document >>>> ============ >>>> <?xml version = "1.0"?> >>>> <item /> >>>> >>>> See what I mean about it being fairly uninteresting? >>> >>> Although note that in this case the valid XML instance can be much >>> more interesting :-) >>> >>> I mention it because it's quite easy to assume that the schema >>> declares an empty element and so might mislead some beginners looking >>> at this post. In fact the default type for an element declaration is >>> xs:anyType. So the following is also a valid XML instance: >>> >>> <item><foo bar="a"><e1>hg></e1></foo><bar/></item> >>> >>> and, of course so, are many others. >>> >>> There's a couple of idioms to specify empty elements. The only I >>> prefer is an empty compleType, along the lines of: >>> >>> <xs:element name='item'> >>> <xs:complexType/> >>> </xs:element> >>> >>> HTH, >>> >>> Pete Cordell >>> Codalogic >>> For XML C++ data binding visit http://www.codalogic.com/lmx/ >>> >>> >> >> >> > > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
