Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Getting elements II
Getting elements II [message #41573] Fri, 16 April 2004 20:33 Go to next message
Eclipse UserFriend
Originally posted by: adrian_andrei.sockeyesolutions.com

I would like to ask a follow-up question concerning the "attached" posting:
If I traverse xsd to construct the element list, I have to solve all schema
choice and derivation by myself, right ? The getContentType will just
expose
the above particles, isn't it!?

Subject: Re: Getting elements
From: merks@ca.ibm.com (Ed Merks)
Newsgroups: eclipse.technology.xsd
Organization: EclipseCorner
Date: Mar 02 2004 07:15:58
References: 1

Michael,

A complex type t only has a t.getContentType() which is a particle if
t.getContentTypeCategory() is element-only or mixed. A particle has a term
which may be an element, a wildcard or a model group, where a model group
has
more particles recursively. The root particle of a complex type will be a
sequence model group. There is no flat list of element declarations in the
complex type, there's only it's content model represented as a tree of
particles.


Michael Norton wrote:

> I must be looking at something completely wrong because this can't be that
> tough. I'm attempting to populate a tree viewer with the elements
> declared in a schema. I can use the getElementDeclarations method to
> retrieve global element(s), but how do I retrieve the elements from, say,
> a complex type global element? I've chased through particles and models,
> but can find no method equivalent to getElementDeclarations (or even
> getElementDeclaration) for these components. Can anyone set me on the
> right path?
>
Re: Getting elements II [message #41592 is a reply to message #41573] Fri, 16 April 2004 21:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Adrian,

I'm not really sure what you are asking. You'll need to walk the tree, but the
tree will contain particles that come from the base type, so you will not have
to take derivation into account. Choices, i.e., model groups with compositor
Choice, will appear in the tree as you walk it.


Adrian Andrei wrote:

> I would like to ask a follow-up question concerning the "attached" posting:
> If I traverse xsd to construct the element list, I have to solve all schema
> choice and derivation by myself, right ? The getContentType will just
> expose
> the above particles, isn't it!?
>
> Subject: Re: Getting elements
> From: merks@ca.ibm.com (Ed Merks)
> Newsgroups: eclipse.technology.xsd
> Organization: EclipseCorner
> Date: Mar 02 2004 07:15:58
> References: 1
>
> Michael,
>
> A complex type t only has a t.getContentType() which is a particle if
> t.getContentTypeCategory() is element-only or mixed. A particle has a term
> which may be an element, a wildcard or a model group, where a model group
> has
> more particles recursively. The root particle of a complex type will be a
> sequence model group. There is no flat list of element declarations in the
> complex type, there's only it's content model represented as a tree of
> particles.
>
> Michael Norton wrote:
>
> > I must be looking at something completely wrong because this can't be that
> > tough. I'm attempting to populate a tree viewer with the elements
> > declared in a schema. I can use the getElementDeclarations method to
> > retrieve global element(s), but how do I retrieve the elements from, say,
> > a complex type global element? I've chased through particles and models,
> > but can find no method equivalent to getElementDeclarations (or even
> > getElementDeclaration) for these components. Can anyone set me on the
> > right path?
> >
Re: Getting elements II [message #41627 is a reply to message #41592] Sat, 17 April 2004 00:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adrian_andrei.sockeyesolutions.com

Ed, thank you for your quick reply.

My case is as follows: I traverse&build a XML tree, and
when I arrive in a certain node I would like to see what
element I can insert as child from a list of candidates.
I would like to have those candidates picked up from the XML Schema.

Here is a small example:
For the schema snipet:
<xsd:complexType name="conditionalCase">
<xsd:complexContent>
<xsd:extension base="bpml:documented">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="condition"
type="bpml:condition" />
<xsd:group ref="bpml:activitySet" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

if I start from "conditionalCase" and I want to return the list
of elements from this type then
1. I have to find "documented" type element list
2. append a new element "condition" into it.

Right ? I was wondering if all this logic doesn't exist somewhere
in XSD...

Ed Merks wrote:

> Adrian,

> I'm not really sure what you are asking. You'll need to walk the tree, but
the
> tree will contain particles that come from the base type, so you will not
have
> to take derivation into account. Choices, i.e., model groups with
compositor
> Choice, will appear in the tree as you walk it.


> Adrian Andrei wrote:

> > I would like to ask a follow-up question concerning the "attached" posting:
> > If I traverse xsd to construct the element list, I have to solve all schema
> > choice and derivation by myself, right ? The getContentType will just
> > expose
> > the above particles, isn't it!?
> >
> > Subject: Re: Getting elements
> > From: merks@ca.ibm.com (Ed Merks)
> > Newsgroups: eclipse.technology.xsd
> > Organization: EclipseCorner
> > Date: Mar 02 2004 07:15:58
> > References: 1
> >
> > Michael,
> >
> > A complex type t only has a t.getContentType() which is a particle if
> > t.getContentTypeCategory() is element-only or mixed. A particle has a term
> > which may be an element, a wildcard or a model group, where a model group
> > has
> > more particles recursively. The root particle of a complex type will be a
> > sequence model group. There is no flat list of element declarations in the
> > complex type, there's only it's content model represented as a tree of
> > particles.
> >
> > Michael Norton wrote:
> >
> > > I must be looking at something completely wrong because this can't be
that
> > > tough. I'm attempting to populate a tree viewer with the elements
> > > declared in a schema. I can use the getElementDeclarations method to
> > > retrieve global element(s), but how do I retrieve the elements from, say,
> > > a complex type global element? I've chased through particles and models,
> > > but can find no method equivalent to getElementDeclarations (or even
> > > getElementDeclaration) for these components. Can anyone set me on the
> > > right path?
> > >
Re: Getting elements II [message #41645 is a reply to message #41627] Sat, 17 April 2004 13:40 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Adrian,

If you get the content type for "conditionalCase", you'll find it's a particle with
a sequence. The first particle of that sequence will refer to the content type of
"documented" and the second particle will refer to the sequence in
"conditional"case. That sequence's first particle will be the "condition" element
and the second particle will refer to the group defined by "activitySet". Try
loading your schema into the Sample XML Schema editor and expand "conditionalCase"
in the "Semantics" tab. You'll be able to see the whole logical particle tree
that's available...

You might find XSDParticle.getDFA useful for helping to produce an XML instance...

Adrian Andrei wrote:

> Ed, thank you for your quick reply.
>
> My case is as follows: I traverse&build a XML tree, and
> when I arrive in a certain node I would like to see what
> element I can insert as child from a list of candidates.
> I would like to have those candidates picked up from the XML Schema.
>
> Here is a small example:
> For the schema snipet:
> <xsd:complexType name="conditionalCase">
> <xsd:complexContent>
> <xsd:extension base="bpml:documented">
> <xsd:sequence>
> <xsd:element maxOccurs="1" minOccurs="0" name="condition"
> type="bpml:condition" />
> <xsd:group ref="bpml:activitySet" />
> </xsd:sequence>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> if I start from "conditionalCase" and I want to return the list
> of elements from this type then
> 1. I have to find "documented" type element list
> 2. append a new element "condition" into it.
>
> Right ? I was wondering if all this logic doesn't exist somewhere
> in XSD...
>
> Ed Merks wrote:
>
> > Adrian,
>
> > I'm not really sure what you are asking. You'll need to walk the tree, but
> the
> > tree will contain particles that come from the base type, so you will not
> have
> > to take derivation into account. Choices, i.e., model groups with
> compositor
> > Choice, will appear in the tree as you walk it.
>
> > Adrian Andrei wrote:
>
> > > I would like to ask a follow-up question concerning the "attached" posting:
> > > If I traverse xsd to construct the element list, I have to solve all schema
> > > choice and derivation by myself, right ? The getContentType will just
> > > expose
> > > the above particles, isn't it!?
> > >
> > > Subject: Re: Getting elements
> > > From: merks@ca.ibm.com (Ed Merks)
> > > Newsgroups: eclipse.technology.xsd
> > > Organization: EclipseCorner
> > > Date: Mar 02 2004 07:15:58
> > > References: 1
> > >
> > > Michael,
> > >
> > > A complex type t only has a t.getContentType() which is a particle if
> > > t.getContentTypeCategory() is element-only or mixed. A particle has a term
> > > which may be an element, a wildcard or a model group, where a model group
> > > has
> > > more particles recursively. The root particle of a complex type will be a
> > > sequence model group. There is no flat list of element declarations in the
> > > complex type, there's only it's content model represented as a tree of
> > > particles.
> > >
> > > Michael Norton wrote:
> > >
> > > > I must be looking at something completely wrong because this can't be
> that
> > > > tough. I'm attempting to populate a tree viewer with the elements
> > > > declared in a schema. I can use the getElementDeclarations method to
> > > > retrieve global element(s), but how do I retrieve the elements from, say,
> > > > a complex type global element? I've chased through particles and models,
> > > > but can find no method equivalent to getElementDeclarations (or even
> > > > getElementDeclaration) for these components. Can anyone set me on the
> > > > right path?
> > > >
Re: Getting elements II [message #585708 is a reply to message #41573] Fri, 16 April 2004 21:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31622
Registered: July 2009
Senior Member
Adrian,

I'm not really sure what you are asking. You'll need to walk the tree, but the
tree will contain particles that come from the base type, so you will not have
to take derivation into account. Choices, i.e., model groups with compositor
Choice, will appear in the tree as you walk it.


Adrian Andrei wrote:

> I would like to ask a follow-up question concerning the "attached" posting:
> If I traverse xsd to construct the element list, I have to solve all schema
> choice and derivation by myself, right ? The getContentType will just
> expose
> the above particles, isn't it!?
>
> Subject: Re: Getting elements
> From: merks@ca.ibm.com (Ed Merks)
> Newsgroups: eclipse.technology.xsd
> Organization: EclipseCorner
> Date: Mar 02 2004 07:15:58
> References: 1
>
> Michael,
>
> A complex type t only has a t.getContentType() which is a particle if
> t.getContentTypeCategory() is element-only or mixed. A particle has a term
> which may be an element, a wildcard or a model group, where a model group
> has
> more particles recursively. The root particle of a complex type will be a
> sequence model group. There is no flat list of element declarations in the
> complex type, there's only it's content model represented as a tree of
> particles.
>
> Michael Norton wrote:
>
> > I must be looking at something completely wrong because this can't be that
> > tough. I'm attempting to populate a tree viewer with the elements
> > declared in a schema. I can use the getElementDeclarations method to
> > retrieve global element(s), but how do I retrieve the elements from, say,
> > a complex type global element? I've chased through particles and models,
> > but can find no method equivalent to getElementDeclarations (or even
> > getElementDeclaration) for these components. Can anyone set me on the
> > right path?
> >


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting elements II [message #585725 is a reply to message #41592] Sat, 17 April 2004 00:14 Go to previous message
Eclipse UserFriend
Originally posted by: adrian_andrei.sockeyesolutions.com

Ed, thank you for your quick reply.

My case is as follows: I traverse&build a XML tree, and
when I arrive in a certain node I would like to see what
element I can insert as child from a list of candidates.
I would like to have those candidates picked up from the XML Schema.

Here is a small example:
For the schema snipet:
<xsd:complexType name="conditionalCase">
<xsd:complexContent>
<xsd:extension base="bpml:documented">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="condition"
type="bpml:condition" />
<xsd:group ref="bpml:activitySet" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

if I start from "conditionalCase" and I want to return the list
of elements from this type then
1. I have to find "documented" type element list
2. append a new element "condition" into it.

Right ? I was wondering if all this logic doesn't exist somewhere
in XSD...

Ed Merks wrote:

> Adrian,

> I'm not really sure what you are asking. You'll need to walk the tree, but
the
> tree will contain particles that come from the base type, so you will not
have
> to take derivation into account. Choices, i.e., model groups with
compositor
> Choice, will appear in the tree as you walk it.


> Adrian Andrei wrote:

> > I would like to ask a follow-up question concerning the "attached" posting:
> > If I traverse xsd to construct the element list, I have to solve all schema
> > choice and derivation by myself, right ? The getContentType will just
> > expose
> > the above particles, isn't it!?
> >
> > Subject: Re: Getting elements
> > From: merks@ca.ibm.com (Ed Merks)
> > Newsgroups: eclipse.technology.xsd
> > Organization: EclipseCorner
> > Date: Mar 02 2004 07:15:58
> > References: 1
> >
> > Michael,
> >
> > A complex type t only has a t.getContentType() which is a particle if
> > t.getContentTypeCategory() is element-only or mixed. A particle has a term
> > which may be an element, a wildcard or a model group, where a model group
> > has
> > more particles recursively. The root particle of a complex type will be a
> > sequence model group. There is no flat list of element declarations in the
> > complex type, there's only it's content model represented as a tree of
> > particles.
> >
> > Michael Norton wrote:
> >
> > > I must be looking at something completely wrong because this can't be
that
> > > tough. I'm attempting to populate a tree viewer with the elements
> > > declared in a schema. I can use the getElementDeclarations method to
> > > retrieve global element(s), but how do I retrieve the elements from, say,
> > > a complex type global element? I've chased through particles and models,
> > > but can find no method equivalent to getElementDeclarations (or even
> > > getElementDeclaration) for these components. Can anyone set me on the
> > > right path?
> > >
Re: Getting elements II [message #585738 is a reply to message #41627] Sat, 17 April 2004 13:40 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31622
Registered: July 2009
Senior Member
Adrian,

If you get the content type for "conditionalCase", you'll find it's a particle with
a sequence. The first particle of that sequence will refer to the content type of
"documented" and the second particle will refer to the sequence in
"conditional"case. That sequence's first particle will be the "condition" element
and the second particle will refer to the group defined by "activitySet". Try
loading your schema into the Sample XML Schema editor and expand "conditionalCase"
in the "Semantics" tab. You'll be able to see the whole logical particle tree
that's available...

You might find XSDParticle.getDFA useful for helping to produce an XML instance...

Adrian Andrei wrote:

> Ed, thank you for your quick reply.
>
> My case is as follows: I traverse&build a XML tree, and
> when I arrive in a certain node I would like to see what
> element I can insert as child from a list of candidates.
> I would like to have those candidates picked up from the XML Schema.
>
> Here is a small example:
> For the schema snipet:
> <xsd:complexType name="conditionalCase">
> <xsd:complexContent>
> <xsd:extension base="bpml:documented">
> <xsd:sequence>
> <xsd:element maxOccurs="1" minOccurs="0" name="condition"
> type="bpml:condition" />
> <xsd:group ref="bpml:activitySet" />
> </xsd:sequence>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> if I start from "conditionalCase" and I want to return the list
> of elements from this type then
> 1. I have to find "documented" type element list
> 2. append a new element "condition" into it.
>
> Right ? I was wondering if all this logic doesn't exist somewhere
> in XSD...
>
> Ed Merks wrote:
>
> > Adrian,
>
> > I'm not really sure what you are asking. You'll need to walk the tree, but
> the
> > tree will contain particles that come from the base type, so you will not
> have
> > to take derivation into account. Choices, i.e., model groups with
> compositor
> > Choice, will appear in the tree as you walk it.
>
> > Adrian Andrei wrote:
>
> > > I would like to ask a follow-up question concerning the "attached" posting:
> > > If I traverse xsd to construct the element list, I have to solve all schema
> > > choice and derivation by myself, right ? The getContentType will just
> > > expose
> > > the above particles, isn't it!?
> > >
> > > Subject: Re: Getting elements
> > > From: merks@ca.ibm.com (Ed Merks)
> > > Newsgroups: eclipse.technology.xsd
> > > Organization: EclipseCorner
> > > Date: Mar 02 2004 07:15:58
> > > References: 1
> > >
> > > Michael,
> > >
> > > A complex type t only has a t.getContentType() which is a particle if
> > > t.getContentTypeCategory() is element-only or mixed. A particle has a term
> > > which may be an element, a wildcard or a model group, where a model group
> > > has
> > > more particles recursively. The root particle of a complex type will be a
> > > sequence model group. There is no flat list of element declarations in the
> > > complex type, there's only it's content model represented as a tree of
> > > particles.
> > >
> > > Michael Norton wrote:
> > >
> > > > I must be looking at something completely wrong because this can't be
> that
> > > > tough. I'm attempting to populate a tree viewer with the elements
> > > > declared in a schema. I can use the getElementDeclarations method to
> > > > retrieve global element(s), but how do I retrieve the elements from, say,
> > > > a complex type global element? I've chased through particles and models,
> > > > but can find no method equivalent to getElementDeclarations (or even
> > > > getElementDeclaration) for these components. Can anyone set me on the
> > > > right path?
> > > >


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Getting elements II
Next Topic:Included Schema not resolved in WSDL?
Goto Forum:
  


Current Time: Sun Nov 29 00:17:41 GMT 2020

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

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

Back to the top