Here is the pertinent information:

xerces-c++ version 1.6.0, built from xerces-c-src1.6.0 using CBuilder5
operating system: Windows 2000 Professional, version 5.00.2195, Service Pack
2
compiler: default CBuilder5 C++ compiler
xml file: see attached file named PatientInfo.xml
schema file: see attached file named PatientInfo.xsd
source code file: see attached PatientInfoXml.cpp and PatientInfoXML.hpp

How it works: I call PatientInfoXml::createDomFromXml() with the following 2
parameters:
pXmlFileUrl: file://localhost/C:\\ProgramLibs\\Wrox\\PatientInfo.xml
useSchemaValidation: true

What happened: The <dateOfBirth> element is declared to be of type "date" in
the shema file.  I inserted <dateOfBirth>robert</dateOfBirth> into the xml
file.  Xerces should have thrown a validation error during the call to
parser->parse(pXmlFileUrl), but it did not.



 -----Original Message-----
From:   Robert McCarthy [mailto:[EMAIL PROTECTED]]
Sent:   Thursday, May 23, 2002 3:37 PM
To:     '[EMAIL PROTECTED]'
Subject:        Xerces-C Does Not Validate Date Value

Hi, I'm running Xerces-C 1.6.0 in a CBuilder5 environment.  I'm using the
DOMParser with schema validation enabled.  In my schema, I have the
following element:
        <xs:element name="dateOfBirth" type="xs:date"/>
In my XML file that I validate against this schema, I have the following
element:
        <dateOfBirth>robert</dateOfBirth>
Xerces does not report an error!

Does Xerces validate dates against schema definitions?

Thanks!

Robert
��<?xml version="1.0" encoding="UTF-8"?>

<patientInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

		 xsi:noNamespaceSchemaLocation="file://localhost/C:\ProgramLibs\Wrox\PatientInfo.xsd">

  <patientID>123-45-6789</patientID>

  <patientName>

    <firstName>Thomas</firstName>

    <middleName>Jefferson</middleName>

    <lastName>Jones</lastName>

  </patientName>

  <dateOfBirth>robert</dateOfBirth>

  <gender>male</gender>

  <height units="in" display1="null" display2="in">76.0</height>

  <weight units="lbs" display="lbs">205.0</weight>

</patientInfo>

��<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

           attributeFormDefault="qualified"

           elementFormDefault="qualified"> 

	<xs:simpleType name="HeightBaseType">

		<xs:restriction base="xs:float">

			<xs:minInclusive value="36.0"/>

			<xs:maxInclusive value="100.0"/>

		</xs:restriction>

	</xs:simpleType>

	<xs:simpleType name="WeightBaseType">

		<xs:restriction base="xs:float">

			<xs:minInclusive value="40.0"/>

			<xs:maxInclusive value="450.0"/>

		</xs:restriction>

	</xs:simpleType>

	<xs:element name="patientInfo">

		<xs:annotation>

			<xs:documentation>XML structure to store all information related to a patient, questions and answers (point in time), references to physician, and lists of tests performed</xs:documentation>

		</xs:annotation>

		<xs:complexType>

			<xs:sequence>

				<xs:element name="patientID" type="xs:string">

					<xs:annotation>

						<xs:documentation>this is the PCP identifier for this patient</xs:documentation>

					</xs:annotation>

				</xs:element>

				<xs:element name="patientName">

					<xs:complexType>

						<xs:sequence>

							<xs:element name="firstName" type="xs:string"/>

							<xs:element name="middleName" type="xs:string"/>

							<xs:element name="lastName" type="xs:string"/>

						</xs:sequence>

					</xs:complexType>

				</xs:element>

				<xs:element name="dateOfBirth" type="xs:date"/>

				<xs:element name="gender">

					<xs:simpleType>

						<xs:restriction base="xs:string">

							<xs:enumeration value="male"/>

							<xs:enumeration value="female"/>

						</xs:restriction>

					</xs:simpleType>

				</xs:element>

				<xs:element name="height">

					<xs:complexType>

						<xs:simpleContent>

             					<xs:extension base="HeightBaseType">

								<xs:attribute name="units" type="xs:token" fixed="in" use="required"/>

								<xs:attribute name="display1" use="required">

									<xs:simpleType>

										<xs:restriction base="xs:token">

											<xs:enumeration value="ft"/>

											<xs:enumeration value="null"/>

										</xs:restriction>

									</xs:simpleType>

								</xs:attribute>

								<xs:attribute name="display2" use="required">

									<xs:simpleType>

										<xs:restriction base="xs:token">

											<xs:enumeration value="in"/>

											<xs:enumeration value="cm"/>

											<xs:enumeration value="null"/>

										</xs:restriction>

									</xs:simpleType>

								</xs:attribute>

							</xs:extension>

						</xs:simpleContent>

					</xs:complexType>

				</xs:element> 

				<xs:element name="weight">

					<xs:complexType>

						<xs:simpleContent>

             					<xs:extension base="WeightBaseType">

								<xs:attribute name="units" type="xs:token" fixed="lbs" use="required"/>

								<xs:attribute name="display" use="required">

									<xs:simpleType>

										<xs:restriction base="xs:token">

											<xs:enumeration value="lbs"/>

											<xs:enumeration value="kg"/>

											<xs:enumeration value="null"/>

										</xs:restriction>

									</xs:simpleType>

								</xs:attribute>

							</xs:extension>

						</xs:simpleContent>

					</xs:complexType>

				</xs:element> 

			</xs:sequence>

		</xs:complexType>

	</xs:element>

</xs:schema>

Attachment: PatientInfoXml.cpp
Description: Binary data

Attachment: PatientInfoXml.hpp
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to