Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Inherited attributes
Inherited attributes [message #46846] Thu, 03 June 2004 09:57 Go to next message
Eclipse User
Originally posted by: invalid.soft-gems.net

Hi group,

Currently I'm trying to collect all attributes from a given type in my
schemas. Essentially, this is my code for this task:

EList xsdAttributes = complexType.getAttributeContents();
iterator = xsdAttributes.iterator();
while (iterator.hasNext())
{
XSDAttributeUse attributeContent = (XSDAttributeUse) iterator.next();
XMLAttribute attribute = new XMLAttribute(this, attributeContent);
attributes.add(attribute);
}

Here is an element I'm trying to analyze:

<xs:element name="page" substitutionGroup="odie:tableGroup">
<xs:complexType>
<xs:complexContent>
<xs:extension base="odie:tableType">
<xs:attribute name="cols" type="xs:positiveInteger"
default="80"/>
<xs:attribute name="rows" type="xs:positiveInteger"
default="20"/>
<xs:attribute name="id" type="xs:positiveInteger"
use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

My problem is that only the 3 here declared attributes are returned by the
above code. In the base type there are more attributes, which I also need.
Is there a single call to get all effective attributes of a given type?

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #46876 is a reply to message #46846] Thu, 03 June 2004 10:05 Go to previous messageGo to next message
Eclipse User
Originally posted by: invalid.soft-gems.net

Mike Lischke wrote:

> My problem is that only the 3 here declared attributes are returned by the
> above code. In the base type there are more attributes, which I also need.
> Is there a single call to get all effective attributes of a given type?

I think the answer is complexType.getAttributeUses(). The documentation
really needs some improvement.

Thank you for reading, anyway.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #46903 is a reply to message #46876] Thu, 03 June 2004 10:52 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Mike,

I see you figured this out in 8 minutes. Probably you read the Javadoc to look
for useful methods. ;-)


Mike Lischke wrote:

> Mike Lischke wrote:
>
> > My problem is that only the 3 here declared attributes are returned by the
> > above code. In the base type there are more attributes, which I also need.
> > Is there a single call to get all effective attributes of a given type?
>
> I think the answer is complexType.getAttributeUses(). The documentation
> really needs some improvement.
>
> Thank you for reading, anyway.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #47085 is a reply to message #46903] Thu, 03 June 2004 17:59 Go to previous messageGo to next message
Eclipse User
Originally posted by: invalid.soft-gems.net

Ed Merks wrote

>I see you figured this out in 8 minutes. Probably you read the Javadoc
to look
>for useful methods. ;-)

;-) It would be cool it would have been so. No, I tried about 2 hours
before I dared to post a question to the newsgroup (I simply did not
realize the other method). I'm maintaing a bunch of private news groups
myself and have a web forum too, so I know what it means to bother others
with beginners questions. Unfortunately, I can't stop it entirely...

Btw: a related question, why can I get all inherited attributes but not
all inherited particles? Currently I'm going through all base types
recursively to find all elements.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #47113 is a reply to message #47085] Thu, 03 June 2004 18:25 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Mike,

I know that the documentation could be a lot less sparse, but there's never
time to make it less sparse. So I don't mind answering questions...

The XSDComplexTypeDefinition.getContentType() method, for the case of
non-empty complex content, will return a particle that represents the whole
content model. In general, you should look for methods that say they
represent an "infoset property" as these represent things from the abstract
component model as defined in the XML Schema spec and are typically things
that are computed from the concrete syntax (i.e., the methods that say they
are "concrete").


Mike Lischke wrote:

> Ed Merks wrote
>
> >I see you figured this out in 8 minutes. Probably you read the Javadoc
> to look
> >for useful methods. ;-)
>
> ;-) It would be cool it would have been so. No, I tried about 2 hours
> before I dared to post a question to the newsgroup (I simply did not
> realize the other method). I'm maintaing a bunch of private news groups
> myself and have a web forum too, so I know what it means to bother others
> with beginners questions. Unfortunately, I can't stop it entirely...
>
> Btw: a related question, why can I get all inherited attributes but not
> all inherited particles? Currently I'm going through all base types
> recursively to find all elements.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #47217 is a reply to message #47113] Fri, 04 June 2004 10:44 Go to previous messageGo to next message
Eclipse User
Originally posted by: invalid.soft-gems.net

Ed Merks wrote:

> The XSDComplexTypeDefinition.getContentType() method, for the case of
> non-empty complex content, will return a particle that represents the whole
> content model.

This does not work. I used this code:

