Hi Luis

Right now there is no simple way to find all the DataType instances for a
document. The current implementation works like this:-

* a schema is loaded explicitly using SchemaDocumentFactory.loadSchema() or
via the presence of a noNamespaceSchemaLocation attribute. (the
schemaLocation attribute should be supported shortly).

* a DocumentFactory usually caches QName instances. A QName instance can
have its own DocumentFactory instance associated with it. This is useful for
using a schema based factory approach - using different DocumentFactory
instances for different named elements.

* The SchemaDocumentFactory associates SchemaElementFactory instances with
QNames found in the schema which understand the DataType requirements. A
single SchemaElementFactory knows the data types for the attributes and
child elements it contains.

* whenever you call getData() or setData() on a Attribute or Element from
the schema it will use the correct DataType instance to turn the object into
a String or a primitive data type (java.lang.Number etc.).

Now I'm sure we can add the necessary code to SchemaDocumentFactory to
extract the information you need. As a step along the way, I've added a
helper method to DocumentFactory called

    List getQNames();

which returns a List of all the QName instances used by a DocumentFactory.
This method is in CVS and the current daily build.

Itereating through this list we can find all the QNames and from there find
all the SchemaElementFactory instances used - and so create some data
structure of all the DataTypes used in a SchemaDocumentFactory.

Does this help any? How would you like to know what the data types are? Do
you just want all the DataTypes used or do you want them associated with
attribute or element QNames?


Incidentally, in the next few days the org.dom4j.schema package will move to
the org.dom4j.datatype package. So the classes will be called
DatatypeDocumentFactory and DatatypeElementFactory rather than the Schema*
equivalent.

James
----- Original Message -----
From: "Luis Peña" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 27, 2001 8:45 AM
Subject: [dom4j-dev] Processing XMLSchema with Dom4j


Hello,

I want to know how can I parse a xsd document and obtain all the DataTypes
(com.sun.tranquilo.datatype.DataType) that its contains?

I was trying it with SchemaDocumentFactory but I really don't know how to do
it.

Thank you.

=====================
Luis Peña Sánchez
A.Q.S.
C/ Jorge Juan, 30, 6º. MADRID

[EMAIL PROTECTED]
=====================


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to