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 2001/09/11 17:24:53 UTC

Re: Code for XSDAttributeGroupTraverser

Hi Rahul,

Thanks for looking into the XSDGroupTraverser and
XSDAttributeGroupTraverser.

Though you code basically looks fine to us, there are some points that I
want to share with you before you proceed.

1. How attribute information will be stored in Xerces2 schema grammar.

As the schema spec states, globally declared attributes result in
"attribute declaration" in the grammar, while locally declared ones result
in "attribute use" in the grammar. But in Xerces1, we don't distinguish
these two concepts. So there were lots of redundant information in Xerces1
about attribute declaration.

In Xerces2, we plan to separate these two concepts. (Similar to the
separation between element declaration and particle.) I'll add a new
XSAttributeUse class in the v2 branch, which corresponds to the "attribute
use" concept. And inside each XSAttributeUse instance, there will be a
reference to an XSAttributeDecl (by index, not object reference).

2. How attribute group information will be stored in Xerces2 schema
grammar.

An attribute group contains two parts: attribute uses and attribute
wildcard. I'm thinking of introducing an XSAttributeGroupDecl class to hold
such information. Do you have any other suggestion, or any opinion on how
to do it?

3. What should be returned from the traversal methods of
XSDAttributeTraverser and XSDAttributeGroupTraverser.

XSDAttributeTraverser.traverseGlobal: register an XSAttributeDecl, and
return the index;
XSDAttributeTraverser.traverseLocal: register an XSAttributeUse, and return
the index;
XSDAttributeGroupTraverser.traverseGlobal: register an
XSAttributeGroupDecl, and return the index;
XSDAttributeGroupTraverser.traverseLocal: resolve the "ref" attribute to an
XSAttributeGroupDecl index, and return such index.

What do you think?

4. What's the responsibility of XSAttributeChecker, and what's the
responsibility of the traversers.

As you noticed (and you already did), whenever we traverse an element in
the schema document, we call XSAttributeChecker.checkAttributes to get the
attribute values. This method is responsible for checking all attribute
(and attribute value) errors except one case: it won't report an error if a
required attribute is missing. The reasons are:
a. If it's a required attribute, the caller will definitely need it and
check whether it's present, so we don't need to duplicate the same effort
in XSAttributeChecker;
b. In some case, we don't know whether an attribute is required. For
example, attribute "base" of <restriction> is required when it's in a
complexType, but optional for a simpleType. So XSAttributeChecker doesn't
know whether it's an error if "base" is missing.

No it's clear that the caller (traverse methods) is only responsible for
reporting errors about missing required attributes. But in your code, you
also check for attributes that's not allowed for a certain element, which
is not necessary. (As an example, "name" on local group/attributeGroup)

5. Some coding habit

While this is completely up to you, just some thoughts:
- In Xerces-J, we seldom use '_' in variable names. Andy Clark had an
outline of coding convention in Xerces-J, which might be helpful to you.
- In both XSDGroupTraverser and XSDAttributeGroupTraverser classes, both
traverseLocal and traverseGlobal invoke a common method
"traverseGroupDecl/traverseAttributeGroupDecl". But there is almost no code
in common between the global and local cases. Do you have any reason doing
so? I think we can get rid of the traverse???Decl method, and just put the
right code into each of the appropriate methods. In fact, Lisa Martin is
working on removing traverseGroupDecl from the group traverser.

I'm so glad to see you guys actively involving in Xerces2 developing and
design. And you further code contributions and design opinions are very
welcome.

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


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