It could be very easy to expose the type information. Might just take 5
minutes. The problem is, there is no standard API for PSVI, so the way of
getting such information could change 5 minutes later.
For prototyping, I suggest you have your own version of ElementPSVImpl
(package org.apache.xerces.impl.xs), which contains one more method than it
currently has:
public XSTypeDecl getTypeDefinition() {
return fTypeDecl;
}
Similar things can be done with AttributePSVImpl.
Then you can get the PSVI item for element/attribute that you are
interested in (the sample xni.PSVIWriter shows how to do it), and get the
type definition from it. To check whether one type is derived from another
one, you can call
XSConstaints.checkTypeDerivationOk(derived, base, block)
But this is only for prototyping. It's better to write your own derivation
checking method: I suspect that you won't need the "block" information, so
the method could be really easy. It's a little bit tricky to handle the
ur-type's, but I'm sure you'll get around it. :-)
Hope this helps,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
[EMAIL PROTECTED]
Joseph
Kesselman/CAM/L To: [EMAIL PROTECTED]
otus@Lotus cc: [EMAIL PROTECTED]
Subject: Re: What schema info is
available?
03/15/2002
05:37 PM
Please respond
to xerces-j-dev
>We will be working on providing full PSVI support
I've been asked to start trying to prototype soon... and initially I don't
need the full PSVI (specific facets and such), just the ability to ask
whether an element of complex type Customer was derived from complext type
PersonWithAddress, or whether PartNumber is encoded as a positiveInteger,
or whether Timeclock can be viewed as a list of dateTimes...
>To check whether one schema type 'D' is derived from
>another one 'B', the right way would be to recursively get
>the base type of 'D' and compare it with 'B'.
If the base type is always the immediate ancestor rather than the
highest-level ancestor, that would certainly work. Is there a way I can
ask the Xerces schema validator what a type's base type is?
It would probably be significantly more convenient and more efficient if
the schema APIs walked the ancestry tree for us -- providing an
encapsulated schema-type equivalent of instanceOf -- but that's a
refinement we can add later. For now, I just need advice on how to take
that first step...
---------------------------------------------------------------------
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]