Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Hello world (sample) of schemas

From: "Sam Hobbs" <samuel@------.--.---_------_------_--_----->
To: 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/
>>>
>>>
>>
>>
>>
>
>
> 





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent