[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: XML Schema: DOs and DON'Ts
- From: Martin Gudgin <marting@develop.com>
- To: Kohsuke KAWAGUCHI <kohsukekawaguchi@yahoo.com>, xml-dev@lists.xml.org
- Date: Thu, 17 May 2001 08:11:16 +0100
----- Original Message -----
From: "Kohsuke KAWAGUCHI" <kohsukekawaguchi@yahoo.com>
To: "Martin Gudgin" <marting@develop.com>; <xml-dev@lists.xml.org>
Sent: Thursday, May 17, 2001 2:40 AM
Subject: Re: XML Schema: DOs and DON'Ts
>
> > OK, perfectly valid for that use case but that is *not* the use case you
> > give in your document. The reason you give for using attribute groups is
> > because you don't think people should use global attribute declarations.
>
> OK, now I understand your point better. Let me go back to your original
> question.
>
> > 4. Regarding your comment about attribute groups, why not just use a
> > local attribute declaration? That *is* what you get anyway despite the
> > syntactic sugar that, it would seem, makes you think otherwise.
>
> As you said, a local attribute declaration will solve the problem I
> depicted. But why do you bother learning that attributes can be used
> locally, when you can achieve the same effect by using attribute groups?
>
> And you need attribute groups anyway.
>
> It's just that I didn't feel the necessity to mention that attributes
> can be declared locally.
>
> Maybe I can even argue that local attributes are bad because you can't
> reuse or override them. (maybe)
But my point is that when you use attribute groups you *are* using local
attribute declarations. The attribute
declarations inside the group become local to the complex type at the point
that you reference the attribute group. Attribute groups ( and model
groups ) are just syntactic sugar. Useful syntactic sugar, no question, but
syntactic sugar all the same. They don't change the fundamental make up of
the schema. It seems to me you are misleading your readers by claiming that
attribute declarations inside attribute groups are somehow different from
attribute declarations inside complex types when, in fact, they are not.
>
>
>
>
> > > Again I'd appreciate if you would tell me why you wrote
> > >
> > > <foo:person xmlns:foo="http://best.practice.com">
> > > <familyName> KAWAGUCHI </familyName>
> > > <lastName> Kohsuke </lastName>
> > > </foo:person>
> > >
> > > instead of
> > >
> > > <person xmlns="http://best.practice.com">
> > > <familyName> KAWAGUCHI </familyName>
> > > <lastName> Kohsuke </lastName>
> > > </person>
> >
> > Perhaps because I'm mapping from the following Java type;
> >
> > package best.practice.com;
> >
> > public class person
> > {
> > String familyName;
> > String lastName;
> > }
> >
> > I think a lot of people that are using XML for something other than
document
> > markup may well end up going this way.
>
> I think you don't answer my question. There is no reason that data
> binding software can't support my way of using namespace. It's not a
> matter of document or data. It's, well, a matter of philosophy or
> something.
>
> What is the reason *not* to qualify lastName and firstName (ouch, I just
> find that familyName==lastName .... )?
There is no particular reason *not* to qualify except that it's more
natural. In the Java world ( and many other programming languages that
support some notion of namespace ) familyName and lastName are *not*
considered to be part of the namespace, per se. They are local to the person
class. The person class *is* in the namespace but the fields are not.
Of course, provided your software is set up to do 'the right thing' then it
doesn't matter. Which is why I said I don't think you can call it either
way.
>
>
>
> And if you don't qualify familyName, then how can you distinguish that
familyName
> element from this familyName element?
>
> <x:mafiaCatalog xmlns:x="http://some.department.of.fbi.gov">
> <familyName> KAWAGUCHI </familyName>
> <area> Chicago </area>
> <description>
> ....
> </description>
> </x:mafiaCatalog>
>
> In the concept of XML namespace, I believe they are strictly identical
> elements because their namespace URI and their local name are the same.
> Why can you justify that such a mixture is OK if you can tell the
> difference from its ancestor?
If, and it's a *very* big if, I came across familyName in isolation then
you're right, I wouldn't know what to do with it. I would need to walk back
up the tree until I found a namespace qualified element that I recognized.
What's the big deal? This happens with attributes all the time.
The reason the 'if' is big is that with DOM using depth-first traversal or
SAX I will already have seen the namespace qualified element before I get to
familyName so I will know what the context is.
Cheers
Gudge