Evgenij Reznik
Evgenij Reznik

Reputation: 18614

XML Schema doesn't work

I want to link an XML Schema with an XML file. I followed this example: XSD How To.

The note.xml looks like:

<?xml version="1.0"?>

<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note> 

And the note.xsd looks like:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema> 

But when I open the note.xml, it just looks like a regular XML in my browser, with the description: This XML file does not appear to have any style information associated with it. The document tree is shown below.
These files are both in the same directory.

Upvotes: 0

Views: 985

Answers (2)

Prabhakar Singh
Prabhakar Singh

Reputation: 19

a XSD(schema) only serves the validation purpose for any xml...whereas a XSLT is used to serve the styling purpose for a XML -wch is simply absent in ur xml so how could you expect any styling in your browser when you are running this XML file...!!!

Upvotes: 0

Pavel Veller
Pavel Veller

Reputation: 6105

are you confusing attaching an XML Schema with attaching an XSLT transformation? because your browser is telling you about the absence of a stylesheet, not the absence of a schema

Upvotes: 2

Related Questions