I have an XML data file that I want to validate using an XML Schema.
The XML data file is saved to a file named 'eigen.xml' and is shown
below:
<?xml version="1.0" ?>
<eigenvalues xsi:noNamespace SchemaLocation= "eigen.xsd"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<fred>
<eigenvalue>3.8 50019E-07</eigenvalue>
<radians>6.2048 52E-04</radians>
<cycles>9.87532 9E-05</cycles>
</fred>
<mode>
<eigenvalue>1.5 06695E-06</eigenvalue>
<radians>1.2274 75E-03</radians>
<cycles>1.95358 7E-04</cycles>
</mode>
<mode>
<eigenvalue>2.1 65626E-06</eigenvalue>
<radians>1.4716 07E-03</radians>
<cycles>2.34213 5E-04</cycles>
</mode>
<mode>
<eigenvalue>3.9 12464E-06</eigenvalue>
<radians>1.9779 95E-03</radians>
<cycles>3.14807 7E-04</cycles>
</mode>
</eigenvalues>
The XML schema file saved to the file 'eigen.xsd' and is located in
the same directory as the XML data file.
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="eigenvalu es">
<xs:element ref="mode" minOccurs="1" maxOccurs="unbo unded"/>
</xs:element>
<xs:element name="mode">
<xs:complexType >
<xs:all>
<xs:element ref="eigenvalue "/>
<xs:element ref="radians"/>
<xs:element ref="cycles"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="eigenvalu e" type="xs:double "/>
<xs:element name="radians" type="xs:double "/>
<xs:element name="cycles" type="xs:double "/>
</xs:schema>
I have introduced an intentional error in the data file (there is no
element named 'fred' in the schema) in an attempt to study how errors
are handled. However, I am not sure that I have referenced the schema
file correctly in the data file. I am trying to view the file in
Mozilla 1.6 and MS Explorer 6.0 and each browser does not flag the
error. I would appreciate it if someone can help me understand what I
am doing wrong. I am new to XML and have been reading the O'Reilly
books 'Learning XML' and 'XML Schema', but I must still be missing
something.
Thank you,
Kevin
The XML data file is saved to a file named 'eigen.xml' and is shown
below:
<?xml version="1.0" ?>
<eigenvalues xsi:noNamespace SchemaLocation= "eigen.xsd"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<fred>
<eigenvalue>3.8 50019E-07</eigenvalue>
<radians>6.2048 52E-04</radians>
<cycles>9.87532 9E-05</cycles>
</fred>
<mode>
<eigenvalue>1.5 06695E-06</eigenvalue>
<radians>1.2274 75E-03</radians>
<cycles>1.95358 7E-04</cycles>
</mode>
<mode>
<eigenvalue>2.1 65626E-06</eigenvalue>
<radians>1.4716 07E-03</radians>
<cycles>2.34213 5E-04</cycles>
</mode>
<mode>
<eigenvalue>3.9 12464E-06</eigenvalue>
<radians>1.9779 95E-03</radians>
<cycles>3.14807 7E-04</cycles>
</mode>
</eigenvalues>
The XML schema file saved to the file 'eigen.xsd' and is located in
the same directory as the XML data file.
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="eigenvalu es">
<xs:element ref="mode" minOccurs="1" maxOccurs="unbo unded"/>
</xs:element>
<xs:element name="mode">
<xs:complexType >
<xs:all>
<xs:element ref="eigenvalue "/>
<xs:element ref="radians"/>
<xs:element ref="cycles"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="eigenvalu e" type="xs:double "/>
<xs:element name="radians" type="xs:double "/>
<xs:element name="cycles" type="xs:double "/>
</xs:schema>
I have introduced an intentional error in the data file (there is no
element named 'fred' in the schema) in an attempt to study how errors
are handled. However, I am not sure that I have referenced the schema
file correctly in the data file. I am trying to view the file in
Mozilla 1.6 and MS Explorer 6.0 and each browser does not flag the
error. I would appreciate it if someone can help me understand what I
am doing wrong. I am new to XML and have been reading the O'Reilly
books 'Learning XML' and 'XML Schema', but I must still be missing
something.
Thank you,
Kevin
Comment