XSDComplexTypeContent content = complexType.getContentType();
if (content instanceof XSDParticle)
{
XSDParticle contentParticle = (XSDParticle) content;
XSDModelGroup group = (XSDModelGroup) contentParticle.getTerm();

compositor = group.getCompositor().getValue();
EList xsdParticles = group.getContents();
Iterator iterator = xsdParticles.iterator();
while (iterator.hasNext())
{
XSDParticle xsdParticle = (XSDParticle) iterator.next();
XMLParticle particle = new XMLParticle(this, xsdParticle);
particles.add(particle);
}
}

and do not get *any* particle for a complex type like:

<xs:complexType name="controlType_combobox">
<xs:complexContent>
<xs:extension base="controlType_text_focusable">
<xs:sequence>
<xs:element name="itemlist" minOccurs="0">
<xs:complexType>
<xs:choice>
<xs:element ref="datasource"/>
<xs:sequence>
<xs:element name="key" type="datasourceType"/>
<xs:element name="value" type="datasourceType"/>
</xs:sequence>
</xs:choice>
<xs:attribute name="rows" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

while the recursive approach collects all particles correctly.

>In general, you should look for methods that say they
> represent an "infoset property" as these represent things from the abstract
> component model as defined in the XML Schema spec and are typically things
> that are computed from the concrete syntax (i.e., the methods that say they
> are "concrete").

This is interesting information. I thought already it must have been
something along this line but didn't bring this thought to an end. It is
generally difficult for me to find time to dive into theoretic stuff like
the info set model or any formal description. I have to learn the matter
while I'm writing products.

Thank you very much.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #47235 is a reply to message #47217] Fri, 04 June 2004 11:11 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Mike,

XSDModelGroup.getContents is a concrete property and you are calling it on a
synthesized model group that does not populate that property. That model group
acts as a logical parent for the local content model and the inherited content
model. Use XSDModelGroup.getParticles, which is the infoset property.


Mike Lischke wrote:

> Ed Merks wrote:
>
> > The XSDComplexTypeDefinition.getContentType() method, for the case of
> > non-empty complex content, will return a particle that represents the whole
> > content model.
>
> This does not work. I used this code:
>
> XSDComplexTypeContent content = complexType.getContentType();
> if (content instanceof XSDParticle)
> {
> XSDParticle contentParticle = (XSDParticle) content;
> XSDModelGroup group = (XSDModelGroup) contentParticle.getTerm();
>
> compositor = group.getCompositor().getValue();
> EList xsdParticles = group.getContents();
> Iterator iterator = xsdParticles.iterator();
> while (iterator.hasNext())
> {
> XSDParticle xsdParticle = (XSDParticle) iterator.next();
> XMLParticle particle = new XMLParticle(this, xsdParticle);
> particles.add(particle);
> }
> }
>
> and do not get *any* particle for a complex type like:
>
> <xs:complexType name="controlType_combobox">
> <xs:complexContent>
> <xs:extension base="controlType_text_focusable">
> <xs:sequence>
> <xs:element name="itemlist" minOccurs="0">
> <xs:complexType>
> <xs:choice>
> <xs:element ref="datasource"/>
> <xs:sequence>
> <xs:element name="key" type="datasourceType"/>
> <xs:element name="value" type="datasourceType"/>
> </xs:sequence>
> </xs:choice>
> <xs:attribute name="rows" type="xs:positiveInteger"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> while the recursive approach collects all particles correctly.
>
> >In general, you should look for methods that say they
> > represent an "infoset property" as these represent things from the abstract
> > component model as defined in the XML Schema spec and are typically things
> > that are computed from the concrete syntax (i.e., the methods that say they
> > are "concrete").
>
> This is interesting information. I thought already it must have been
> something along this line but didn't bring this thought to an end. It is
> generally difficult for me to find time to dive into theoretic stuff like
> the info set model or any formal description. I have to learn the matter
> while I'm writing products.
>
> Thank you very much.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #47265 is a reply to message #47235] Fri, 04 June 2004 18:40 Go to previous messageGo to next message
Eclipse User
Originally posted by: invalid.soft-gems.net

Ed Merks wrote

>Use XSDModelGroup.getParticles, which is the infoset property.

Thank you Ed, I'll try this out on monday. Btw: have you ever had a vague
feeling that the API is unnessecarily complex ;-) ?

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #47285 is a reply to message #47265] Fri, 04 June 2004 18:57 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Mike,

Yes, I've often had the distinct feeling that XML Schema is unnecessarily
complex, and as the expression goes, it's very difficult to make a silk purse
out of a sow's ear...


