Have you tried using simpleTypes in your XSD for these values.
ie
<xs:simpleType name="vehType">
 <xs:restriction base="xs:token"> <!-- like a string but stricter -->
   <xs:enumeration value="car"/>
   <xs:enumeration value="truck"/>
</xs:restriction>
</xs:simpleType>

You could then refer to this type in various places in the schema
<xs:complexType name="vehicle">
 <xs:sequence>
   <xs:element name="typeOfVehicle" type="tns:vehType"/>
  ...
<xs:element name="VehicleTypeValidateElement" type="tns:vehType"/>
And when you got the user input you would be able to do something like:
VehicleTypeValidateElement v =
VehicleTypeValidateElement.Factory.parse("<VehicleTypeValidateElement>"+userInput+"</VehicleTypeValidateElement>");
and then ...
v.validate()
or what not.

There are several ways to represent the types you could use for
validation in your xsd. I find myself going back to:
http://www.xfront.com/GlobalVersusLocal.html when the types I want are
not POJOs as I want to access them.

As far as simple atomic types, are you having problems using
XmlInt.setValue, etc?

Thanks,
-Jacob Danner

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

Ah, I can see how you that could be confusing.  Imagine an editor display like 
the following (this is a contrived example, but is similar to what we're doing):

Vehicle (no input allowed, this is a parent element that can't hold a value)
  Model number: __________   (the value should be limited to "int")
  Vehicle type: __________   (the value should be limited to "string", and be one of 
"car", or "truck")

So what the user is entering are the values that go in the blanks above.  The overall 
"Vehicle" document DOES have a schema XSD file; it has been loaded in 
SchemaType objects, and we know which SchemaType object goes along with each field.  What 
I want to do is validate the user's input to a field and give them immediate feedback 
about if their input is valid or not.

To do this, I need to validate against a particular element's atomic type 
(e.g., int, string) and its constraints (e.g., enumerations, max numerical 
values) but NOT its children or place in the hierarchy (which of course isn't 
complete yet, since they haven't filled out all fields).

You're right in regards to enumerations, those are easy enough to check on our 
side.  For enumerated fields, we only allow values that match the enumeration 
list from the SchemaType.  But we can't figure out how to validate the atomic 
type and constraints against the SchemaType.

Any hints?

Thanks again,
Vance


----------------------------------------
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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to