You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by sa...@ca.ibm.com on 2002/05/30 00:11:08 UTC

PSVI interface changes

In the package org.apache.xerces.xni.psvi, there are 3 interfaces used to
expose PSVI information.

Now that the schema component API is implemented, I'll be working on
exposing it via PSVI.

Some changes are necessary to the PSVI interfaces: to expose schema
components, and to make the two sets of interfaces consistent. The attached
are the modified interfaces. Changes include:

1. Constant names

The PSVI interfaces used common suffixes for constants, while the component
interfaces used common prefixes. Common prefixes seem to be better, so the
constant names will be changed to:

    public static final short VALIDITY_UNKNOWN               = 0;
    public static final short VALIDITY_INVALID               = 1;
    public static final short VALIDITY_VALID                 = 2;
    public static final short VALIDATION_NONE                = 0;
    public static final short VALIDATION_PARTIAL             = 1;
    public static final short VALIDATION_FULL                = 2;

2. Method names

There were PSVI methods named isXXX(). The component API uses getIsXXX() in
this case, to make it possible to have IDL definition for the interfaces in
the future (by making IsXXX an attribute). To follow the same fashion,
isXXX methods are changed to getIsXXX().

3. getErrorCodes()

This method used to return a String array. The component API handles this
kind of situations by returning an Enumeration. So I change the return type
of this method to return an Enumeration too.

4. Light vs. heavy weight properties

For type definitions and element/attribute declarations, we used to expose
the light weight properties. That is, the name, namespace, anonymous, isNil
properties, etc. Now since we have interfaces describing these components,
we can return the object directly, and various properties can be queried
from this object.

So the light weight methods will be replaced by the heavy weight ones:
    public XSTypeDefinition getTypeDefinition();
    public XSSimpleTypeDefinition getMemberTypeDefinition();
    public XSElementDeclaration getElementDeclaration();
    public XSAttributeDeclaration getAttributeDeclaration();

5. Exposing [schema information] property

This property (3.15.5) exposes all the schema components, target
namespaces, and schema documents used to construct the "schema" that's used
for the validation. The attached doesn't include this change, because I'm
still struggling with making it working with XSModel and grammar-loading
mechanism.


I know the first 4 changes might affect some existing code. But I believe
it's worth it:
- The interfaces are experimental, so it's subject to (reasonable) changes;
- Consistent naming will benefit us in the longer term;
- The heavy weight properties covers information provided by the light
weight ones, so it's redundant to have methods for them on the interfaces.


Comments are welcome as always. I'll check-in the interfaces and
implementation soon, if there is no major objections.

Thanks,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
sandygao@ca.ibm.com

(See attached file: ItemPSVI.java)(See attached file: ElementPSVI.java)(See
attached file: AttributePSVI.java)

Re: PSVI interface changes

Posted by Andy Clark <an...@apache.org>.
sandygao@ca.ibm.com wrote:
> 2. Method names
> 
> There were PSVI methods named isXXX(). The component API uses getIsXXX() in
> this case, to make it possible to have IDL definition for the interfaces in
> the future (by making IsXXX an attribute). To follow the same fashion,
> isXXX methods are changed to getIsXXX().

Ugh. The "Is" is completely superfluous. And if you look at
the DOM API, which is also generated from IDL, it does not
use "getIsXXX" for boolean fields. Case in point: specified
attributes. The method is "getSpecified", not "getIsSpecified".

I personally don't have a problem with having the Java
binding of IDL for a boolean attribute follow Java standards
and prefix an "is" instead of "get" to the accessor method.
And even JavaBean naming conventions allow both. But I
always cringe when I see "getIsXXX".

To me, this is completely ugly. But I don't have a use for
XML Schema, so it doesn't bother me that much.

-- 
Andy Clark * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org