xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandy...@ca.ibm.com
Subject Re: Code for XSDAttributeGroupTraverser
Date Wed, 12 Sep 2001 23:09:09 GMT
> Well Sandy, in this way you clearly distinguish the attribute declaration
> attribute usage. On the other hand, even using attributeDeclIndex in lieu
> XSAttributeUse object would suffice, as, when storing information about
> element in grammar, you need the set of attributes for this element. So,
you can
> use the set of attributeDeclIndices. Why an extra object here?.
> Let me be more elaborate. You can have an attribute declared in-line or a

> reference to a globally declared attribute. When you get in-line
> instantiate XSAttributeDecl, populate it, add to grammar and use this
index. If
> you get a reference to a globally declared attribute, check if it exists
> already. If not, its an error, else, use the index of the already
> XSAttributeDecl. This will keep things simple and clear.

Consider this:

<attribute name="att" type="string"/>

<attributeGroup name="ag1">
  <attribute ref="ns:att" use="required"/>

<attributeGroup name="ag2">
  <attribute ref="ns:att" use="prohibited"/>

Then where do you store the "type" information for "att", and where do you
store "use" information for the references to "att"?

One choice could be that whenever you see a reference to "att", you create
a new attribute declaration, copy all information from the global one, and
set "use" and "value constraint" on the new decl. Apparently, you are
wasting a lot of space. And this is what we've done in Xerces1.

In the new schema design, we want to avoid "information cloning" as much as
possible. So we store attribute decl and attribute use in separate places.
In attribute use, it only contains "use" "value constraint" and a pointer
to the attribute decl.

> Introducing XSAttributeGroupDecl is a really good idea. But, I feel, this
> should only hold references to attributes/attributeGroups/anyAttribute
> inside attributeGroup. So, you can call this an Object of pointers to
> attributes. In element declaration we can give a reference to this object
> thus the attributes. The sole purpose is to keep these set of attributes
> and use it wherever required.
> I think it should be:
> XSDAttributeTraverser.traverseGlobal: register XSAttributeDecl, return
> XSDAttributeTraverser.traverseLocal : register XSAttributeDecl, return
>                                                      OR
>                             resolve "ref" to XSAttributeDecl, return that
> XSDAttributeGroupTraverser.traverseGlobal: register XSAttributeGroupDecl,
> index.
> XSDAttributeGroupTraverser.traverseLocal : resolve "ref" to
> , return that index.
> What do you say?.

If you agree with me on the above point, then
XSDAttributeTraverser.traverseLocal should return a XSAtributeUse index.

> Well Sandy, I have a clear understanding of
> if you have not deleted the mail, in which I attached
> you will notice that, when checking for global traversal, I have not
> local attributes (I mean attributes required for local decl. e.g. "ref")
> vice-versa. But, when Elena checked in the code to CVS, I found those
> were added. Well, adding such checks are not going to harm the
functionality but
> they are very well not required. I should have asked Elena about this,
but, I
> missed. Therefore, in my next code viz. XSDAttributeGroupTraverser, I did
> same.

So you are innocent :-) sorry for not looking at your original code.

> -I have the habit of using the S&G <scope of var.>_<2-3 letter acr. for
> type><Name of var. in Hungarian notation>. Also, I start the opening
brace in
> the next line, which I have seldom found. Well, if this is not the
> followed here, that's okay. But, this may take a little more time for me
> code. Anyways, can you tell me exactly where the coding convention is?. I
> try to use them, onwards.

I'm sure different people will have different coding habit, but I don't
think it's too hard to change. (I used to code the same way as you do:
using lots of '_', put { in a new line, etc.) It'd just be nice to have a
consistent looking for one project.

The reason I didn't tell you the link to Andy's coding convention is that I
didn't remember (and still don't know) where it's located :-) Anybody wants
to help me out here?

> -You are right. In both my classes, from the traverseLocal and
> methods, a common method viz. traverseXXXDecl is invoked. Actually, both

> XSDElementTraverser and XSDSimpleTypeTraverser are doing the same thing.
In both
> these classes, both the traverseLocal and traverseGlobal methods invoke
> traverseXXX. So, I was provoked by these classes to the same. If you
want, I can
> remove these methods for you in my classes. But, I feel dumping the whole
> again in traverseGlobal or traverseLocal seperately is not a pleasant

The reason element/attribute/simpleType traverser look that way is because
there are lots of common code for named components. But for group and
attributeGroup, the global and local cases are so different that there is
almost no common code.

I didn't have much time to work on the attribute/attributeGroup stuff these
two days. I'll try to do something this week.

I just put in some other changes. I'll write another message explaining

Sandy Gao
Software Developer, IBM Canada
(1-416) 448-3255

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

View raw message