K
Kevin Partin
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:noNamespaceSchemaLocation="eigen.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fred>
<eigenvalue>3.850019E-07</eigenvalue>
<radians>6.204852E-04</radians>
<cycles>9.875329E-05</cycles>
</fred>
<mode>
<eigenvalue>1.506695E-06</eigenvalue>
<radians>1.227475E-03</radians>
<cycles>1.953587E-04</cycles>
</mode>
<mode>
<eigenvalue>2.165626E-06</eigenvalue>
<radians>1.471607E-03</radians>
<cycles>2.342135E-04</cycles>
</mode>
<mode>
<eigenvalue>3.912464E-06</eigenvalue>
<radians>1.977995E-03</radians>
<cycles>3.148077E-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="eigenvalues">
<xs:element ref="mode" minOccurs="1" maxOccurs="unbounded"/>
</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="eigenvalue" 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:noNamespaceSchemaLocation="eigen.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fred>
<eigenvalue>3.850019E-07</eigenvalue>
<radians>6.204852E-04</radians>
<cycles>9.875329E-05</cycles>
</fred>
<mode>
<eigenvalue>1.506695E-06</eigenvalue>
<radians>1.227475E-03</radians>
<cycles>1.953587E-04</cycles>
</mode>
<mode>
<eigenvalue>2.165626E-06</eigenvalue>
<radians>1.471607E-03</radians>
<cycles>2.342135E-04</cycles>
</mode>
<mode>
<eigenvalue>3.912464E-06</eigenvalue>
<radians>1.977995E-03</radians>
<cycles>3.148077E-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="eigenvalues">
<xs:element ref="mode" minOccurs="1" maxOccurs="unbounded"/>
</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="eigenvalue" 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