Reputation: 63
Say I have an xml file student.xml
<?xml version="1.0" encoding="utf-8"?>
<College>
<Student>
<name>John</Name>
<RollNo>1</RollNo>
</Student>
<Student>
<name>rosh</Name>
<RollNo>2</RollNo>
</Student>
</College>
Now how to add XSD reference for file student.xsd
which is present in the same folder and validate the xml with it?
Upvotes: 0
Views: 148
Reputation: 163282
You don't need to modify the XML document to include a reference to the schema. Every schema validator has some kind of API or user interface allowing you to say "validate document X against schema Y". The details depend on whether you are doing this from an application, from the command line, or from some interactive tool, which schema processor you are using, what platform you are running on, etc.
Upvotes: 1
Reputation: 534
Change in root element:
<College xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="student.xsd">
...
</College>
Upvotes: 0