Hi Luis This sounds pretty close to the functionality of the org.dom4j.datatype library. Using this library you can parse an XML Schema document and create a Datatype-aware Document which performs data type validation.
Yuxin Ruan has been working away to improve the XML Schema Datatypes support (thanks Yuxin!) so I think we're getting quite close to full XSD datatype support. There's a simple example in dom4j/src/samples/DatatypeDemo.java which demonstrates how to parse a document using the DatatypeDocumentFactory which will create data types from a schema. So java.lang.Number/Integer/Double, java.util.Calendar etc. are created for elements and attributes that are defined in the schema. The XML Schema document can be read explicitly via the loadSchema() method on DatatypeDocumentFactory or implicitly via the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attributes. If you have a datatype aware document then the getData() method on an attribute or element will return the underlying Java data value object, such as a Number or Calendar. There are a whole bunch of JUnit tests in dom4j/src/test/org/dom4j/datatype/*.java which test out the datatype support; looking at those might help you understand the datatype support in dom4j. In addition there are 2 sample programs in the dom4j/src/samples/validate directory called MSVDemo and XercesDemo that might be helpful - they demonstrate how to perform XML Schema validation with dom4j using the MSV and Xerces libraries respectively. The MSV library looks very promising, it supports DTD, XML Schema, RelaxNG together with Relax and TREX. Does that help answer your question? James ----- Original Message ----- From: "Luis Peña" <[EMAIL PROTECTED]> To: "'James Strachan'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 8:02 AM Subject: RE: [dom4j-dev] Extracting Information from XMLSchemas > > Thanks boys, > > > > But the problem I want to solve is to retieve all the > > attributes from the schema, and, after store them, I want to > > create the DatatypeValidator for this attributes. > > > > Sorry for the misunderstunding, I haven't a very good english. > > > > I try your solution also. Thank you, again > ___________________________________________________ > Luis Peña Sánchez. AQS (Advanced Quality Solutions). > Ingeniero de Software. Jorge Juan 30, 6ª planta. > [EMAIL PROTECTED] 28001 Madrid. > <http://www.aqs.es/>. Tel.91 578 01 27. / Fax. 91 577 76 78. > ___________________________________________________ > > > > -----Mensaje original----- > De: James Strachan [mailto:[EMAIL PROTECTED]] > Enviado el: jueves, 08 de noviembre de 2001 17:07 > Para: Luis Peña; [EMAIL PROTECTED] > Asunto: Re: [dom4j-dev] Extracting Information from XMLSchemas > > > Hi Luis > > The following should work... > > Document document = ...; > Element element = (Element) document.selectSingleNode( > "/xsd:schema/xsd:element[@name='users']" ); > Element id = (Element) element.selectSingleNode( > "xsd:complexType/xsd:attribute[@name='id']" ); > Element _status = (Element) element.selectSingleNode( > "xsd:complexType/xsd:attribute[@name='_status']" ); > > Would that do? What kind of thing do you want to find from id and _status? > > James > ----- Original Message ----- > From: "Luis Peña" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, November 08, 2001 3:40 PM > Subject: [dom4j-dev] Extracting Information from XMLSchemas > > > Hello, > > I have a problem that I cannot solve because I don't know which way I must > choose. > > I want to extract some specific information from a XMLSchema, for example, > the name of the attributes that a specific element have. > > The Schema have this form: > > ................ > > <xsd:element name="users"> > <xsd:complexType> > <xsd:sequence> > <xsd:element minOccurs="0" maxOccurs="unbounded" name="user"/> > </xsd:sequence> > <xsd:attribute name="id" type="xsd:long" use="required" i18n="false"/> > <xsd:attribute name="_status" use="optional" i18n="false"> > <xsd:simpleType> > <xsd:restriction base="xsd:string"> > <xsd:maxLength value="14"/> > <xsd:enumeration value="DIRTY"/> > <xsd:enumeration value="VALIDATED"/> > <xsd:enumeration value="PUBLISHED"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:complexType> > </xsd:element> > ............... > > So I want to access to <id,_status> > > I had been trying it with dom4j and msv but I don't have a clue about what > to do. > > Can anybody help me?. > ___________________________________________________ > Luis Peña Sánchez. AQS (Advanced Quality Solutions). > Ingeniero de Software. Jorge Juan 30, 6ª planta. > [EMAIL PROTECTED] 28001 Madrid. > <http://www.aqs.es/>. Tel.91 578 01 27. / Fax. 91 577 76 78. > ___________________________________________________ > > > > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev