- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 31 Jan 2001 17:00:31 +0000
- To: Satya Podury <satya@perfect.com>
- Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Satya Podury <satya@perfect.com> writes:
> I am relatively new to XMl, and have spent a few days surfing various sites
> on how to link .xsd files to .xml files, but have not seen any resolution to
> my case. Any help will be deeeply appreciated!
>
> I am working on an NT box. My pers.xsd and pers.xml files are in C:\dir1
>
> The pers.xsd file looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
>
> <element name="personnel">
> <complexType>
> <element ref="person" minOccurs='1' maxOccurs='unbounded'/>
> </complexType>
> </element>
>
> <element name="person">
> <complexType>
> <element ref="name"/>
> <element ref="email" minOccurs='0' maxOccurs='unbounded'/>
> <element ref="url" minOccurs='0' maxOccurs='unbounded'/>
> <element ref="link" minOccurs='0' maxOccurs='1'/>
>
> <attribute name="id" type="ID" use='required'/>
> ....
>
>
> While my pers.xml file looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <personnel xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation='pers.xsd'>
>
> <person id="Big.Boss" >
> <name><family>Boss</family> <given>Big Shot</given></name>
> <email1>This element should fail validation...chief@foo.com</email1>
> <email>chief@foo.com</email>
> <link subordinates="one.worker two.worker three.worker four.worker
> five.worker"/>
> </person>
>
> ...
>
> I am using sax parser to validate the above pers.xml with the corrsponding
> pers.xsd file located in the same directory. I am not running any webserver
> on my machine.
>
> The questions I have is:
>
> 1. What is the syntax in the pers.xml file to refer to the pers.xsd schema
> file? Do I have to use namespaces?
Your files above are nearly correct -- you've got a mistake in the xsi
namespace declaration, should be http://www.w3.org/2000/10/XMLSchema-instance.
> 2. I am expecting the pers.xml file to fail validation as the element
> "email1" has not been defined in the pers.xsd schema file.
> Given that I do not have any webserver access, how can I check if my
> pers.xml file is being validated?
<snip/>
A list of XML Schema validators is available on the XML Schema home
page [1].
ht
[1] http://www.w3.org/XML/Schema.html
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
W3C Fellow 1999--2001, part-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
Received on Wednesday, 31 January 2001 12:00:33 UTC