W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

RE: XML Schema validation using JAXP Q?

From: <Jakub.Valenta@Deio.net>
Date: Tue, 18 Dec 2001 09:55:02 +0200
To: Tom Preston <tpreston@amadeusboston.com>, xmlschema-dev@w3.org
Message-ID: <OF0A9FD38A.958DE672-ONC2256B26.002B46C2@e-know.net>

Thanks a lot for help,
I would like to ask one more think. Is the example, you gave me, going to
work with any JAXP compatible parser, or is the validation Xerces
proprietary?

br,

Jakub





Tom Preston <tpreston@amadeusboston.com> on 12/17/2001 10:57:20 PM

To:   Jakub.Valenta@Deio.net, xmlschema-dev@w3.org
cc:

Subject:  RE: XML Schema validation using JAXP Q?

You write a trivial java program like this:

Compile and run it like this (notice xerces.jar and xml-apis.jar are
needed):

C:\xml>javac -classpath
.;c:\thirdparty\apache\xerces.jar;c:\thirdparty\apache\x
ml-apis.jar SchemaValidate.java

C:\xml>java -classpath
.;c:\thirdparty\apache\xerces.jar;c:\thirdparty\apache\xm
l-apis.jar SchemaValidate editor99.xml
Error:  org.xml.sax.SAXParseException: Datatype error: In element
'allowNull' :
tru is not a boolean.


NOtice that editor99.xml failed validation.  Here is editor99.xml and
editor.xsd which it validates against (note the xsi:schemaLocation is
defined in the .xml file):

------
editor.xml
------
<!DOCTYPE htmlEditor >
<htmlEditor
  xmlns="http://www.emilygraham.com/java/other/Editor"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.emilygraham.com/java/other/Editor
  http://www.emilygraham.com/java/other/editor.xsd">

  <updateTime>1999-05-31T13:20:00</updateTime>
  <fields>
    <field columnName="nickname">
      <shortDesc>Short Desc</shortDesc>
      <htmlType name="select">
        <name>firstName</name>
        <value>lastName</value>
      </htmlType>
      <allowNull>tru</allowNull>
      <defaultVal>Blueberry</defaultVal>
    </field>
  </fields>
</htmlEditor>

------
editor.xsd
------

<schema targetNamespace="http://www.emilygraham.com/java/other/Editor"
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:e="http://www.emilygraham.com/java/other/Editor"
        elementFormDefault="qualified">

  <annotation>
    <documentation xml:lang="en">
     Editor document definition defines an html based editor
    </documentation>
  </annotation>

  <element name="htmlEditor" type="e:HtmlEditorType"/>

  <element name="updateTime" type="dateTime"/>

  <complexType name="HtmlEditorType">
    <sequence>
      <element ref="e:updateTime" minOccurs="1" maxOccurs="1" />
      <element name="fields" type="e:Fields" minOccurs="1" maxOccurs="1" />
    </sequence>
  </complexType>

  <complexType name="Fields">
    <sequence>
      <element name="field" minOccurs="1" maxOccurs="unbounded">
        <complexType>
          <sequence>
            <element name="shortDesc" type="string" minOccurs="1"
maxOccurs="1"/>
            <element name="htmlType" type="e:HtmlTypeType" minOccurs="1"
maxOccurs="1"/>
            <element name="allowNull" type="boolean" minOccurs="1"
maxOccurs="1" />
            <element name="defaultVal"  type="string"/>
          </sequence>
          <attribute name="columnName" type="string" use="required"/>
        </complexType>
      </element>
    </sequence>
  </complexType>

  <complexType name="HtmlTypeType">
    <sequence>
      <element name="name" type="string" />
      <element name="value" type="string" />
    </sequence>
    <attribute name="name" type="e:HtmlNameType" use="required"/>
  </complexType>

  <simpleType name="HtmlNameType">
    <restriction base="NMTOKEN">
      <enumeration value="select"/>
      <enumeration value="text"/>
    </restriction>
  </simpleType>
</schema>

------
hope this helps.

TOm

-----Original Message-----
From: Jakub.Valenta@Deio.net [mailto:Jakub.Valenta@Deio.net]
Sent: Monday, December 17, 2001 12:26 PM
To: xmlschema-dev@w3.org
Subject: XML Schema validation using JAXP Q?


Hi all,
I would like to ask if it is possible to validate xml document against XML
Schema using JAXP? At the moment I am using XALAN and it should be XML
Schema aware, but I have no clue how to do the vlidation using JAXP.

Any help appreciated,

Jaub
Received on Tuesday, 18 December 2001 02:59:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT