Hi Vance, There are some scripts that you can use to validate an instance to a schema type. Take a peek at the svalidate/validate scripts in the bin directory. The class that is called is: org.apache.xmlbeans.impl.tool.InstanceValidator and might do what you are looking for. Hope this helps, -Jacob Danner
On 5/2/07, Vance Vagell <[EMAIL PROTECTED]> wrote:
Hi folks, First, thanks for the tip earlier about atomic type validation, Cezar. Here is another issue I've been working on, that I hope someone has insight into. It is similar to this old thread: http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200501.mbox/[EMAIL PROTECTED] I have a SchemaType object that I've loaded from an .xsd file. I also have a piece of data that I'd like to validate against that SchemaType object. Here is how I'm trying to do it: String value = "car"; // The value I want to validate. XmlObject xmlObject = XmlObject.Factory.parse("<product>" + value + "</product>"); // I make a temporary XmlObject to hold the value. xmlObject = xmlObject.selectChildren(new QName("product"))[0]; // I get the <product> element (what I want to validate), not the doc root. xmlObject = xmlObject.changeType(schemaType); // I specify the type to validate against. return xmlObject.validate(); // I perform validation. This always returns false... And here is the schema snippet that defines the type that is held in schemaType: <xsd:simpleType name="productType"> <xsd:restriction base='xsd:string'> <xsd:enumeration value='truck'/> <xsd:enumeration value='car'/> </xsd:restriction> </xsd:simpleType> I get an error (not an exception) when xmlObject.validate() is called; I used XmlOptions.setErrorListener() to get the error info. Here is the error: Message: Invalid type Location of invalid XML: <product>car</product> Does the mailer thread I linked earlier mean that I can't validate programatically this way? The types I'm dealing with are completely unknown before runtime, as these are end-user-specified schemas and values. Compiling these into Java classes isn't an option for this application. If the way I'm doing it is wrong, is there another way? Thanks for the help, Vance --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

