Hi Vance,
I guess I'm a little confused as to what you are trying to do. It
sounds like you are trying to validate user input with xmlbeans
without a schema or values since you don't care about the elements or
other data.
Why not use some kind of form validation? - since xml/xsd is not
important to your problem
What about creating an simpleType with valid enumeration values and
validating against that?

For your scenario:
- I have a value, as a string.  Such as "car".
- I have a SchemaType object (a simple type), that was loaded from a
schema file, that says that valid values are "car" or "truck".
- I want to validate that "car" is a valid value, given the SchemaType object.

it seems like the enumeration might do the trick for you with a little
effort. Have you tried this route?
-Jacob Danner


On 5/7/07, Vance Vagell <[EMAIL PROTECTED]> wrote:
Hi,

This issue is a sticking-point on our project, since it's one of the main 
reasons we chose to go with XMLBeans (the fact that we could validate against a 
type in isolation -- not an entire schema file).

Without going into great detail, our project involves a graphical editor where 
each user-inputted value is governed by a type from a schema file (but where 
not enough data is available at validation time to validate on a document 
level).

If no one is sure how to do this, can anyone recommend a few places to poke 
around in the XMLBeans code to get this working?  If necessary we could update 
the library itself to support this, with some direction for a starting point.

Thanks again,
Vance

> -------- Original Message --------
> Subject: RE: Validating a value against a SchemaType object
> From: Vance Vagell <[EMAIL PROTECTED]>
> Date: Thu, May 03, 2007 8:48 pm
> To: [email protected]
>
> Hi Jacob,
>
> Thanks for the tip.  I took a look at InstanceValidator, and noticed
> that the key difference was that it uses the same SchemaTypeLoader
> instance it used to load the SchemaTypes to also load the XML to be
> validated.  I tried that, no dice.  However, I did a little more
> debugging:
>
> * The error value I get back when validation fails is: cvc-elt.1
> * XmlErrorCodes describes this error as "ELEM_LOCALLY_VALID$NO_TYPE",
> "cvc-elt.1: See clause 1 of XMLSchema Structures 1.0: Element Locally
> Valid (Element)"
> * I took a look at the suggested part of the schema spec, and that
> clause reads "1 The declaration must not be absent."
> * I took a look at all the XmlBeans code that includes the words
> "invalid type", and found that the most likely source of this is this
> part of QNameHelper:
>
>         if (sType.isNoType() || sType.getOuterType() == null)
>         {
>             return "invalid type";
>         }
>
> * Using a debugger, I was able to confirm that the SchemaType I'm
> validating against DOES return null for getOuterType() (not sure what
> this signifies -- the Javadocs for this method are very terse).
>
> So long story short, let me restate my goal, and hopefully someone has
> another lifejacket they can throw me as I float around in this sea of
> schemas and XML:
>
> - I have a value, as a string.  Such as "car".
> - I have a SchemaType object (a simple type), that was loaded from a
> schema file, that says that valid values are "car" or "truck".
> - I want to validate that "car" is a valid value, given the SchemaType
> object.
> - I create an XmlObject like this:
>
> XmlObject xmlObject = schemaTypeLoader.parse("<whatever>" + value +
> "</whatever>", null, null); // Note that the SchemaType specified here
> is null, I don't have or want a type that defines "whatever"
>
> - I select the "whatever" child, because I am not actually interested
> in the tag, just the (simple) value.
>
> xmlObject = xmlObject.selectChildren(new QName("whatever"))[0];
>
> - I change the type of the object to the type I'm interested in
> validating against:
>
> xmlObject = xmlObject.changeType(schemaType);
>
> However, xmlObject.validate() always returns false, and if I use an
> error listener I find out the information I described earlier in this
> email.
>
> I've spent quite a few hours looking into this, and would sincerely
> appreciate any advice others may have as to how I can perform this
> validation.  Note that the schemas involved have not been compiled
> into Java objects, as this is a fully dynamic application, where the
> schemas are loaded -- the user types in a value -- and then the
> SchemaType objects are referenced to check its validity.
>
> Thanks so much!
>
> - 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]

Reply via email to