Mike Lischke wrote:

> Ed Merks wrote
>
> >Use XSDModelGroup.getParticles, which is the infoset property.
>
> Thank you Ed, I'll try this out on monday. Btw: have you ever had a vague
> feeling that the API is unnessecarily complex ;-) ?
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #588022 is a reply to message #46846] Thu, 03 June 2004 10:05 Go to previous message
Mike Lischke is currently offline Mike Lischke
Messages: 78
Registered: July 2009
Member
Mike Lischke wrote:

> My problem is that only the 3 here declared attributes are returned by the
> above code. In the base type there are more attributes, which I also need.
> Is there a single call to get all effective attributes of a given type?

I think the answer is complexType.getAttributeUses(). The documentation
really needs some improvement.

Thank you for reading, anyway.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #588035 is a reply to message #46876] Thu, 03 June 2004 10:52 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Mike,

I see you figured this out in 8 minutes. Probably you read the Javadoc to look
for useful methods. ;-)


Mike Lischke wrote:

> Mike Lischke wrote:
>
> > My problem is that only the 3 here declared attributes are returned by the
> > above code. In the base type there are more attributes, which I also need.
> > Is there a single call to get all effective attributes of a given type?
>
> I think the answer is complexType.getAttributeUses(). The documentation
> really needs some improvement.
>
> Thank you for reading, anyway.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #588108 is a reply to message #46903] Thu, 03 June 2004 17:59 Go to previous message
Mike Lischke is currently offline Mike Lischke
Messages: 78
Registered: July 2009
Member
Ed Merks wrote

>I see you figured this out in 8 minutes. Probably you read the Javadoc
to look
>for useful methods. ;-)

;-) It would be cool it would have been so. No, I tried about 2 hours
before I dared to post a question to the newsgroup (I simply did not
realize the other method). I'm maintaing a bunch of private news groups
myself and have a web forum too, so I know what it means to bother others
with beginners questions. Unfortunately, I can't stop it entirely...

Btw: a related question, why can I get all inherited attributes but not
all inherited particles? Currently I'm going through all base types
recursively to find all elements.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #588119 is a reply to message #47085] Thu, 03 June 2004 18:25 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Mike,

I know that the documentation could be a lot less sparse, but there's never
time to make it less sparse. So I don't mind answering questions...

The XSDComplexTypeDefinition.getContentType() method, for the case of
non-empty complex content, will return a particle that represents the whole
content model. In general, you should look for methods that say they
represent an "infoset property" as these represent things from the abstract
component model as defined in the XML Schema spec and are typically things
that are computed from the concrete syntax (i.e., the methods that say they
are "concrete").


Mike Lischke wrote:

> Ed Merks wrote
>
> >I see you figured this out in 8 minutes. Probably you read the Javadoc
> to look
> >for useful methods. ;-)
>
> ;-) It would be cool it would have been so. No, I tried about 2 hours
> before I dared to post a question to the newsgroup (I simply did not
> realize the other method). I'm maintaing a bunch of private news groups
> myself and have a web forum too, so I know what it means to bother others
> with beginners questions. Unfortunately, I can't stop it entirely...
>
> Btw: a related question, why can I get all inherited attributes but not
> all inherited particles? Currently I'm going through all base types
> recursively to find all elements.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #588164 is a reply to message #47113] Fri, 04 June 2004 10:44 Go to previous message
Mike Lischke is currently offline Mike Lischke
Messages: 78
Registered: July 2009
Member
Ed Merks wrote:

> The XSDComplexTypeDefinition.getContentType() method, for the case of
> non-empty complex content, will return a particle that represents the whole
> content model.

This does not work. I used this code:

XSDComplexTypeContent content = complexType.getContentType();
if (content instanceof XSDParticle)
{
XSDParticle contentParticle = (XSDParticle) content;
XSDModelGroup group = (XSDModelGroup) contentParticle.getTerm();

compositor = group.getCompositor().getValue();
EList xsdParticles = group.getContents();
Iterator iterator = xsdParticles.iterator();
while (iterator.hasNext())
{
XSDParticle xsdParticle = (XSDParticle) iterator.next();
XMLParticle particle = new XMLParticle(this, xsdParticle);
particles.add(particle);
}
}

and do not get *any* particle for a complex type like:

