Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Analysing Complex Types derived by extension
Analysing Complex Types derived by extension [message #54850] Fri, 19 November 2004 14:55 Go to next message
Eclipse UserFriend
Originally posted by: none.nonet.com

Hi there,

I'm having a problem analysing a complex type hierarchy using the API -
below are the complex type definitions I'm using. As you can see,
USAddress derives from Address, and NYAddress derives from USAddress.

The problem I'm encountering is when analysing a derived complex type. In
the attribute uses, I get all the attributes from the subtype and its base
type(s). However, as far as element declarations go, I only get the ones
from this particular type - which in the case of the NY address is none.
To get these I have to look at the base type definitions.

This seems fair enough in some ways, but the fact that the attributes do
appear in the attribute uses list seems to contradict this approach. Does
anyone have any ideas why this approach has been taken, or is it a flaw?

<xs:complexType name="Address">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
<xs:attribute name="Person" type="xs:string"/>
</xs:complexType>

<xs:complexType name="USAddress">
<xs:complexContent>
<xs:extension base="Address">
<xs:sequence>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:string"/>
</xs:sequence>
<xs:attribute name="Surname" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="NYAddress">
<xs:complexContent>
<xs:extension base="USAddress">
<xs:attribute name="RentControlled" type="xs:boolean"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>


Many thanks for your help,

Ray
Re: Analysing Complex Types derived by extension [message #54877 is a reply to message #54850] Fri, 19 November 2004 15:21 Go to previous messageGo to next message
Klaas Dellschaft is currently offline Klaas DellschaftFriend
Messages: 58
Registered: July 2009
Member
> The problem I'm encountering is when analysing a derived complex type. In
> the attribute uses, I get all the attributes from the subtype and its base
> type(s). However, as far as element declarations go, I only get the ones
> from this particular type - which in the case of the NY address is none.
> To get these I have to look at the base type definitions.

Do you use XSDComplexTypeDefinition#getContentType() or
XSDComplexTypeDefinition#getContent()? The first method is should be the
correct for getting also the derived elements. With the second method you
will only get the elements defined at the current complexType.

Cheers
Klaas
Re: Analysing Complex Types derived by extension [message #54904 is a reply to message #54850] Fri, 19 November 2004 15:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Ray,

Given an XSDComplexTypeDefinition x (with complex content),
x.getContentType() will give you the complete content particle,
including anything inherited from the base type, whereas x.getContent()
will give you only the physically contained particle with only the
locally declared content. Similarly, x.getAttributeUses() returns all
the inherited and local attributes, but x.getAttributeContents() returns
only the locally declared ones. I.e., you can view the model either
abstractly or concretely and abstract properties will say something like
"This represents the ... infoset property" whereas concrete properties
will say something like "This concrete reference represents ...". Be
sure to choose the one appropriate for what you are trying to do...


Ray wrote:

> Hi there,
>
> I'm having a problem analysing a complex type hierarchy using the API
> - below are the complex type definitions I'm using. As you can see,
> USAddress derives from Address, and NYAddress derives from USAddress.
>
> The problem I'm encountering is when analysing a derived complex type.
> In the attribute uses, I get all the attributes from the subtype and
> its base type(s). However, as far as element declarations go, I only
> get the ones from this particular type - which in the case of the NY
> address is none. To get these I have to look at the base type
> definitions.
> This seems fair enough in some ways, but the fact that the attributes
> do appear in the attribute uses list seems to contradict this
> approach. Does anyone have any ideas why this approach has been taken,
> or is it a flaw?
>
> <xs:complexType name="Address">
> <xs:sequence>
> <xs:element name="name" type="xs:string"/>
> <xs:element name="street" type="xs:string"/>
> <xs:element name="city" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="Person" type="xs:string"/>
> </xs:complexType>
>
> <xs:complexType name="USAddress">
> <xs:complexContent>
> <xs:extension base="Address">
> <xs:sequence>
> <xs:element name="state" type="xs:string"/>
> <xs:element name="zip" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="Surname" type="xs:string"/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:complexType name="NYAddress">
> <xs:complexContent>
> <xs:extension base="USAddress">
> <xs:attribute name="RentControlled" type="xs:boolean"/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
>
> Many thanks for your help,
>
> Ray
>
Re: Analysing Complex Types derived by extension [message #54930 is a reply to message #54904] Fri, 19 November 2004 17:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.nonet.com

Ed Merks wrote:

> Ray,

> Given an XSDComplexTypeDefinition x (with complex content),
> x.getContentType() will give you the complete content particle,
> including anything inherited from the base type, whereas x.getContent()
> will give you only the physically contained particle with only the
> locally declared content. Similarly, x.getAttributeUses() returns all
> the inherited and local attributes, but x.getAttributeContents() returns
> only the locally declared ones. I.e., you can view the model either
> abstractly or concretely and abstract properties will say something like
> "This represents the ... infoset property" whereas concrete properties
> will say something like "This concrete reference represents ...". Be
> sure to choose the one appropriate for what you are trying to do...


Thanks for your help both of you. Unfortunately while what you say holds
true for attributes (AttributeUses returns all, AttributeContents only
local), i find that for elements, while x.GetContent does contain the the
local ones, x.GetContentType is empty - it doesn't even contain the local
declarations.

I'm using XSD 2.0.1 if thats of any help....

Thanks again for your help - you've helped me understand the API better
certainly.

Ray
Re: Analysing Complex Types derived by extension [message #54961 is a reply to message #54930] Fri, 19 November 2004 18:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------020404030308060305090703
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ray,

For this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:exa="http://www.example.com/ExampleA"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/ExampleA">

<xsd:element name="a" type="exa:A"/>

<xsd:complexType name="A">
<xsd:sequence>
<xsd:element name="ae" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="aa" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="B">
<xsd:complexContent>
<xsd:extension base="exa:A">
<xsd:sequence>
<xsd:element name="be" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="ba" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

</xsd:schema>

I'd expect to see results like this in the Sample XML Schema Editor:

Note the content type is not null and the Semantics view shows how it's
a sequence that combines the local sequence and that of the base type.

I'm not sure what you've tried to do...


Ray wrote:

> Ed Merks wrote:
>
>> Ray,
>
>
>> Given an XSDComplexTypeDefinition x (with complex content),
>> x.getContentType() will give you the complete content particle,
>> including anything inherited from the base type, whereas
>> x.getContent() will give you only the physically contained particle
>> with only the locally declared content. Similarly,
>> x.getAttributeUses() returns all the inherited and local attributes,
>> but x.getAttributeContents() returns only the locally declared ones.
>> I.e., you can view the model either abstractly or concretely and
>> abstract properties will say something like "This represents the ...
>> infoset property" whereas concrete properties will say something like
>> "This concrete reference represents ...". Be sure to choose the one
>> appropriate for what you are trying to do...
>
>
>
> Thanks for your help both of you. Unfortunately while what you say
> holds true for attributes (AttributeUses returns all,
> AttributeContents only local), i find that for elements, while
> x.GetContent does contain the the local ones, x.GetContentType is
> empty - it doesn't even contain the local declarations.
>
> I'm using XSD 2.0.1 if thats of any help....
>
> Thanks again for your help - you've helped me understand the API
> better certainly.
> Ray
>


--------------020404030308060305090703
Content-Type: multipart/related;
boundary="------------080603050704010309070905"


--------------080603050704010309070905
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ray,<br>
<br>
For this schema:<br>
<blockquote><tt><small>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</small><br>
<small>&lt;xsd:schema </small><br>
<small>
Re: Analysing Complex Types derived by extension [message #55089 is a reply to message #54961] Tue, 23 November 2004 15:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.nonet.com

> Note the content type is not null and the Semantics view shows how it's a
> sequence that combines the local sequence and that of the base type. I'm
> not sure what you've tried to do..

Sorry for delay in responding - Indeed I was looking in the wrong place to
begin with, but your comments have pointed me to the right direction. When
analysing the subsequent XSDModelGroupDefinition, I was getting its
contents, and not its 'particles'. Once i got this list, i was able to look
through and find all the elements required. Thanks very much for your help!

Ray
Re: Analysing Complex Types derived by extension [message #62340 is a reply to message #55089] Tue, 05 July 2005 16:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

Hi all,
I have read this post, and I think I have a similar problem. I'm trying to
analize some complexType like the following one:

<complexType name="ScaleMapDefinition">
<complexContent>
<extension base="tns1:MapDefinitionType">
<sequence>
<element name="centerPoint" nillable="true"
type="tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the
complexType):

xsdModelGroup = (XSDModelGroup)
targetComplexDefinition.getComplexType().getContent();
listOfElements = xsdModelGroup.getContents();

Iterator elementsIterator = listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
XSDElementDeclaration element =
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it doesn't
works when I manage a complexType with an "extension" tag. Can someone
explain me way? There is any way to access to all the elements of the
complexType (including those coming from the "extension")?. Sorry if this
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi
Re: Analysing Complex Types derived by extension [message #62364 is a reply to message #62340] Tue, 05 July 2005 16:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------060405030508050601030404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

The getContent method returns the particle (for the model group)
physically present in that type definition. The getContentType returns
the logical/synthetic particle (if the type has complex content) and
that logical particle has a model group (sequence) that will include a
particle for the base class's contents and a particle for the content
contributed locally.


Fran wrote:

>Hi all,
>I have read this post, and I think I have a similar problem. I'm trying to
>analize some complexType like the following one:
>
> <complexType name="ScaleMapDefinition">
> <complexContent>
> <extension base="tns1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" nillable="true"
>type="tns3:GeoCoordinates"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
>I was using this code ("targetComplexDefinition" variable contains the
>complexType):
>
> xsdModelGroup = (XSDModelGroup)
>targetComplexDefinition.getComplexType().getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
>(XSDElementDeclaration)elementParticle.getContent();
> ...........
>
>It works when my complexType doesn't have an "extension" tag, but it doesn't
>works when I manage a complexType with an "extension" tag. Can someone
>explain me way? There is any way to access to all the elements of the
>complexType (including those coming from the "extension")?. Sorry if this
>question is so simple. But I really don't find how to do it.
>Thanks in advance,
>Fran
>
>
>"Ray" <none@nonet.com> escribi
Re: Analysing Complex Types derived by extension [message #62388 is a reply to message #62364] Tue, 05 July 2005 17:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0157_01C58191.962F2400
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Ed,
I have tried to do something like this:
=20
XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
.............


Now, I use "getContentType", and from the particle, I try to retrieve
the sequence, in order to access to the "base" particle and the
"local" particle. But I recover wrong information. Do you know what=20
am I doing wrong?
Thank you very mucho for your help,
Fran
=20
Fran,

The getContent method returns the particle (for the model group) =
physically present in that type definition. The getContentType returns =
the logical/synthetic particle (if the type has complex content) and =
that logical particle has a model group (sequence) that will include a =
particle for the base class's contents and a particle for the content =
contributed locally.


Fran wrote:=20
Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi=F3 en el mensaje=20
news:cnvmsa$kft$1@www.eclipse.org...
Note the content type is not null and the Semantics view shows how =
it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
Sorry for delay in responding - Indeed I was looking in the wrong =
place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


=20

=20

------=_NextPart_000_0157_01C58191.962F2400
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have tried to do something like=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDParticle)=20
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial size=3D2>
<DIV><BR>&nbsp;&nbsp;Iterator elementsIterator =3D=20
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp; XSDParticle elementParticle =3D </DIV>
<DIV> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(XSDParticle)=20
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;XSDElementDeclaratio n=
=20
element =3D </DIV>
<DIV> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;.............</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Now, I&nbsp;use&nbsp;"getContentType", and from the&nbsp;particle, =
I try to=20
retrieve</DIV>
<DIV>the&nbsp;sequence, in order to&nbsp;access to the&nbsp;"base" =
particle and=20
the</DIV>
<DIV>"local" particle. But I recover wrong information.&nbsp;Do you know =
what=20
</DIV>
<DIV>am I doing&nbsp;wrong?</DIV>
<DIV>Thank you very mucho for your help,</DIV>
<DIV>Fran<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT ></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>The=20
getContent method returns the particle (for the model group) =
physically=20
present in that type definition.&nbsp; The getContentType returns the=20
logical/synthetic particle (if the type has complex content) and that =
logical=20
particle has a model group (sequence) that will include a particle for =
the=20
base class's contents and a particle for the content contributed=20
locally.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaeb7o$ovn$1@news.eclipse.org type=3D"cite"><PRE =
wrap=3D"">Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

&lt;complexType name=3D"ScaleMapDefinition"&gt;
&lt;complexContent&gt;
&lt;extension base=3D"tns1:MapDefinitionType"&gt;
&lt;sequence&gt;
&lt;element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/&gt;
&lt;/sequence&gt;
&lt;/extension&gt;
&lt;/complexContent&gt;
&lt;/complexType&gt;

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:none@nonet.com">&lt;none@nonet.com&gt;</A> escribi=F3 en =
el mensaje=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:cnvmsa$kft$1@www.eclipse.org">news:cnvmsa$kft$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Note the content type is =
not null and the Semantics view shows how it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
</PRE></BLOCKQUOTE><PRE wrap=3D"">Sorry for delay in responding - =
Indeed I was looking in the wrong place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0157_01C58191.962F2400--
Re: Analysing Complex Types derived by extension [message #62412 is a reply to message #62388] Tue, 05 July 2005 17:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------040608040103060607030300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

I would imagine that you will get class cast exceptions because the
particles of the top level synthetic particle can refer to XSDModelGroup
(or XSDWildcard) not just XSDElementDeclaration. Only the top level
particle's content is guaranteed to be an XSDModelGroup; everywhere else
you'd better be prepared to deal with the more general cases. I think
you really need a recursive algorithm to do this properly.


Fran wrote:

> Hi Ed,
> I have tried to do something like this:
>
> XSDParticle complexTypeContent =
> (XSDParticle) targetComplexDefinition.getContentType();
> XSDModelGroup xsdModelGroup =
> (XSDModelGroup)complexTypeContent.getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> XSDParticle elementParticle =
> (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
> (XSDElementDeclaration)elementParticle.getContent();
> .............
>
>
> Now, I use "getContentType", and from the particle, I try to retrieve
> the sequence, in order to access to the "base" particle and the
> "local" particle. But I recover wrong information. Do you know what
> am I doing wrong?
> Thank you very mucho for your help,
> Fran
>
>
> Fran,
>
> The getContent method returns the particle (for the model group)
> physically present in that type definition. The getContentType
> returns the logical/synthetic particle (if the type has complex
> content) and that logical particle has a model group (sequence)
> that will include a particle for the base class's contents and a
> particle for the content contributed locally.
>
>
> Fran wrote:
>
>>Hi all,
>>I have read this post, and I think I have a similar problem. I'm trying to
>>analize some complexType like the following one:
>>
>> <complexType name="ScaleMapDefinition">
>> <complexContent>
>> <extension base="tns1:MapDefinitionType">
>> <sequence>
>> <element name="centerPoint" nillable="true"
>>type="tns3:GeoCoordinates"/>
>> </sequence>
>> </extension>
>> </complexContent>
>> </complexType>
>>
>>I was using this code ("targetComplexDefinition" variable contains the
>>complexType):
>>
>> xsdModelGroup = (XSDModelGroup)
>>targetComplexDefinition.getComplexType().getContent();
>> listOfElements = xsdModelGroup.getContents();
>>
>> Iterator elementsIterator = listOfElements.iterator();
>> while(elementsIterator.hasNext())
>> {
>> XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
>> XSDElementDeclaration element =
>>(XSDElementDeclaration)elementParticle.getContent();
>> ...........
>>
>>It works when my complexType doesn't have an "extension" tag, but it doesn't
>>works when I manage a complexType with an "extension" tag. Can someone
>>explain me way? There is any way to access to all the elements of the
>>complexType (including those coming from the "extension")?. Sorry if this
>>question is so simple. But I really don't find how to do it.
>>Thanks in advance,
>>Fran
>>
>>
>>"Ray" <none@nonet.com> escribi
Re: Analysing Complex Types derived by extension [message #62436 is a reply to message #62412] Tue, 05 July 2005 18:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0164_01C58197.809943E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi again Ed,
I will try to explain with more detail the results I obtain. I'm using =
this code in an recursive method and it works for all the <complexType> =
elements without problems, except for the ones including an <extension> =
tag.
Now, l will try to trace for you the execution of the program:

Step 1. As input, the complexType "targetComplexDefinition"=20
is the following:
<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

Step 2. The program proceed without error until the arrow I have writen:

XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
------> XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();

Step 3. And then, and suddendly, the input of the method =
(targetComplexDefinition)
(you can see at step 1) changes to the following value:

<complexType name=3D"MapRequest">
<sequence>
<element name=3D"itiTrace" nillable=3D"true" =
type=3D"tns2:ItineraryTrace"/>
<element name=3D"mapDefinition" nillable=3D"true" =
type=3D"tns1:ScaleMapDefinition"/>
</sequence>
</complexType>

As you see, this complexType contains an element called =
"tns1:ScaleMapDefinition", which
is the original input.
Believe me. I really don't understand what's happen... I hope this post =
would be clear enough=20
so you could help me.
Thank you very much,
Fran
--=20
__________________________________________

Francisco Sanchez Cid, Research Assistant
Department of Computing
City University
Northampton Square, London, EC1V 0HB
e-mail: F.Sanchez-Cid@soi.city.ac.uk
T (+44) 020 7040 4042
F (+44) 020 7040 0244
__________________________________________
"Ed Merks" <merks@ca.ibm.com> escribi=F3 en el mensaje =
news:daeha7$1cl$1@news.eclipse.org...
Fran,

I would imagine that you will get class cast exceptions because the =
particles of the top level synthetic particle can refer to XSDModelGroup =
(or XSDWildcard) not just XSDElementDeclaration. Only the top level =
particle's content is guaranteed to be an XSDModelGroup; everywhere else =
you'd better be prepared to deal with the more general cases. I think =
you really need a recursive algorithm to do this properly.
=20

Fran wrote:=20
Hi Ed,
I have tried to do something like this:
=20
XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
.............


Now, I use "getContentType", and from the particle, I try to =
retrieve
the sequence, in order to access to the "base" particle and the
"local" particle. But I recover wrong information. Do you know what=20
am I doing wrong?
Thank you very mucho for your help,
Fran
=20
Fran,

The getContent method returns the particle (for the model group) =
physically present in that type definition. The getContentType returns =
the logical/synthetic particle (if the type has complex content) and =
that logical particle has a model group (sequence) that will include a =
particle for the base class's contents and a particle for the content =
contributed locally.


Fran wrote:=20
Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi=F3 en el mensaje=20
news:cnvmsa$kft$1@www.eclipse.org...
Note the content type is not null and the Semantics view shows how =
it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
Sorry for delay in responding - Indeed I was looking in the wrong =
place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


=20

=20



------=_NextPart_000_0164_01C58197.809943E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi again Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I will try to explain with more detail =
the results=20
I obtain. I'm using this code in an recursive method and it works for =
all the=20
&lt;complexType&gt; elements without problems, except for the ones =
including an=20
&lt;extension&gt; tag.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now, l will try to trace for you the =
execution of=20
the program:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 1. As input, the complexType=20
"targetComplexDefinition" </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; is =
the=20
following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial=20
size=3D2>&lt;complexContent&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
&lt;extension=20
base=3D"tns1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 2. The program proceed without =
error until the=20
arrow I have writen:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDParticle)=20
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;------&gt;&nbsp;&nbsp; =
XSDParticle=20
elementParticle =3D </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (XSDParticle)=20
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&nbsp;XSDElementDeclaration element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV></FONT><=
/DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 3. And then, and suddendly, the =
input of the=20
method (targetComplexDefinition)</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(you can see=20
at step 1)&nbsp;</FONT><FONT face=3DArial size=3D2>changes to the =
following=20
value:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"MapRequest"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;=
sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"itiTrace" nillable=3D"true"=20
type=3D"tns2:ItineraryTrace"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"mapDefinition" nillable=3D"true"=20
type=3D"tns1:ScaleMapDefinition"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
&lt;/sequence&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As you see, this complexType contains =
an element=20
called "tns1:ScaleMapDefinition", which</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is the original input.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Believe me. I really don't understand =
what's=20
happen... I hope this post would be clear enough </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>so you could help me.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very much,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT><BR>--=20
<BR>__________________________________________</DIV>
<DIV>&nbsp;</DIV>
<DIV>Francisco Sanchez Cid, Research Assistant<BR>Department of=20
Computing<BR>City University<BR>Northampton Square, London, EC1V =
0HB<BR>e-mail:=20
<A=20
href=3D"mailto:F.Sanchez-Cid@soi.city.ac.uk">F.Sanchez-Cid@soi.city.ac.uk=
</A><BR>T=20
(+44) 020 7040 4042<BR>F (+44) 020 7040=20
0244<BR>__________________________________________</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
escribi=F3 en el mensaje <A=20
=
href=3D"news:daeha7$1cl$1@news.eclipse.org">news:daeha7$1cl$1@news.eclips=
e.org</A>...</DIV>Fran,<BR><BR>I=20
would imagine that you will get class cast exceptions because the =
particles of=20
the top level synthetic particle can refer to XSDModelGroup (or =
XSDWildcard)=20
not just XSDElementDeclaration.&nbsp; Only the top level particle's =
content is=20
guaranteed to be an XSDModelGroup; everywhere else you'd better be =
prepared to=20
deal with the more general cases.&nbsp;&nbsp; I think you really need =
a=20
recursive algorithm to do this properly.<BR>&nbsp;<BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaegu4$rr$1@news.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have tried to do something like=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; =
(XSDParticle)=20
=
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
=
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XSDParticle =
elementParticle=20
=3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDParticle)=20
=
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;XSDElementDeclaratio n=
=20
element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;.............</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now, =
I&nbsp;use&nbsp;"getContentType", and from=20
the&nbsp;particle, I try to retrieve</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the&nbsp;sequence, in order =
to&nbsp;access to=20
the&nbsp;"base" particle and the</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"local" particle. But I recover =
wrong=20
information.&nbsp;Do you know what </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>am I doing&nbsp;wrong?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very mucho for your=20
help,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Fran<BR>&nbsp;&nbsp;&nbsp;&nbsp; </FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>The=20
getContent method returns the particle (for the model group) =
physically=20
present in that type definition.&nbsp; The getContentType returns =
the=20
logical/synthetic particle (if the type has complex content) and =
that=20
logical particle has a model group (sequence) that will include a =
particle=20
for the base class's contents and a particle for the content =
contributed=20
locally.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaeb7o$ovn$1@news.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

&lt;complexType name=3D"ScaleMapDefinition"&gt;
&lt;complexContent&gt;
&lt;extension base=3D"tns1:MapDefinitionType"&gt;
&lt;sequence&gt;
&lt;element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/&gt;
&lt;/sequence&gt;
&lt;/extension&gt;
&lt;/complexContent&gt;
&lt;/complexType&gt;

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:none@nonet.com">&lt;none@nonet.com&gt;</A> escribi=F3 en =
el mensaje=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:cnvmsa$kft$1@www.eclipse.org">news:cnvmsa$kft$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Note the content type =
is not null and the Semantics view shows how it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
</PRE></BLOCKQUOTE><PRE wrap=3D"">Sorry for delay in responding - =
Indeed I was looking in the wrong place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_0164_01C58197.809943E0--
Re: Analysing Complex Types derived by extension [message #62461 is a reply to message #62436] Tue, 05 July 2005 18:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000505000002030500060606
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

What you describe is exactly what I expect. That is, if you get
ScaleMapDefinitions's content type, look at that particle's model
group's first particle, that particle will be exactly the same particle
as you get for MapRequest's content type. In other words, the content
type of an extended complex type reuses (refers to) the content type of
the base type.


Fran wrote:

> Hi again Ed,
> I will try to explain with more detail the results I obtain. I'm using
> this code in an recursive method and it works for all the
> <complexType> elements without problems, except for the ones including
> an <extension> tag.
> Now, l will try to trace for you the execution of the program:
>
> Step 1. As input, the complexType "targetComplexDefinition"
> is the following:
> <complexType name="ScaleMapDefinition">
> <complexContent>
> <extension base="tns1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> Step 2. The program proceed without error until the arrow I have writen:
>
> XSDParticle complexTypeContent =
> (XSDParticle) targetComplexDefinition.getContentType();
> XSDModelGroup xsdModelGroup =
> (XSDModelGroup)complexTypeContent.getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> ------> XSDParticle elementParticle =
> (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
> (XSDElementDeclaration)elementParticle.getContent();
>
> Step 3. And then, and suddendly, the input of the method
> (targetComplexDefinition)
> (you can see at step 1) changes to the following value:
>
> <complexType name="MapRequest">
> <sequence>
> <element name="itiTrace" nillable="true"
> type="tns2:ItineraryTrace"/>
> <element name="mapDefinition" nillable="true"
> type="tns1:ScaleMapDefinition"/>
> </sequence>
> </complexType>
>
> As you see, this complexType contains an element called
> "tns1:ScaleMapDefinition", which
> is the original input.
> Believe me. I really don't understand what's happen... I hope this
> post would be clear enough
> so you could help me.
> Thank you very much,
> Fran
> --
> __________________________________________
>
> Francisco Sanchez Cid, Research Assistant
> Department of Computing
> City University
> Northampton Square, London, EC1V 0HB
> e-mail: F.Sanchez-Cid@soi.city.ac.uk <mailto:F.Sanchez-Cid@soi.city.ac.uk>
> T (+44) 020 7040 4042
> F (+44) 020 7040 0244
> __________________________________________
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> escribi
Re: Analysing Complex Types derived by extension [message #62485 is a reply to message #62461] Wed, 06 July 2005 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C58219.4D1B8690
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,
I thought the base type for "ScaleMapDefitinion" was =
"tns1:MapDefinitionType".......:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
----- > <extension base=3D"TNS1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

.........And not "MapRequest". But reading your response, I see I was =
wrong.

Nevertheless, is there any way to obtain the elements in the sequence in =
"ScaleMapDefinition" complexType? In other words, I'm talking about =
obtaining a List, collection or whatever, containing:
=20
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
AND
<element name=3D"heightInPixels" type=3D"xsd:int"/>
<element name=3D"weightInPixels" type=3D"xsd:int"/>

(Obviously, the last two elements come from the base of the <extension> =
tag, that is:=20
<complexType name=3D"MapDefinitionType">
<sequence>
<element name=3D"heightInPixels" type=3D"xsd:int"/>
<element name=3D"weightInPixels" type=3D"xsd:int"/>
</sequence>
<complexType/>)

Thanks a lot for your help,
Fran

--=20
"Ed Merks" <merks@ca.ibm.com> escribi=F3 en el mensaje =
news:daek1p$4sb$1@news.eclipse.org...
Fran,

What you describe is exactly what I expect. That is, if you get =
ScaleMapDefinitions's content type, look at that particle's model =
group's first particle, that particle will be exactly the same particle =
as you get for MapRequest's content type. In other words, the content =
type of an extended complex type reuses (refers to) the content type of =
the base type.


Fran wrote:=20
Hi again Ed,
I will try to explain with more detail the results I obtain. I'm =
using this code in an recursive method and it works for all the =
<complexType> elements without problems, except for the ones including =
an <extension> tag.
Now, l will try to trace for you the execution of the program:

Step 1. As input, the complexType "targetComplexDefinition"=20
is the following:
<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

Step 2. The program proceed without error until the arrow I have =
writen:

XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
------> XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();

Step 3. And then, and suddendly, the input of the method =
(targetComplexDefinition)
(you can see at step 1) changes to the following value:

<complexType name=3D"MapRequest">
<sequence>
<element name=3D"itiTrace" nillable=3D"true" =
type=3D"tns2:ItineraryTrace"/>
<element name=3D"mapDefinition" nillable=3D"true" =
type=3D"tns1:ScaleMapDefinition"/>
</sequence>
</complexType>

As you see, this complexType contains an element called =
"tns1:ScaleMapDefinition", which
is the original input.
Believe me. I really don't understand what's happen... I hope this =
post would be clear enough=20
so you could help me.
Thank you very much,
Fran
--=20

------=_NextPart_000_0017_01C58219.4D1B8690
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I thought the base type for =
"ScaleMapDefitinion"=20
was "tns1:MapDefinitionType".......:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;complexType=20
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial size=3D2>&lt;complexContent&gt;<BR>----- &gt; &lt;extension =

base=3D"TNS1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>........And not "MapRequest". But =
reading your=20
response, I see I was wrong.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Nevertheless, is there any way to =
obtain the=20
elements in the sequence in "ScaleMapDefinition" complexType? In other =
words,=20
I'm talking about obtaining a List, collection or whatever,=20
containing:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp; &lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize" type=3D"xsd:double"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; AND</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&lt;element=20
name=3D"heightInPixels"=20
type=3D"xsd:int"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"weightInPixels" type=3D"xsd:int"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>(Obviously, the last two elements come =
from the=20
base of the &lt;extension&gt; tag, that is: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"MapDefinitionType"&gt;</FONT><FONT face=3DArial=20
size=3D2><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"heightInPixels"=20
type=3D"xsd:int"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"weightInPixels" type=3D"xsd:int"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;/sequence&gt;</FONT></DIV>
<DIV><FONT face=3DArial><FONT=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&lt;complexType/ &gt;) </FONT></FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks a lot for your =
help,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT></DIV>
<DIV><BR>-- <BR>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; escribi=F3 en =
el mensaje=20
<A=20
href=3D"news:daek1p$4sb$1@news.eclipse.org">news:daek1p$4sb$1@news.eclips=
e.org</A>...</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>What=20
you describe is exactly what I expect.&nbsp; That is, if you get=20
ScaleMapDefinitions's content type, look at that particle's model =
group's=20
first particle, that particle will be exactly the same particle as you =
get for=20
MapRequest's content type.&nbsp; In other words, the content type of =
an=20
extended complex type reuses (refers to) the content type of the base=20
type.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaejdh$3vt$1@news.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi again Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I will try to explain with more =
detail the=20
results I obtain. I'm using this code in an recursive method and it =
works=20
for all the &lt;complexType&gt; elements without problems, except =
for the=20
ones including an &lt;extension&gt; tag.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now, l will try to trace for you =
the execution=20
of the program:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 1. As input, the complexType=20
"targetComplexDefinition" </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; is =
the=20
following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
=
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial=20
=
size=3D2>&lt;complexContent&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
&lt;extension=20
=
base=3D"tns1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
=
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
=
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/complexType&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 2. The program proceed without =
error until=20
the arrow I have writen:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; =
(XSDParticle)=20
=
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D =
xsdModelGroup.getContents();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
=
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;------&gt;&nbsp;&nbsp; =
XSDParticle=20
elementParticle =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (XSDParticle)=20
=
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&nbsp;XSDElementDeclaration element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
=
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV></FONT><=
/DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 3. And then, and suddendly, =
the input of=20
the method (targetComplexDefinition)</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(you can=20
see at step 1)&nbsp;</FONT><FONT face=3DArial size=3D2>changes to =
the following=20
value:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
=
name=3D"MapRequest"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;=
sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"itiTrace" nillable=3D"true"=20
=
type=3D"tns2:ItineraryTrace"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"mapDefinition" nillable=3D"true"=20
=
type=3D"tns1:ScaleMapDefinition"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
&lt;/sequence&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As you see, this complexType =
contains an=20
element called "tns1:ScaleMapDefinition", which</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is the original input.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Believe me. I really don't =
understand what's=20
happen... I hope this post would be clear enough </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>so you could help me.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very much,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT><BR>--=20
<BR></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0017_01C58219.4D1B8690--
Re: Analysing Complex Types derived by extension [message #62522 is a reply to message #62485] Wed, 06 July 2005 10:54 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000702020309080105090901
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

You are only showing me tiny little snips of your schemas (and of of
your code) so I just assumed when you showed me the second type that is
was the base of the first type. I see that it isn't. I think so far
you've essentially asked the same question three times and you've
asserted odd things like you've recovered wrong information and that
suddenly the input of the method changed, but none of that is really
helping clarify what you are actually doing and if anything serves to
confuse things further. I've told you that you can't blindly assume the
the content of the particle is an element, but you show the same code
again a second time without change. I don't get it...

I'm not a patient person and I don't want to repeat what I've already
said, so here goes one last attempt. The content model of a complex
type is a tree of particles, where the getContent() of each particle can
be an element declaration, a model group, a wildcard, or a model group
definition, and the getTerm() of each particle, which resolves element
references and model group definition references, can be an element
declaration, a model group, or a wildcard. If you want to walk the
concrete/physical structure as it appears in the source schema, you can
walk the complex type's getContent and the particle's getContent; if you
want to walk the abstract/logical structure as defined in the XML Schema
specification, you can walk the complex type's getContentType() and the
particle's getTerm(). That's all there is and those methods are
sufficient for all your purposes, so it's best to figure out how to make
those work and if you have a problem to show clearly and precisely all
the code you are executing and all the the schema constructs being
analyzed, not just snips and bits. The bottom line is that there is no
flat list of all the elements, there is only a tree and you must walk it
recursively.


Fran wrote:

> Ed,
> I thought the base type for "ScaleMapDefitinion" was
> "tns1:MapDefinitionType".......:
>
> <complexType name="ScaleMapDefinition">
> <complexContent>
> ----- > <extension base="TNS1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> ........And not "MapRequest". But reading your response, I see I was
> wrong.
>
> Nevertheless, is there any way to obtain the elements in the sequence
> in "ScaleMapDefinition" complexType? In other words, I'm talking about
> obtaining a List, collection or whatever, containing:
>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> AND
> <element name="heightInPixels" type="xsd:int"/>
> <element name="weightInPixels" type="xsd:int"/>
>
> (Obviously, the last two elements come from the base of the
> <extension> tag, that is:
> <complexType name="MapDefinitionType">
> <sequence>
> <element name="heightInPixels" type="xsd:int"/>
> <element name="weightInPixels" type="xsd:int"/>
> </sequence>
> <complexType/>)
>
> Thanks a lot for your help,
> Fran
>
> --
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> escribi
Re: Analysing Complex Types derived by extension [message #592531 is a reply to message #54850] Fri, 19 November 2004 15:21 Go to previous message
Klaas Dellschaft is currently offline Klaas DellschaftFriend
Messages: 58
Registered: July 2009
Member
> The problem I'm encountering is when analysing a derived complex type. In
> the attribute uses, I get all the attributes from the subtype and its base
> type(s). However, as far as element declarations go, I only get the ones
> from this particular type - which in the case of the NY address is none.
> To get these I have to look at the base type definitions.

Do you use XSDComplexTypeDefinition#getContentType() or
XSDComplexTypeDefinition#getContent()? The first method is should be the
correct for getting also the derived elements. With the second method you
will only get the elements defined at the current complexType.

Cheers
Klaas
Re: Analysing Complex Types derived by extension [message #592543 is a reply to message #54850] Fri, 19 November 2004 15:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Ray,

Given an XSDComplexTypeDefinition x (with complex content),
x.getContentType() will give you the complete content particle,
including anything inherited from the base type, whereas x.getContent()
will give you only the physically contained particle with only the
locally declared content. Similarly, x.getAttributeUses() returns all
the inherited and local attributes, but x.getAttributeContents() returns
only the locally declared ones. I.e., you can view the model either
abstractly or concretely and abstract properties will say something like
"This represents the ... infoset property" whereas concrete properties
will say something like "This concrete reference represents ...". Be
sure to choose the one appropriate for what you are trying to do...


Ray wrote:

> Hi there,
>
> I'm having a problem analysing a complex type hierarchy using the API
> - below are the complex type definitions I'm using. As you can see,
> USAddress derives from Address, and NYAddress derives from USAddress.
>
> The problem I'm encountering is when analysing a derived complex type.
> In the attribute uses, I get all the attributes from the subtype and
> its base type(s). However, as far as element declarations go, I only
> get the ones from this particular type - which in the case of the NY
> address is none. To get these I have to look at the base type
> definitions.
> This seems fair enough in some ways, but the fact that the attributes
> do appear in the attribute uses list seems to contradict this
> approach. Does anyone have any ideas why this approach has been taken,
> or is it a flaw?
>
> <xs:complexType name="Address">
> <xs:sequence>
> <xs:element name="name" type="xs:string"/>
> <xs:element name="street" type="xs:string"/>
> <xs:element name="city" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="Person" type="xs:string"/>
> </xs:complexType>
>
> <xs:complexType name="USAddress">
> <xs:complexContent>
> <xs:extension base="Address">
> <xs:sequence>
> <xs:element name="state" type="xs:string"/>
> <xs:element name="zip" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="Surname" type="xs:string"/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:complexType name="NYAddress">
> <xs:complexContent>
> <xs:extension base="USAddress">
> <xs:attribute name="RentControlled" type="xs:boolean"/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
>
> Many thanks for your help,
>
> Ray
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Analysing Complex Types derived by extension [message #592558 is a reply to message #54904] Fri, 19 November 2004 17:02 Go to previous message
Ray is currently offline RayFriend
Messages: 9
Registered: July 2009
Junior Member
Ed Merks wrote:

> Ray,

> Given an XSDComplexTypeDefinition x (with complex content),
> x.getContentType() will give you the complete content particle,
> including anything inherited from the base type, whereas x.getContent()
> will give you only the physically contained particle with only the
> locally declared content. Similarly, x.getAttributeUses() returns all
> the inherited and local attributes, but x.getAttributeContents() returns
> only the locally declared ones. I.e., you can view the model either
> abstractly or concretely and abstract properties will say something like
> "This represents the ... infoset property" whereas concrete properties
> will say something like "This concrete reference represents ...". Be
> sure to choose the one appropriate for what you are trying to do...


Thanks for your help both of you. Unfortunately while what you say holds
true for attributes (AttributeUses returns all, AttributeContents only
local), i find that for elements, while x.GetContent does contain the the
local ones, x.GetContentType is empty - it doesn't even contain the local
declarations.

I'm using XSD 2.0.1 if thats of any help....

Thanks again for your help - you've helped me understand the API better
certainly.

Ray
Re: Analysing Complex Types derived by extension [message #592568 is a reply to message #54930] Fri, 19 November 2004 18:08 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020404030308060305090703
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ray,

For this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:exa="http://www.example.com/ExampleA"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/ExampleA">

<xsd:element name="a" type="exa:A"/>

<xsd:complexType name="A">
<xsd:sequence>
<xsd:element name="ae" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="aa" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="B">
<xsd:complexContent>
<xsd:extension base="exa:A">
<xsd:sequence>
<xsd:element name="be" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="ba" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

</xsd:schema>

I'd expect to see results like this in the Sample XML Schema Editor:

Note the content type is not null and the Semantics view shows how it's
a sequence that combines the local sequence and that of the base type.

I'm not sure what you've tried to do...


Ray wrote:

> Ed Merks wrote:
>
>> Ray,
>
>
>> Given an XSDComplexTypeDefinition x (with complex content),
>> x.getContentType() will give you the complete content particle,
>> including anything inherited from the base type, whereas
>> x.getContent() will give you only the physically contained particle
>> with only the locally declared content. Similarly,
>> x.getAttributeUses() returns all the inherited and local attributes,
>> but x.getAttributeContents() returns only the locally declared ones.
>> I.e., you can view the model either abstractly or concretely and
>> abstract properties will say something like "This represents the ...
>> infoset property" whereas concrete properties will say something like
>> "This concrete reference represents ...". Be sure to choose the one
>> appropriate for what you are trying to do...
>
>
>
> Thanks for your help both of you. Unfortunately while what you say
> holds true for attributes (AttributeUses returns all,
> AttributeContents only local), i find that for elements, while
> x.GetContent does contain the the local ones, x.GetContentType is
> empty - it doesn't even contain the local declarations.
>
> I'm using XSD 2.0.1 if thats of any help....
>
> Thanks again for your help - you've helped me understand the API
> better certainly.
> Ray
>


--------------020404030308060305090703
Content-Type: multipart/related;
boundary="------------080603050704010309070905"


--------------080603050704010309070905
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ray,<br>
<br>
For this schema:<br>
<blockquote><tt><small>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</small><br>
<small>&lt;xsd:schema </small><br>
<small>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Analysing Complex Types derived by extension [message #592635 is a reply to message #54961] Tue, 23 November 2004 15:59 Go to previous message
Ray is currently offline RayFriend
Messages: 9
Registered: July 2009
Junior Member
> Note the content type is not null and the Semantics view shows how it's a
> sequence that combines the local sequence and that of the base type. I'm
> not sure what you've tried to do..

Sorry for delay in responding - Indeed I was looking in the wrong place to
begin with, but your comments have pointed me to the right direction. When
analysing the subsequent XSDModelGroupDefinition, I was getting its
contents, and not its 'particles'. Once i got this list, i was able to look
through and find all the elements required. Thanks very much for your help!

Ray
Re: Analysing Complex Types derived by extension [message #595978 is a reply to message #55089] Tue, 05 July 2005 16:06 Go to previous message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

Hi all,
I have read this post, and I think I have a similar problem. I'm trying to
analize some complexType like the following one:

<complexType name="ScaleMapDefinition">
<complexContent>
<extension base="tns1:MapDefinitionType">
<sequence>
<element name="centerPoint" nillable="true"
type="tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the
complexType):

xsdModelGroup = (XSDModelGroup)
targetComplexDefinition.getComplexType().getContent();
listOfElements = xsdModelGroup.getContents();

Iterator elementsIterator = listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
XSDElementDeclaration element =
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it doesn't
works when I manage a complexType with an "extension" tag. Can someone
explain me way? There is any way to access to all the elements of the
complexType (including those coming from the "extension")?. Sorry if this
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi
Re: Analysing Complex Types derived by extension [message #595990 is a reply to message #62340] Tue, 05 July 2005 16:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060405030508050601030404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

The getContent method returns the particle (for the model group)
physically present in that type definition. The getContentType returns
the logical/synthetic particle (if the type has complex content) and
that logical particle has a model group (sequence) that will include a
particle for the base class's contents and a particle for the content
contributed locally.


Fran wrote:

>Hi all,
>I have read this post, and I think I have a similar problem. I'm trying to
>analize some complexType like the following one:
>
> <complexType name="ScaleMapDefinition">
> <complexContent>
> <extension base="tns1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" nillable="true"
>type="tns3:GeoCoordinates"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
>I was using this code ("targetComplexDefinition" variable contains the
>complexType):
>
> xsdModelGroup = (XSDModelGroup)
>targetComplexDefinition.getComplexType().getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
>(XSDElementDeclaration)elementParticle.getContent();
> ...........
>
>It works when my complexType doesn't have an "extension" tag, but it doesn't
>works when I manage a complexType with an "extension" tag. Can someone
>explain me way? There is any way to access to all the elements of the
>complexType (including those coming from the "extension")?. Sorry if this
>question is so simple. But I really don't find how to do it.
>Thanks in advance,
>Fran
>
>
>"Ray" <none@nonet.com> escribi


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Analysing Complex Types derived by extension [message #595999 is a reply to message #62364] Tue, 05 July 2005 17:44 Go to previous message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0157_01C58191.962F2400
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Ed,
I have tried to do something like this:
=20
XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
.............


Now, I use "getContentType", and from the particle, I try to retrieve
the sequence, in order to access to the "base" particle and the
"local" particle. But I recover wrong information. Do you know what=20
am I doing wrong?
Thank you very mucho for your help,
Fran
=20
Fran,

The getContent method returns the particle (for the model group) =
physically present in that type definition. The getContentType returns =
the logical/synthetic particle (if the type has complex content) and =
that logical particle has a model group (sequence) that will include a =
particle for the base class's contents and a particle for the content =
contributed locally.


Fran wrote:=20
Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi=F3 en el mensaje=20
news:cnvmsa$kft$1@www.eclipse.org...
Note the content type is not null and the Semantics view shows how =
it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
Sorry for delay in responding - Indeed I was looking in the wrong =
place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


=20

=20

------=_NextPart_000_0157_01C58191.962F2400
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have tried to do something like=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDParticle)=20
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial size=3D2>
<DIV><BR>&nbsp;&nbsp;Iterator elementsIterator =3D=20
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</DIV>
<DIV>&nbsp;&nbsp;&nbsp; XSDParticle elementParticle =3D </DIV>
<DIV> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(XSDParticle)=20
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;XSDElementDeclaratio n=
=20
element =3D </DIV>
<DIV> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;.............</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Now, I&nbsp;use&nbsp;"getContentType", and from the&nbsp;particle, =
I try to=20
retrieve</DIV>
<DIV>the&nbsp;sequence, in order to&nbsp;access to the&nbsp;"base" =
particle and=20
the</DIV>
<DIV>"local" particle. But I recover wrong information.&nbsp;Do you know =
what=20
</DIV>
<DIV>am I doing&nbsp;wrong?</DIV>
<DIV>Thank you very mucho for your help,</DIV>
<DIV>Fran<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT ></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>The=20
getContent method returns the particle (for the model group) =
physically=20
present in that type definition.&nbsp; The getContentType returns the=20
logical/synthetic particle (if the type has complex content) and that =
logical=20
particle has a model group (sequence) that will include a particle for =
the=20
base class's contents and a particle for the content contributed=20
locally.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaeb7o$ovn$1@news.eclipse.org type=3D"cite"><PRE =
wrap=3D"">Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

&lt;complexType name=3D"ScaleMapDefinition"&gt;
&lt;complexContent&gt;
&lt;extension base=3D"tns1:MapDefinitionType"&gt;
&lt;sequence&gt;
&lt;element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/&gt;
&lt;/sequence&gt;
&lt;/extension&gt;
&lt;/complexContent&gt;
&lt;/complexType&gt;

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:none@nonet.com">&lt;none@nonet.com&gt;</A> escribi=F3 en =
el mensaje=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:cnvmsa$kft$1@www.eclipse.org">news:cnvmsa$kft$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Note the content type is =
not null and the Semantics view shows how it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
</PRE></BLOCKQUOTE><PRE wrap=3D"">Sorry for delay in responding - =
Indeed I was looking in the wrong place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0157_01C58191.962F2400--
Re: Analysing Complex Types derived by extension [message #596008 is a reply to message #62388] Tue, 05 July 2005 17:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040608040103060607030300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

I would imagine that you will get class cast exceptions because the
particles of the top level synthetic particle can refer to XSDModelGroup
(or XSDWildcard) not just XSDElementDeclaration. Only the top level
particle's content is guaranteed to be an XSDModelGroup; everywhere else
you'd better be prepared to deal with the more general cases. I think
you really need a recursive algorithm to do this properly.


Fran wrote:

> Hi Ed,
> I have tried to do something like this:
>
> XSDParticle complexTypeContent =
> (XSDParticle) targetComplexDefinition.getContentType();
> XSDModelGroup xsdModelGroup =
> (XSDModelGroup)complexTypeContent.getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> XSDParticle elementParticle =
> (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
> (XSDElementDeclaration)elementParticle.getContent();
> .............
>
>
> Now, I use "getContentType", and from the particle, I try to retrieve
> the sequence, in order to access to the "base" particle and the
> "local" particle. But I recover wrong information. Do you know what
> am I doing wrong?
> Thank you very mucho for your help,
> Fran
>
>
> Fran,
>
> The getContent method returns the particle (for the model group)
> physically present in that type definition. The getContentType
> returns the logical/synthetic particle (if the type has complex
> content) and that logical particle has a model group (sequence)
> that will include a particle for the base class's contents and a
> particle for the content contributed locally.
>
>
> Fran wrote:
>
>>Hi all,
>>I have read this post, and I think I have a similar problem. I'm trying to
>>analize some complexType like the following one:
>>
>> <complexType name="ScaleMapDefinition">
>> <complexContent>
>> <extension base="tns1:MapDefinitionType">
>> <sequence>
>> <element name="centerPoint" nillable="true"
>>type="tns3:GeoCoordinates"/>
>> </sequence>
>> </extension>
>> </complexContent>
>> </complexType>
>>
>>I was using this code ("targetComplexDefinition" variable contains the
>>complexType):
>>
>> xsdModelGroup = (XSDModelGroup)
>>targetComplexDefinition.getComplexType().getContent();
>> listOfElements = xsdModelGroup.getContents();
>>
>> Iterator elementsIterator = listOfElements.iterator();
>> while(elementsIterator.hasNext())
>> {
>> XSDParticle elementParticle = (XSDParticle) elementsIterator.next();
>> XSDElementDeclaration element =
>>(XSDElementDeclaration)elementParticle.getContent();
>> ...........
>>
>>It works when my complexType doesn't have an "extension" tag, but it doesn't
>>works when I manage a complexType with an "extension" tag. Can someone
>>explain me way? There is any way to access to all the elements of the
>>complexType (including those coming from the "extension")?. Sorry if this
>>question is so simple. But I really don't find how to do it.
>>Thanks in advance,
>>Fran
>>
>>
>>"Ray" <none@nonet.com> escribi


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Analysing Complex Types derived by extension [message #596022 is a reply to message #62412] Tue, 05 July 2005 18:26 Go to previous message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0164_01C58197.809943E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi again Ed,
I will try to explain with more detail the results I obtain. I'm using =
this code in an recursive method and it works for all the <complexType> =
elements without problems, except for the ones including an <extension> =
tag.
Now, l will try to trace for you the execution of the program:

Step 1. As input, the complexType "targetComplexDefinition"=20
is the following:
<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

Step 2. The program proceed without error until the arrow I have writen:

XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
------> XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();

Step 3. And then, and suddendly, the input of the method =
(targetComplexDefinition)
(you can see at step 1) changes to the following value:

<complexType name=3D"MapRequest">
<sequence>
<element name=3D"itiTrace" nillable=3D"true" =
type=3D"tns2:ItineraryTrace"/>
<element name=3D"mapDefinition" nillable=3D"true" =
type=3D"tns1:ScaleMapDefinition"/>
</sequence>
</complexType>

As you see, this complexType contains an element called =
"tns1:ScaleMapDefinition", which
is the original input.
Believe me. I really don't understand what's happen... I hope this post =
would be clear enough=20
so you could help me.
Thank you very much,
Fran
--=20
__________________________________________

Francisco Sanchez Cid, Research Assistant
Department of Computing
City University
Northampton Square, London, EC1V 0HB
e-mail: F.Sanchez-Cid@soi.city.ac.uk
T (+44) 020 7040 4042
F (+44) 020 7040 0244
__________________________________________
"Ed Merks" <merks@ca.ibm.com> escribi=F3 en el mensaje =
news:daeha7$1cl$1@news.eclipse.org...
Fran,

I would imagine that you will get class cast exceptions because the =
particles of the top level synthetic particle can refer to XSDModelGroup =
(or XSDWildcard) not just XSDElementDeclaration. Only the top level =
particle's content is guaranteed to be an XSDModelGroup; everywhere else =
you'd better be prepared to deal with the more general cases. I think =
you really need a recursive algorithm to do this properly.
=20

Fran wrote:=20
Hi Ed,
I have tried to do something like this:
=20
XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
.............


Now, I use "getContentType", and from the particle, I try to =
retrieve
the sequence, in order to access to the "base" particle and the
"local" particle. But I recover wrong information. Do you know what=20
am I doing wrong?
Thank you very mucho for your help,
Fran
=20
Fran,

The getContent method returns the particle (for the model group) =
physically present in that type definition. The getContentType returns =
the logical/synthetic particle (if the type has complex content) and =
that logical particle has a model group (sequence) that will include a =
particle for the base class's contents and a particle for the content =
contributed locally.


Fran wrote:=20
Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/>
</sequence>
</extension>
</complexContent>
</complexType>

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <none@nonet.com> escribi=F3 en el mensaje=20
news:cnvmsa$kft$1@www.eclipse.org...
Note the content type is not null and the Semantics view shows how =
it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
Sorry for delay in responding - Indeed I was looking in the wrong =
place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


=20

=20



------=_NextPart_000_0164_01C58197.809943E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi again Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I will try to explain with more detail =
the results=20
I obtain. I'm using this code in an recursive method and it works for =
all the=20
&lt;complexType&gt; elements without problems, except for the ones =
including an=20
&lt;extension&gt; tag.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now, l will try to trace for you the =
execution of=20
the program:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 1. As input, the complexType=20
"targetComplexDefinition" </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; is =
the=20
following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial=20
size=3D2>&lt;complexContent&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
&lt;extension=20
base=3D"tns1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 2. The program proceed without =
error until the=20
arrow I have writen:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDParticle)=20
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;------&gt;&nbsp;&nbsp; =
XSDParticle=20
elementParticle =3D </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (XSDParticle)=20
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&nbsp;XSDElementDeclaration element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV></FONT><=
/DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 3. And then, and suddendly, the =
input of the=20
method (targetComplexDefinition)</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(you can see=20
at step 1)&nbsp;</FONT><FONT face=3DArial size=3D2>changes to the =
following=20
value:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"MapRequest"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;=
sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"itiTrace" nillable=3D"true"=20
type=3D"tns2:ItineraryTrace"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"mapDefinition" nillable=3D"true"=20
type=3D"tns1:ScaleMapDefinition"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
&lt;/sequence&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As you see, this complexType contains =
an element=20
called "tns1:ScaleMapDefinition", which</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is the original input.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Believe me. I really don't understand =
what's=20
happen... I hope this post would be clear enough </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>so you could help me.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very much,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT><BR>--=20
<BR>__________________________________________</DIV>
<DIV>&nbsp;</DIV>
<DIV>Francisco Sanchez Cid, Research Assistant<BR>Department of=20
Computing<BR>City University<BR>Northampton Square, London, EC1V =
0HB<BR>e-mail:=20
<A=20
href=3D"mailto:F.Sanchez-Cid@soi.city.ac.uk">F.Sanchez-Cid@soi.city.ac.uk=
</A><BR>T=20
(+44) 020 7040 4042<BR>F (+44) 020 7040=20
0244<BR>__________________________________________</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
escribi=F3 en el mensaje <A=20
=
href=3D"news:daeha7$1cl$1@news.eclipse.org">news:daeha7$1cl$1@news.eclips=
e.org</A>...</DIV>Fran,<BR><BR>I=20
would imagine that you will get class cast exceptions because the =
particles of=20
the top level synthetic particle can refer to XSDModelGroup (or =
XSDWildcard)=20
not just XSDElementDeclaration.&nbsp; Only the top level particle's =
content is=20
guaranteed to be an XSDModelGroup; everywhere else you'd better be =
prepared to=20
deal with the more general cases.&nbsp;&nbsp; I think you really need =
a=20
recursive algorithm to do this properly.<BR>&nbsp;<BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaegu4$rr$1@news.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have tried to do something like=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; =
(XSDParticle)=20
=
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D=20
xsdModelGroup.getContents();</FONT></DIV><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
=
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XSDParticle =
elementParticle=20
=3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDParticle)=20
=
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;XSDElementDeclaratio n=
=20
element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;.............</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now, =
I&nbsp;use&nbsp;"getContentType", and from=20
the&nbsp;particle, I try to retrieve</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the&nbsp;sequence, in order =
to&nbsp;access to=20
the&nbsp;"base" particle and the</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"local" particle. But I recover =
wrong=20
information.&nbsp;Do you know what </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>am I doing&nbsp;wrong?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very mucho for your=20
help,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Fran<BR>&nbsp;&nbsp;&nbsp;&nbsp; </FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>The=20
getContent method returns the particle (for the model group) =
physically=20
present in that type definition.&nbsp; The getContentType returns =
the=20
logical/synthetic particle (if the type has complex content) and =
that=20
logical particle has a model group (sequence) that will include a =
particle=20
for the base class's contents and a particle for the content =
contributed=20
locally.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaeb7o$ovn$1@news.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi all,
I have read this post, and I think I have a similar problem. I'm trying =
to=20
analize some complexType like the following one:

&lt;complexType name=3D"ScaleMapDefinition"&gt;
&lt;complexContent&gt;
&lt;extension base=3D"tns1:MapDefinitionType"&gt;
&lt;sequence&gt;
&lt;element name=3D"centerPoint" nillable=3D"true"=20
type=3D"tns3:GeoCoordinates"/&gt;
&lt;/sequence&gt;
&lt;/extension&gt;
&lt;/complexContent&gt;
&lt;/complexType&gt;

I was using this code ("targetComplexDefinition" variable contains the=20
complexType):

xsdModelGroup =3D (XSDModelGroup)=20
targetComplexDefinition.getComplexType().getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
XSDParticle elementParticle =3D (XSDParticle) =
elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();
...........

It works when my complexType doesn't have an "extension" tag, but it =
doesn't=20
works when I manage a complexType with an "extension" tag. Can someone=20
explain me way? There is any way to access to all the elements of the=20
complexType (including those coming from the "extension")?. Sorry if =
this=20
question is so simple. But I really don't find how to do it.
Thanks in advance,
Fran


"Ray" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:none@nonet.com">&lt;none@nonet.com&gt;</A> escribi=F3 en =
el mensaje=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:cnvmsa$kft$1@www.eclipse.org">news:cnvmsa$kft$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Note the content type =
is not null and the Semantics view shows how it's a=20
sequence that combines the local sequence and that of the base type. =
I'm=20
not sure what you've tried to do..
</PRE></BLOCKQUOTE><PRE wrap=3D"">Sorry for delay in responding - =
Indeed I was looking in the wrong place to=20
begin with, but your comments have pointed me to the right direction. =
When=20
analysing the subsequent XSDModelGroupDefinition, I was getting its=20
contents, and not its 'particles'. Once i got this list, i was able to=20
look through and find all the elements required. Thanks very much for =
your=20
help!

Ray


</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_0164_01C58197.809943E0--
Re: Analysing Complex Types derived by extension [message #596033 is a reply to message #62436] Tue, 05 July 2005 18:37 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000505000002030500060606
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

What you describe is exactly what I expect. That is, if you get
ScaleMapDefinitions's content type, look at that particle's model
group's first particle, that particle will be exactly the same particle
as you get for MapRequest's content type. In other words, the content
type of an extended complex type reuses (refers to) the content type of
the base type.


Fran wrote:

> Hi again Ed,
> I will try to explain with more detail the results I obtain. I'm using
> this code in an recursive method and it works for all the
> <complexType> elements without problems, except for the ones including
> an <extension> tag.
> Now, l will try to trace for you the execution of the program:
>
> Step 1. As input, the complexType "targetComplexDefinition"
> is the following:
> <complexType name="ScaleMapDefinition">
> <complexContent>
> <extension base="tns1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> Step 2. The program proceed without error until the arrow I have writen:
>
> XSDParticle complexTypeContent =
> (XSDParticle) targetComplexDefinition.getContentType();
> XSDModelGroup xsdModelGroup =
> (XSDModelGroup)complexTypeContent.getContent();
> listOfElements = xsdModelGroup.getContents();
>
> Iterator elementsIterator = listOfElements.iterator();
> while(elementsIterator.hasNext())
> {
> ------> XSDParticle elementParticle =
> (XSDParticle) elementsIterator.next();
> XSDElementDeclaration element =
> (XSDElementDeclaration)elementParticle.getContent();
>
> Step 3. And then, and suddendly, the input of the method
> (targetComplexDefinition)
> (you can see at step 1) changes to the following value:
>
> <complexType name="MapRequest">
> <sequence>
> <element name="itiTrace" nillable="true"
> type="tns2:ItineraryTrace"/>
> <element name="mapDefinition" nillable="true"
> type="tns1:ScaleMapDefinition"/>
> </sequence>
> </complexType>
>
> As you see, this complexType contains an element called
> "tns1:ScaleMapDefinition", which
> is the original input.
> Believe me. I really don't understand what's happen... I hope this
> post would be clear enough
> so you could help me.
> Thank you very much,
> Fran
> --
> __________________________________________
>
> Francisco Sanchez Cid, Research Assistant
> Department of Computing
> City University
> Northampton Square, London, EC1V 0HB
> e-mail: F.Sanchez-Cid@soi.city.ac.uk <mailto:F.Sanchez-Cid@soi.city.ac.uk>
> T (+44) 020 7040 4042
> F (+44) 020 7040 0244
> __________________________________________
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> escribi


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Analysing Complex Types derived by extension [message #596044 is a reply to message #62461] Wed, 06 July 2005 09:56 Go to previous message
Eclipse UserFriend
Originally posted by: sa840.soi.city.ac.uk

This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C58219.4D1B8690
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,
I thought the base type for "ScaleMapDefitinion" was =
"tns1:MapDefinitionType".......:

<complexType name=3D"ScaleMapDefinition">
<complexContent>
----- > <extension base=3D"TNS1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

.........And not "MapRequest". But reading your response, I see I was =
wrong.

Nevertheless, is there any way to obtain the elements in the sequence in =
"ScaleMapDefinition" complexType? In other words, I'm talking about =
obtaining a List, collection or whatever, containing:
=20
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
AND
<element name=3D"heightInPixels" type=3D"xsd:int"/>
<element name=3D"weightInPixels" type=3D"xsd:int"/>

(Obviously, the last two elements come from the base of the <extension> =
tag, that is:=20
<complexType name=3D"MapDefinitionType">
<sequence>
<element name=3D"heightInPixels" type=3D"xsd:int"/>
<element name=3D"weightInPixels" type=3D"xsd:int"/>
</sequence>
<complexType/>)

Thanks a lot for your help,
Fran

--=20
"Ed Merks" <merks@ca.ibm.com> escribi=F3 en el mensaje =
news:daek1p$4sb$1@news.eclipse.org...
Fran,

What you describe is exactly what I expect. That is, if you get =
ScaleMapDefinitions's content type, look at that particle's model =
group's first particle, that particle will be exactly the same particle =
as you get for MapRequest's content type. In other words, the content =
type of an extended complex type reuses (refers to) the content type of =
the base type.


Fran wrote:=20
Hi again Ed,
I will try to explain with more detail the results I obtain. I'm =
using this code in an recursive method and it works for all the =
<complexType> elements without problems, except for the ones including =
an <extension> tag.
Now, l will try to trace for you the execution of the program:

Step 1. As input, the complexType "targetComplexDefinition"=20
is the following:
<complexType name=3D"ScaleMapDefinition">
<complexContent>
<extension base=3D"tns1:MapDefinitionType">
<sequence>
<element name=3D"centerPoint" type=3D"tns3:GeoCoord"/>
<element name=3D"pixelSize" type=3D"xsd:double"/>
</sequence>
</extension>
</complexContent>
</complexType>

Step 2. The program proceed without error until the arrow I have =
writen:

XSDParticle complexTypeContent =3D=20
(XSDParticle) targetComplexDefinition.getContentType();
XSDModelGroup xsdModelGroup =3D=20
(XSDModelGroup)complexTypeContent.getContent();
listOfElements =3D xsdModelGroup.getContents();

Iterator elementsIterator =3D listOfElements.iterator();
while(elementsIterator.hasNext())
{
------> XSDParticle elementParticle =3D=20
(XSDParticle) elementsIterator.next();
XSDElementDeclaration element =3D=20
(XSDElementDeclaration)elementParticle.getContent();

Step 3. And then, and suddendly, the input of the method =
(targetComplexDefinition)
(you can see at step 1) changes to the following value:

<complexType name=3D"MapRequest">
<sequence>
<element name=3D"itiTrace" nillable=3D"true" =
type=3D"tns2:ItineraryTrace"/>
<element name=3D"mapDefinition" nillable=3D"true" =
type=3D"tns1:ScaleMapDefinition"/>
</sequence>
</complexType>

As you see, this complexType contains an element called =
"tns1:ScaleMapDefinition", which
is the original input.
Believe me. I really don't understand what's happen... I hope this =
post would be clear enough=20
so you could help me.
Thank you very much,
Fran
--=20

------=_NextPart_000_0017_01C58219.4D1B8690
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I thought the base type for =
"ScaleMapDefitinion"=20
was "tns1:MapDefinitionType".......:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;complexType=20
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial size=3D2>&lt;complexContent&gt;<BR>----- &gt; &lt;extension =

base=3D"TNS1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>........And not "MapRequest". But =
reading your=20
response, I see I was wrong.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Nevertheless, is there any way to =
obtain the=20
elements in the sequence in "ScaleMapDefinition" complexType? In other =
words,=20
I'm talking about obtaining a List, collection or whatever,=20
containing:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp; &lt;element name=3D"centerPoint"=20
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize" type=3D"xsd:double"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; AND</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&lt;element=20
name=3D"heightInPixels"=20
type=3D"xsd:int"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"weightInPixels" type=3D"xsd:int"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>(Obviously, the last two elements come =
from the=20
base of the &lt;extension&gt; tag, that is: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
name=3D"MapDefinitionType"&gt;</FONT><FONT face=3DArial=20
size=3D2><BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"heightInPixels"=20
type=3D"xsd:int"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"weightInPixels" type=3D"xsd:int"/&gt;</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;/sequence&gt;</FONT></DIV>
<DIV><FONT face=3DArial><FONT=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&lt;complexType/ &gt;) </FONT></FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks a lot for your =
help,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT></DIV>
<DIV><BR>-- <BR>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; escribi=F3 en =
el mensaje=20
<A=20
href=3D"news:daek1p$4sb$1@news.eclipse.org">news:daek1p$4sb$1@news.eclips=
e.org</A>...</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">Fran,<BR><BR>What=20
you describe is exactly what I expect.&nbsp; That is, if you get=20
ScaleMapDefinitions's content type, look at that particle's model =
group's=20
first particle, that particle will be exactly the same particle as you =
get for=20
MapRequest's content type.&nbsp; In other words, the content type of =
an=20
extended complex type reuses (refers to) the content type of the base=20
type.<BR><BR><BR>Fran wrote:=20
<BLOCKQUOTE cite=3Dmiddaejdh$3vt$1@news.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi again Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I will try to explain with more =
detail the=20
results I obtain. I'm using this code in an recursive method and it =
works=20
for all the &lt;complexType&gt; elements without problems, except =
for the=20
ones including an &lt;extension&gt; tag.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now, l will try to trace for you =
the execution=20
of the program:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 1. As input, the complexType=20
"targetComplexDefinition" </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; is =
the=20
following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
=
name=3D"ScaleMapDefinition"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </=
FONT><FONT=20
face=3DArial=20
=
size=3D2>&lt;complexContent&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;=20
&lt;extension=20
=
base=3D"tns1:MapDefinitionType"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=
&lt;sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"centerPoint"=20
=
type=3D"tns3:GeoCoord"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"pixelSize"=20
=
type=3D"xsd:double"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&lt;/sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
&lt;/extension&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/complexContent&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/complexType&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 2. The program proceed without =
error until=20
the arrow I have writen:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XSDParticle =
complexTypeContent =3D=20
</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; =
(XSDParticle)=20
=
targetComplexDefinition.getContentType();<BR>&nbsp;&nbsp;&nbsp;XSDModelGr=
oup=20
xsdModelGroup =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(XSDModelGroup)complexTypeContent.getContent();<BR>&nbsp;&nbsp; =
</FONT><FONT=20
face=3DArial size=3D2>listOfElements =3D =
xsdModelGroup.getContents();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;&nbsp;Iterator =
elementsIterator =3D=20
=
listOfElements.iterator();<BR>&nbsp;&nbsp;while(elementsIterator.hasNext(=
))<BR>&nbsp;&nbsp;{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;------&gt;&nbsp;&nbsp; =
XSDParticle=20
elementParticle =3D </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (XSDParticle)=20
=
elementsIterator.next();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp;=20
&nbsp;XSDElementDeclaration element =3D </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
=
(XSDElementDeclaration)elementParticle.getContent();</FONT> </DIV></FONT><=
/DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Step 3. And then, and suddendly, =
the input of=20
the method (targetComplexDefinition)</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; =
(you can=20
see at step 1)&nbsp;</FONT><FONT face=3DArial size=3D2>changes to =
the following=20
value:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &lt;complexType=20
=
name=3D"MapRequest"&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;=
sequence&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"itiTrace" nillable=3D"true"=20
=
type=3D"tns2:ItineraryTrace"/&gt;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&lt;element name=3D"mapDefinition" nillable=3D"true"=20
=
type=3D"tns1:ScaleMapDefinition"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
&lt;/sequence&gt;<BR>&nbsp;&nbsp;&nbsp; =
&lt;/complexType&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As you see, this complexType =
contains an=20
element called "tns1:ScaleMapDefinition", which</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is the original input.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Believe me. I really don't =
understand what's=20
happen... I hope this post would be clear enough </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>so you could help me.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thank you very much,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Fran</FONT><BR>--=20
<BR></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0017_01C58219.4D1B8690--
Re: Analysing Complex Types derived by extension [message #596053 is a reply to message #62485] Wed, 06 July 2005 10:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000702020309080105090901
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Fran,

You are only showing me tiny little snips of your schemas (and of of
your code) so I just assumed when you showed me the second type that is
was the base of the first type. I see that it isn't. I think so far
you've essentially asked the same question three times and you've
asserted odd things like you've recovered wrong information and that
suddenly the input of the method changed, but none of that is really
helping clarify what you are actually doing and if anything serves to
confuse things further. I've told you that you can't blindly assume the
the content of the particle is an element, but you show the same code
again a second time without change. I don't get it...

I'm not a patient person and I don't want to repeat what I've already
said, so here goes one last attempt. The content model of a complex
type is a tree of particles, where the getContent() of each particle can
be an element declaration, a model group, a wildcard, or a model group
definition, and the getTerm() of each particle, which resolves element
references and model group definition references, can be an element
declaration, a model group, or a wildcard. If you want to walk the
concrete/physical structure as it appears in the source schema, you can
walk the complex type's getContent and the particle's getContent; if you
want to walk the abstract/logical structure as defined in the XML Schema
specification, you can walk the complex type's getContentType() and the
particle's getTerm(). That's all there is and those methods are
sufficient for all your purposes, so it's best to figure out how to make
those work and if you have a problem to show clearly and precisely all
the code you are executing and all the the schema constructs being
analyzed, not just snips and bits. The bottom line is that there is no
flat list of all the elements, there is only a tree and you must walk it
recursively.


Fran wrote:

> Ed,
> I thought the base type for "ScaleMapDefitinion" was
> "tns1:MapDefinitionType".......:
>
> <complexType name="ScaleMapDefinition">
> <complexContent>
> ----- > <extension base="TNS1:MapDefinitionType">
> <sequence>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> ........And not "MapRequest". But reading your response, I see I was
> wrong.
>
> Nevertheless, is there any way to obtain the elements in the sequence
> in "ScaleMapDefinition" complexType? In other words, I'm talking about
> obtaining a List, collection or whatever, containing:
>
> <element name="centerPoint" type="tns3:GeoCoord"/>
> <element name="pixelSize" type="xsd:double"/>
> AND
> <element name="heightInPixels" type="xsd:int"/>
> <element name="weightInPixels" type="xsd:int"/>
>
> (Obviously, the last two elements come from the base of the
> <extension> tag, that is:
> <complexType name="MapDefinitionType">
> <sequence>
> <element name="heightInPixels" type="xsd:int"/>
> <element name="weightInPixels" type="xsd:int"/>
> </sequence>
> <complexType/>)
>
> Thanks a lot for your help,
> Fran
>
> --
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> escribi


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to get default and fixed value of an XSDElementDeclaration?
Next Topic:SetCommand and the XSDSimpleTypeDefinition LexicalFinal attribute
Goto Forum:
  


Current Time: Thu Apr 18 18:22:34 GMT 2024

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

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

Back to the top