Home » Archived » XML Schema Definition (XSD) » How to retrieve Attributes for a complex ElementDeclaration
How to retrieve Attributes for a complex ElementDeclaration [message #51267] |
Mon, 23 August 2004 17:51  |
Eclipse User |
|
|
|
Originally posted by: gj.puredge.com
Hi,
Given the schema fragment:
<xsd:element name="Test">
<xsd:complexType>
<xsd:choice>
<xsd:element ref="comment"></xsd:element>
<xsd:element name="choice2" type="xsd:string"></xsd:element>
</xsd:choice>
<xsd:attribute name="Attribute" type="xsd:string"></xsd:attribute>
</xsd:complexType>
</xsd:element>
From the complexType particle, getTerm() gets the "choice" ModelGroup.
Which method gets the attribute(s)?
Sorry for such a newbie question.
Thanks
|
|
| | | |
Re: How to retrieve Attributes for a complex ElementDeclaration [message #51538 is a reply to message #51512] |
Tue, 24 August 2004 10:37   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------020405000909090205010801
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Gary,
Yes, that's exactly right. ;-)
Gary J wrote:
>Thanks Ed,
>
>getAttributeContents vs getAttributeUses
>
>Am I correct that this is another example of the difference between the
>"Concrete" and "Abstract" representations of the schema?
>
>The Concrete representation is what's actually written in the schema file
>itself whereas Abstract is (sort of) the "expanded" version of the schema
>with all the inherited types, groups, refs, etc available.
>
>I'd use the Concrete model if I wanted to serialize (write) the schema and
>the Abstract to walk the schema elements, among other things.
>
>I think I'm actually starting to get a clue. That perhaps qualifies me a
>"cluebie" .
>
>
>
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:cgf9ov$ujg$1@eclipse.org...
>Gary,
>
>Yes, the contents will always be of type XSDAttributeUse, so there's no
>need for a instanceof check. Note that getAttributeContents returns the
>physically contained attribute declarations whereas getAttributeUses
>will get the inherited ones as well as the local ones just as getContent
>returns the physically contained content model (particle/simple type)
>whereas getContentType will return the inherited content model as well.
>
>
>Gary J wrote:
>
>
>
>>I think I found what I need. Here's some code I wrote to print out
>>attributes for an element. Correct me if I'm wrong.
>>
>>Starting with: ElementDeclaration element
>>
>>XSDTypeDefinition type = element.getTypeDefinition();
>>
>>if (type instanceof XSDComplexTypeDefinition)
>> {
>> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>>
>> for (Iterator iter = list.iterator(); iter.hasNext();)
>> {
>> Object obj = iter.next();
>> if (obj instanceof XSDAttributeUse)
>> {
>> XSDAttributeUse a = (XSDAttributeUse) obj;
>> System.out.println(a.getAttributeDeclaration().getName());
>> }
>> }
>> }
>>
>>I'm not sure if the results of getAttributeContents() are always an
>>instance
>>of XSDAttributeUse so I check just in case.
>>
>>
>>
>>
>>
>>
>
>
>
>
--------------020405000909090205010801
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gary,<br>
<br>
Yes, that's exactly right. ;-)<br>
<br>
<br>
Gary J wrote:<br>
<blockquote cite="midcgfjbg$i5q$1@eclipse.org" type="cite">
<pre wrap="">Thanks Ed,
getAttributeContents vs getAttributeUses
Am I correct that this is another example of the difference between the
"Concrete" and "Abstract" representations of the schema?
The Concrete representation is what's actually written in the schema file
itself whereas Abstract is (sort of) the "expanded" version of the schema
with all the inherited types, groups, refs, etc available.
I'd use the Concrete model if I wanted to serialize (write) the schema and
the Abstract to walk the schema elements, among other things.
I think I'm actually starting to get a clue. That perhaps qualifies me a
"cluebie" .
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:cgf9ov$ujg$1@eclipse.org">news:cgf9ov$ujg$1@eclipse.org</a>...
Gary,
Yes, the contents will always be of type XSDAttributeUse, so there's no
need for a instanceof check. Note that getAttributeContents returns the
physically contained attribute declarations whereas getAttributeUses
will get the inherited ones as well as the local ones just as getContent
returns the physically contained content model (particle/simple type)
whereas getContentType will return the inherited content model as well.
Gary J wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I think I found what I need. Here's some code I wrote to print out
attributes for an element. Correct me if I'm wrong.
Starting with: ElementDeclaration element
XSDTypeDefinition type = element.getTypeDefinition();
if (type instanceof XSDComplexTypeDefinition)
{
EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
for (Iterator iter = list.iterator(); iter.hasNext();)
{
Object obj = iter.next();
if (obj instanceof XSDAttributeUse)
{
XSDAttributeUse a = (XSDAttributeUse) obj;
System.out.println(a.getAttributeDeclaration().getName());
}
}
}
I'm not sure if the results of getAttributeContents() are always an
instance
of XSDAttributeUse so I check just in case.
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------020405000909090205010801--
|
|
|
attribute use from declaration [message #54280 is a reply to message #51538] |
Wed, 27 October 2004 02:49   |
Eclipse User |
|
|
|
Originally posted by: user.domain.invalid
Sorry to drop this question..may be stupid one
How can one get XSDAttributeUse for an attribute from attributedeclaration.
best
roy
Ed Merks wrote:
> Gary,
>
> Yes, that's exactly right. ;-)
>
>
> Gary J wrote:
>
>>Thanks Ed,
>>
>>getAttributeContents vs getAttributeUses
>>
>>Am I correct that this is another example of the difference between the
>>"Concrete" and "Abstract" representations of the schema?
>>
>>The Concrete representation is what's actually written in the schema file
>>itself whereas Abstract is (sort of) the "expanded" version of the schema
>>with all the inherited types, groups, refs, etc available.
>>
>>I'd use the Concrete model if I wanted to serialize (write) the schema and
>>the Abstract to walk the schema elements, among other things.
>>
>>I think I'm actually starting to get a clue. That perhaps qualifies me a
>>"cluebie" .
>>
>>
>>
>>
>>"Ed Merks" <merks@ca.ibm.com> wrote in message
>>news:cgf9ov$ujg$1@eclipse.org...
>>Gary,
>>
>>Yes, the contents will always be of type XSDAttributeUse, so there's no
>>need for a instanceof check. Note that getAttributeContents returns the
>>physically contained attribute declarations whereas getAttributeUses
>>will get the inherited ones as well as the local ones just as getContent
>>returns the physically contained content model (particle/simple type)
>>whereas getContentType will return the inherited content model as well.
>>
>>
>>Gary J wrote:
>>
>>
>>
>>>I think I found what I need. Here's some code I wrote to print out
>>>attributes for an element. Correct me if I'm wrong.
>>>
>>>Starting with: ElementDeclaration element
>>>
>>>XSDTypeDefinition type = element.getTypeDefinition();
>>>
>>>if (type instanceof XSDComplexTypeDefinition)
>>> {
>>> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>>>
>>> for (Iterator iter = list.iterator(); iter.hasNext();)
>>> {
>>> Object obj = iter.next();
>>> if (obj instanceof XSDAttributeUse)
>>> {
>>> XSDAttributeUse a = (XSDAttributeUse) obj;
>>> System.out.println(a.getAttributeDeclaration().getName());
>>> }
>>> }
>>> }
>>>
>>>I'm not sure if the results of getAttributeContents() are always an
>>>instance
>>>of XSDAttributeUse so I check just in case.
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
|
|
|
Re: attribute use from declaration [message #54307 is a reply to message #54280] |
Wed, 27 October 2004 13:00  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Roy,
If the attribute use is not the container
(XSDConcreteComponent.getContainer()) of the attribute declaration, then
there isn't a way since there can be arbitrarily many attributes uses
that share a particular attribute declaration (because they have "ref"
to it).
user@domain.invalid wrote:
>
> Sorry to drop this question..may be stupid one
>
> How can one get XSDAttributeUse for an attribute from
> attributedeclaration.
>
> best
>
> roy
>
> Ed Merks wrote:
>
>> Gary,
>>
>> Yes, that's exactly right. ;-)
>>
>>
>> Gary J wrote:
>>
>>> Thanks Ed,
>>>
>>> getAttributeContents vs getAttributeUses
>>>
>>> Am I correct that this is another example of the difference between
>>> the "Concrete" and "Abstract" representations of the schema?
>>>
>>> The Concrete representation is what's actually written in the schema
>>> file itself whereas Abstract is (sort of) the "expanded" version of
>>> the schema with all the inherited types, groups, refs, etc available.
>>>
>>> I'd use the Concrete model if I wanted to serialize (write) the
>>> schema and the Abstract to walk the schema elements, among other
>>> things.
>>>
>>> I think I'm actually starting to get a clue. That perhaps qualifies
>>> me a "cluebie" .
>>>
>>>
>>>
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:cgf9ov$ujg$1@eclipse.org...
>>> Gary,
>>>
>>> Yes, the contents will always be of type XSDAttributeUse, so there's no
>>> need for a instanceof check. Note that getAttributeContents returns
>>> the
>>> physically contained attribute declarations whereas getAttributeUses
>>> will get the inherited ones as well as the local ones just as
>>> getContent
>>> returns the physically contained content model (particle/simple type)
>>> whereas getContentType will return the inherited content model as well.
>>>
>>>
>>> Gary J wrote:
>>>
>>>
>>>
>>>> I think I found what I need. Here's some code I wrote to print out
>>>> attributes for an element. Correct me if I'm wrong.
>>>>
>>>> Starting with: ElementDeclaration element
>>>>
>>>> XSDTypeDefinition type = element.getTypeDefinition();
>>>>
>>>> if (type instanceof XSDComplexTypeDefinition)
>>>> {
>>>> EList list = ((XSDComplexTypeDefinition)
>>>> type).getAttributeContents();
>>>>
>>>> for (Iterator iter = list.iterator(); iter.hasNext();)
>>>> {
>>>> Object obj = iter.next();
>>>> if (obj instanceof XSDAttributeUse)
>>>> {
>>>> XSDAttributeUse a = (XSDAttributeUse) obj;
>>>> System.out.println(a.getAttributeDeclaration().getName());
>>>> }
>>>> }
>>>> }
>>>>
>>>> I'm not sure if the results of getAttributeContents() are always an
>>>> instance
>>>> of XSDAttributeUse so I check just in case.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>
|
|
|
Re: How to retrieve Attributes for a complex ElementDeclaration [message #590790 is a reply to message #51267] |
Mon, 23 August 2004 23:15  |
Eclipse User |
|
|
|
I think I found what I need. Here's some code I wrote to print out
attributes for an element. Correct me if I'm wrong.
Starting with: ElementDeclaration element
XSDTypeDefinition type = element.getTypeDefinition();
if (type instanceof XSDComplexTypeDefinition)
{
EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
for (Iterator iter = list.iterator(); iter.hasNext();)
{
Object obj = iter.next();
if (obj instanceof XSDAttributeUse)
{
XSDAttributeUse a = (XSDAttributeUse) obj;
System.out.println(a.getAttributeDeclaration().getName());
}
}
}
I'm not sure if the results of getAttributeContents() are always an instance
of XSDAttributeUse so I check just in case.
|
|
|
Re: How to retrieve Attributes for a complex ElementDeclaration [message #590923 is a reply to message #51293] |
Tue, 24 August 2004 07:48  |
Eclipse User |
|
|
|
Gary,
Yes, the contents will always be of type XSDAttributeUse, so there's no
need for a instanceof check. Note that getAttributeContents returns the
physically contained attribute declarations whereas getAttributeUses
will get the inherited ones as well as the local ones just as getContent
returns the physically contained content model (particle/simple type)
whereas getContentType will return the inherited content model as well.
Gary J wrote:
>I think I found what I need. Here's some code I wrote to print out
>attributes for an element. Correct me if I'm wrong.
>
>Starting with: ElementDeclaration element
>
> XSDTypeDefinition type = element.getTypeDefinition();
>
> if (type instanceof XSDComplexTypeDefinition)
> {
> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>
> for (Iterator iter = list.iterator(); iter.hasNext();)
> {
> Object obj = iter.next();
> if (obj instanceof XSDAttributeUse)
> {
> XSDAttributeUse a = (XSDAttributeUse) obj;
> System.out.println(a.getAttributeDeclaration().getName());
> }
> }
> }
>
>I'm not sure if the results of getAttributeContents() are always an instance
>of XSDAttributeUse so I check just in case.
>
>
>
>
|
|
|
Re: How to retrieve Attributes for a complex ElementDeclaration [message #590953 is a reply to message #51458] |
Tue, 24 August 2004 10:32  |
Eclipse User |
|
|
|
Thanks Ed,
getAttributeContents vs getAttributeUses
Am I correct that this is another example of the difference between the
"Concrete" and "Abstract" representations of the schema?
The Concrete representation is what's actually written in the schema file
itself whereas Abstract is (sort of) the "expanded" version of the schema
with all the inherited types, groups, refs, etc available.
I'd use the Concrete model if I wanted to serialize (write) the schema and
the Abstract to walk the schema elements, among other things.
I think I'm actually starting to get a clue. That perhaps qualifies me a
"cluebie" .
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:cgf9ov$ujg$1@eclipse.org...
Gary,
Yes, the contents will always be of type XSDAttributeUse, so there's no
need for a instanceof check. Note that getAttributeContents returns the
physically contained attribute declarations whereas getAttributeUses
will get the inherited ones as well as the local ones just as getContent
returns the physically contained content model (particle/simple type)
whereas getContentType will return the inherited content model as well.
Gary J wrote:
>I think I found what I need. Here's some code I wrote to print out
>attributes for an element. Correct me if I'm wrong.
>
>Starting with: ElementDeclaration element
>
> XSDTypeDefinition type = element.getTypeDefinition();
>
> if (type instanceof XSDComplexTypeDefinition)
> {
> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>
> for (Iterator iter = list.iterator(); iter.hasNext();)
> {
> Object obj = iter.next();
> if (obj instanceof XSDAttributeUse)
> {
> XSDAttributeUse a = (XSDAttributeUse) obj;
> System.out.println(a.getAttributeDeclaration().getName());
> }
> }
> }
>
>I'm not sure if the results of getAttributeContents() are always an
>instance
>of XSDAttributeUse so I check just in case.
>
>
>
>
|
|
|
Re: How to retrieve Attributes for a complex ElementDeclaration [message #590966 is a reply to message #51512] |
Tue, 24 August 2004 10:37  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------020405000909090205010801
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Gary,
Yes, that's exactly right. ;-)
Gary J wrote:
>Thanks Ed,
>
>getAttributeContents vs getAttributeUses
>
>Am I correct that this is another example of the difference between the
>"Concrete" and "Abstract" representations of the schema?
>
>The Concrete representation is what's actually written in the schema file
>itself whereas Abstract is (sort of) the "expanded" version of the schema
>with all the inherited types, groups, refs, etc available.
>
>I'd use the Concrete model if I wanted to serialize (write) the schema and
>the Abstract to walk the schema elements, among other things.
>
>I think I'm actually starting to get a clue. That perhaps qualifies me a
>"cluebie" .
>
>
>
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:cgf9ov$ujg$1@eclipse.org...
>Gary,
>
>Yes, the contents will always be of type XSDAttributeUse, so there's no
>need for a instanceof check. Note that getAttributeContents returns the
>physically contained attribute declarations whereas getAttributeUses
>will get the inherited ones as well as the local ones just as getContent
>returns the physically contained content model (particle/simple type)
>whereas getContentType will return the inherited content model as well.
>
>
>Gary J wrote:
>
>
>
>>I think I found what I need. Here's some code I wrote to print out
>>attributes for an element. Correct me if I'm wrong.
>>
>>Starting with: ElementDeclaration element
>>
>>XSDTypeDefinition type = element.getTypeDefinition();
>>
>>if (type instanceof XSDComplexTypeDefinition)
>> {
>> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>>
>> for (Iterator iter = list.iterator(); iter.hasNext();)
>> {
>> Object obj = iter.next();
>> if (obj instanceof XSDAttributeUse)
>> {
>> XSDAttributeUse a = (XSDAttributeUse) obj;
>> System.out.println(a.getAttributeDeclaration().getName());
>> }
>> }
>> }
>>
>>I'm not sure if the results of getAttributeContents() are always an
>>instance
>>of XSDAttributeUse so I check just in case.
>>
>>
>>
>>
>>
>>
>
>
>
>
--------------020405000909090205010801
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gary,<br>
<br>
Yes, that's exactly right. ;-)<br>
<br>
<br>
Gary J wrote:<br>
<blockquote cite="midcgfjbg$i5q$1@eclipse.org" type="cite">
<pre wrap="">Thanks Ed,
getAttributeContents vs getAttributeUses
Am I correct that this is another example of the difference between the
"Concrete" and "Abstract" representations of the schema?
The Concrete representation is what's actually written in the schema file
itself whereas Abstract is (sort of) the "expanded" version of the schema
with all the inherited types, groups, refs, etc available.
I'd use the Concrete model if I wanted to serialize (write) the schema and
the Abstract to walk the schema elements, among other things.
I think I'm actually starting to get a clue. That perhaps qualifies me a
"cluebie" .
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:cgf9ov$ujg$1@eclipse.org">news:cgf9ov$ujg$1@eclipse.org</a>...
Gary,
Yes, the contents will always be of type XSDAttributeUse, so there's no
need for a instanceof check. Note that getAttributeContents returns the
physically contained attribute declarations whereas getAttributeUses
will get the inherited ones as well as the local ones just as getContent
returns the physically contained content model (particle/simple type)
whereas getContentType will return the inherited content model as well.
Gary J wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I think I found what I need. Here's some code I wrote to print out
attributes for an element. Correct me if I'm wrong.
Starting with: ElementDeclaration element
XSDTypeDefinition type = element.getTypeDefinition();
if (type instanceof XSDComplexTypeDefinition)
{
EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
for (Iterator iter = list.iterator(); iter.hasNext();)
{
Object obj = iter.next();
if (obj instanceof XSDAttributeUse)
{
XSDAttributeUse a = (XSDAttributeUse) obj;
System.out.println(a.getAttributeDeclaration().getName());
}
}
}
I'm not sure if the results of getAttributeContents() are always an
instance
of XSDAttributeUse so I check just in case.
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------020405000909090205010801--
|
|
|
attribute use from declaration [message #592228 is a reply to message #51538] |
Wed, 27 October 2004 02:49  |
Eclipse User |
|
|
|
Sorry to drop this question..may be stupid one
How can one get XSDAttributeUse for an attribute from attributedeclaration.
best
roy
Ed Merks wrote:
> Gary,
>
> Yes, that's exactly right. ;-)
>
>
> Gary J wrote:
>
>>Thanks Ed,
>>
>>getAttributeContents vs getAttributeUses
>>
>>Am I correct that this is another example of the difference between the
>>"Concrete" and "Abstract" representations of the schema?
>>
>>The Concrete representation is what's actually written in the schema file
>>itself whereas Abstract is (sort of) the "expanded" version of the schema
>>with all the inherited types, groups, refs, etc available.
>>
>>I'd use the Concrete model if I wanted to serialize (write) the schema and
>>the Abstract to walk the schema elements, among other things.
>>
>>I think I'm actually starting to get a clue. That perhaps qualifies me a
>>"cluebie" .
>>
>>
>>
>>
>>"Ed Merks" <merks@ca.ibm.com> wrote in message
>>news:cgf9ov$ujg$1@eclipse.org...
>>Gary,
>>
>>Yes, the contents will always be of type XSDAttributeUse, so there's no
>>need for a instanceof check. Note that getAttributeContents returns the
>>physically contained attribute declarations whereas getAttributeUses
>>will get the inherited ones as well as the local ones just as getContent
>>returns the physically contained content model (particle/simple type)
>>whereas getContentType will return the inherited content model as well.
>>
>>
>>Gary J wrote:
>>
>>
>>
>>>I think I found what I need. Here's some code I wrote to print out
>>>attributes for an element. Correct me if I'm wrong.
>>>
>>>Starting with: ElementDeclaration element
>>>
>>>XSDTypeDefinition type = element.getTypeDefinition();
>>>
>>>if (type instanceof XSDComplexTypeDefinition)
>>> {
>>> EList list = ((XSDComplexTypeDefinition) type).getAttributeContents();
>>>
>>> for (Iterator iter = list.iterator(); iter.hasNext();)
>>> {
>>> Object obj = iter.next();
>>> if (obj instanceof XSDAttributeUse)
>>> {
>>> XSDAttributeUse a = (XSDAttributeUse) obj;
>>> System.out.println(a.getAttributeDeclaration().getName());
>>> }
>>> }
>>> }
>>>
>>>I'm not sure if the results of getAttributeContents() are always an
>>>instance
>>>of XSDAttributeUse so I check just in case.
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
|
|
|
Re: attribute use from declaration [message #592249 is a reply to message #54280] |
Wed, 27 October 2004 13:00  |
Eclipse User |
|
|
|
Roy,
If the attribute use is not the container
(XSDConcreteComponent.getContainer()) of the attribute declaration, then
there isn't a way since there can be arbitrarily many attributes uses
that share a particular attribute declaration (because they have "ref"
to it).
user@domain.invalid wrote:
>
> Sorry to drop this question..may be stupid one
>
> How can one get XSDAttributeUse for an attribute from
> attributedeclaration.
>
> best
>
> roy
>
> Ed Merks wrote:
>
>> Gary,
>>
>> Yes, that's exactly right. ;-)
>>
>>
>> Gary J wrote:
>>
>>> Thanks Ed,
>>>
>>> getAttributeContents vs getAttributeUses
>>>
>>> Am I correct that this is another example of the difference between
>>> the "Concrete" and "Abstract" representations of the schema?
>>>
>>> The Concrete representation is what's actually written in the schema
>>> file itself whereas Abstract is (sort of) the "expanded" version of
>>> the schema with all the inherited types, groups, refs, etc available.
>>>
>>> I'd use the Concrete model if I wanted to serialize (write) the
>>> schema and the Abstract to walk the schema elements, among other
>>> things.
>>>
>>> I think I'm actually starting to get a clue. That perhaps qualifies
>>> me a "cluebie" .
>>>
>>>
>>>
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:cgf9ov$ujg$1@eclipse.org...
>>> Gary,
>>>
>>> Yes, the contents will always be of type XSDAttributeUse, so there's no
>>> need for a instanceof check. Note that getAttributeContents returns
>>> the
>>> physically contained attribute declarations whereas getAttributeUses
>>> will get the inherited ones as well as the local ones just as
>>> getContent
>>> returns the physically contained content model (particle/simple type)
>>> whereas getContentType will return the inherited content model as well.
>>>
>>>
>>> Gary J wrote:
>>>
>>>
>>>
>>>> I think I found what I need. Here's some code I wrote to print out
>>>> attributes for an element. Correct me if I'm wrong.
>>>>
>>>> Starting with: ElementDeclaration element
>>>>
>>>> XSDTypeDefinition type = element.getTypeDefinition();
>>>>
>>>> if (type instanceof XSDComplexTypeDefinition)
>>>> {
>>>> EList list = ((XSDComplexTypeDefinition)
>>>> type).getAttributeContents();
>>>>
>>>> for (Iterator iter = list.iterator(); iter.hasNext();)
>>>> {
>>>> Object obj = iter.next();
>>>> if (obj instanceof XSDAttributeUse)
>>>> {
>>>> XSDAttributeUse a = (XSDAttributeUse) obj;
>>>> System.out.println(a.getAttributeDeclaration().getName());
>>>> }
>>>> }
>>>> }
>>>>
>>>> I'm not sure if the results of getAttributeContents() are always an
>>>> instance
>>>> of XSDAttributeUse so I check just in case.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>
|
|
|
Goto Forum:
Current Time: Sun May 11 16:54:55 EDT 2025
Powered by FUDForum. Page generated in 0.08115 seconds
|