<xs:complexType name="controlType_combobox">
<xs:complexContent>
<xs:extension base="controlType_text_focusable">
<xs:sequence>
<xs:element name="itemlist" minOccurs="0">
<xs:complexType>
<xs:choice>
<xs:element ref="datasource"/>
<xs:sequence>
<xs:element name="key" type="datasourceType"/>
<xs:element name="value" type="datasourceType"/>
</xs:sequence>
</xs:choice>
<xs:attribute name="rows" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

while the recursive approach collects all particles correctly.

>In general, you should look for methods that say they
> represent an "infoset property" as these represent things from the abstract
> component model as defined in the XML Schema spec and are typically things
> that are computed from the concrete syntax (i.e., the methods that say they
> are "concrete").

This is interesting information. I thought already it must have been
something along this line but didn't bring this thought to an end. It is
generally difficult for me to find time to dive into theoretic stuff like
the info set model or any formal description. I have to learn the matter
while I'm writing products.

Thank you very much.

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #588176 is a reply to message #47217] Fri, 04 June 2004 11:11 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Mike,

XSDModelGroup.getContents is a concrete property and you are calling it on a
synthesized model group that does not populate that property. That model group
acts as a logical parent for the local content model and the inherited content
model. Use XSDModelGroup.getParticles, which is the infoset property.


Mike Lischke wrote:

> Ed Merks wrote:
>
> > The XSDComplexTypeDefinition.getContentType() method, for the case of
> > non-empty complex content, will return a particle that represents the whole
> > content model.
>
> This does not work. I used this code:
>
> XSDComplexTypeContent content = complexType.getContentType();
> if (content instanceof XSDParticle)
> {
> XSDParticle contentParticle = (XSDParticle) content;
> XSDModelGroup group = (XSDModelGroup) contentParticle.getTerm();
>
> compositor = group.getCompositor().getValue();
> EList xsdParticles = group.getContents();
> Iterator iterator = xsdParticles.iterator();
> while (iterator.hasNext())
> {
> XSDParticle xsdParticle = (XSDParticle) iterator.next();
> XMLParticle particle = new XMLParticle(this, xsdParticle);
> particles.add(particle);
> }
> }
>
> and do not get *any* particle for a complex type like:
>
> <xs:complexType name="controlType_combobox">
> <xs:complexContent>
> <xs:extension base="controlType_text_focusable">
> <xs:sequence>
> <xs:element name="itemlist" minOccurs="0">
> <xs:complexType>
> <xs:choice>
> <xs:element ref="datasource"/>
> <xs:sequence>
> <xs:element name="key" type="datasourceType"/>
> <xs:element name="value" type="datasourceType"/>
> </xs:sequence>
> </xs:choice>
> <xs:attribute name="rows" type="xs:positiveInteger"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> while the recursive approach collects all particles correctly.
>
> >In general, you should look for methods that say they
> > represent an "infoset property" as these represent things from the abstract
> > component model as defined in the XML Schema spec and are typically things
> > that are computed from the concrete syntax (i.e., the methods that say they
> > are "concrete").
>
> This is interesting information. I thought already it must have been
> something along this line but didn't bring this thought to an end. It is
> generally difficult for me to find time to dive into theoretic stuff like
> the info set model or any formal description. I have to learn the matter
> while I'm writing products.
>
> Thank you very much.
>
> Mike
> --
> www.soft-gems.net
Re: Inherited attributes [message #588187 is a reply to message #47235] Fri, 04 June 2004 18:40 Go to previous message
Mike Lischke is currently offline Mike Lischke
Messages: 78
Registered: July 2009
Member
Ed Merks wrote

>Use XSDModelGroup.getParticles, which is the infoset property.

Thank you Ed, I'll try this out on monday. Btw: have you ever had a vague
feeling that the API is unnessecarily complex ;-) ?

Mike
--
www.soft-gems.net
Re: Inherited attributes [message #588199 is a reply to message #47265] Fri, 04 June 2004 18:57 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26138
Registered: July 2009
Senior Member
Mike,

Yes, I've often had the distinct feeling that XML Schema is unnecessarily
complex, and as the expression goes, it's very difficult to make a silk purse
out of a sow's ear...


Mike Lischke wrote:

> Ed Merks wrote
>
> >Use XSDModelGroup.getParticles, which is the infoset property.
>
> Thank you Ed, I'll try this out on monday. Btw: have you ever had a vague
> feeling that the API is unnessecarily complex ;-) ?
>
> Mike
> --
> www.soft-gems.net
Previous Topic:maxLength not permitted in string
Next Topic:Training on Eclipse
Goto Forum:
  


Current Time: Fri Oct 24 10:34:16 GMT 2014

Powered by FUDForum. Page generated in 0.02320 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software