Hi Laurance,
thanks for the comments.
 
The ui that I am building is not viewing th e XML in a raw form, more of a tree of the logical constructs and property sheets. In the property sheets is the place that I thank that we could use this support.
 
For the specific application, the list of values would be very small. I dont believe that this should be too complex .
For the general case it seems to be that the results are limitted to a xpath (reduced) query, and will be finite. The validation can be applied as a list / combo box / text box depending on the number of options returned, with appropriate validaton post entry
 
Thanks
 
Mike


From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: 11 October 2005 19:50
To: [email protected]
Subject: RE: Key/value detection

Hi Mike

 

Ah – I thought you wanted to be able to analyse the schema.

 

As far as instance docs – you can, of course, just run validate() on it. That checks uniqueness and keys vs keyrefs (among other things) - at least I know there are errors for failing to validate in that way – see src/xmlpublic/org/apache/xmlbeans/message.properties - cvc-identity-constraint.4.1, cvc-identity-constraint.4.2.2 and cvc-identity-constraint.4.3 and the corresponding error codes in XmlErrorCodes and the validation code in IdentityConstraint.

 

To design a UI that could e.g. underline values in an XML instance document which are invalid, you’d probably have to call XmlOptions.setErrorListener() passing a Collection, then call validate() on your XmlBean instance, then loop through the ErrorListener Collection looking for particular error codes (I believe the returned Collection will contain just XmlError objects). Once you’ve identified the ones you want to highlight you can ask the XmlError for the position of the error and then highlight it.

 

I think that answers your #2 – but it’s just a suggestion. It sounds a bit heavyweight to me to be executed on (say) every keystroke but maybe it would be OK if your UI had a “validate me” button. Anyway I’m not sure what else to suggest. I’m no expert on this code – so maybe someone else on this list will have a better idea.

 

As far as #1 – that goes a bit further. I think you’re suggesting listing which values are valid in order to provide a drop down or some such thing. That might be more difficult – as there could be a potentially infinite # of such values. And even if it were a finite list, generating that list in the case of attributes restricted by complicated patterns sounds very difficult. So AFAIK I don’t think there’s any support for what you want to do in #1.

 

Cheers,

 

Lawrence

 


From: Mike Skells [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 11, 2005 5:36 AM
To: [email protected]
Subject: RE: Key/value detection

 

H Laurance,

From my (limitted) understanding doesnt the getConstraints give the constraints that are defined on an element, not those that are applied

 

What I was looking for is a way to say (for example) that 

1. an atribute value is limitted to a specific list of values because it is a keyRef.

2. that a specified value is invalid because it is not unique, and is part of a key or unique constraint

 

I am looking to build some UI tools to manage some documents that we use internally

 

I think that I will have to scan all of the document and build these reverse lookups.

 

Mike

 

 


From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: 10 October 2005 18:18
To: [email protected]
Subject: RE: Key/value detection

Hi Mike

 

The SchemaLocalElement interface (and hence SchemaGlobalElement too since it inherits from SchemaLocalElement) has a getIdentityConstraints() API which returns an array of SchemaIdentityConstraint objects which I think should be helpful to you.

 

You can navigate to an object that implements SchemaLocalElement from a given SchemaType using the getContentModel() API (possibly recursively) although you may have to do an instanceof check on the returned object and then cast it to a SchemaLocalElement before you can use it. All generated XmlBeans have a public static variable called type which will return the SchemaType.

 

Cheers,

 

Lawrence

 


From: Mike Skells [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 09, 2005 4:27 PM
To: [email protected]
Subject: Key/value detection

 

Hi

Is there any way to detect that a field has constraints applied to it (unique key, keyref)

 

Mike

________________________________________________________________________________
BEAWorld 2005: coming to a city near you.  Everything you need for SOA and enterprise infrastructure success.
 
 
Register now at http://www.bea.com/4beaworld
 
 
London 11-12 Oct| Paris13-14 Oct| Prague18-19 Oct |Tokyo 25-26 Oct| Beijing 7-8 Dec
________________________________________________________________________________
BEAWorld 2005: coming to a city near you.  Everything you need for SOA and enterprise infrastructure success.

 
Register now at http://www.bea.com/4beaworld

 
London 11-12 Oct| Paris13-14 Oct| Prague18-19 Oct |Tokyo 25-26 Oct| Beijing 7-8 Dec

Reply via email to