Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Referenced attributes
Referenced attributes [message #70674] Thu, 23 November 2006 05:02 Go to next message
Alexander Koezle is currently offline Alexander Koezle
Messages: 13
Registered: July 2009
Junior Member
Hi,

i have a little problem by retrieving of top-level attributes referenced
in <xsd:attribute/> by "ref".

E.g. we have the following schema:

<!-- top level attribute -->
<xsd:attribute name="attr1" type="xsd:string"/>

<!-- complex type that reference that attribute -->
<xsd:complexType name="complexType1">
<xsd:attribute ref="attr1"/>
</xsd:complexType>

<!-- complex type that extends defined above complex type -->
<xsd:complexType name="extComplexType1">
<xsd:complexContent>
<xsd:extension base="complexType1">
<xsd:attribute name="extAttr1" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

1. I can reach the attribute "attr1" on the complex type "complexType1" by
calling of XSDComplexTypeDefinition#getAttributeContents instead of
XSDComplexTypeDefinition#getAttributeUses

2. XSDComplexTypeDefinition#getAttributeContents on the extension
"extComplexType1" doesn't return the "attr1" in the list, so i should
check all my base types recursive to find all "ref"-attributes that i
missing.

So here is my first question - how can i distinguish those
"ref"-attributes from the "normal"? - it seems to be also the instance of
XSDAttributeUse in the list, returned by
XSDComplexTypeDefinition#getAttributeContents

And why don't return the "ref"-attributes in
XSDComplexTypeDefinition#getAttributeUses like by referencing of an
attribute group? What is the difference?

thanks and warm regards,
Alexander
Re: Referenced attributes [message #70689 is a reply to message #70674] Thu, 23 November 2006 05:26 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Alexander,

Comments below.


Alexander Koezle wrote:
> Hi,
>
> i have a little problem by retrieving of top-level attributes
> referenced in <xsd:attribute/> by "ref".
>
> E.g. we have the following schema:
>
> <!-- top level attribute -->
> <xsd:attribute name="attr1" type="xsd:string"/>
> <!-- complex type that reference that attribute -->
> <xsd:complexType name="complexType1">
> <xsd:attribute ref="attr1"/>
> </xsd:complexType>
>
> <!-- complex type that extends defined above complex type -->
> <xsd:complexType name="extComplexType1">
> <xsd:complexContent>
> <xsd:extension base="complexType1">
> <xsd:attribute name="extAttr1" type="xsd:string" />
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> 1. I can reach the attribute "attr1" on the complex type
> "complexType1" by calling of
> XSDComplexTypeDefinition#getAttributeContents instead of
> XSDComplexTypeDefinition#getAttributeUses
If you are doing semantic analysis, rather than syntactic analysis,
you'd probably want to use the later rather than the former.
> 2. XSDComplexTypeDefinition#getAttributeContents on the extension
> "extComplexType1" doesn't return the "attr1" in the list, so i should
> check all my base types recursive to find all "ref"-attributes that i
> missing.
Yep. In the syntax, extAttr1 is all that appears in the
extComplexType1, so you'd have to follow all the syntax up the
inheritance chain to find all things this way.
>
> So here is my first question - how can i distinguish those
> "ref"-attributes from the "normal"? - it seems to be also the instance
> of XSDAttributeUse in the list, returned by
> XSDComplexTypeDefinition#getAttributeContents
Given an XSDAttributeUse, getContent and getAttributeDeclaration will
return different things in the case of an attribute reference. In that
case, the former will return an XSDAttributeDeclaration for which
isAttributeDeclarationReference is true and the later will return the
getResolvedAttributeDeclaration. So if getContent and
getAttributeDeclarations return different things (and when
getContent().isAttributeDeclarationReference() is true), then you are
looking at an attribute declaration reference.
>
> And why don't return the "ref"-attributes in
> XSDComplexTypeDefinition#getAttributeUses like by referencing of an
> attribute group?
I'm not sure I understand this comment. The getAttributeUses will
return exactly what's specified in the XML Schema specification, i.e.,
the set of attributes uses of the complex type.
> What is the difference?
If I understand correctly, the difference is between semantics (which
follows what the XML Schema specification says) verses syntax, which
models exactly the concrete syntax so that you can manipulate it directly.
>
> thanks and warm regards,
> Alexander
>
Re: Referenced attributes [message #70703 is a reply to message #70674] Thu, 23 November 2006 05:46 Go to previous messageGo to next message
Alexander Koezle is currently offline Alexander Koezle
Messages: 13
Registered: July 2009
Junior Member
sorry, forget it
i have defined that "ref" as "prohibited" (not in the example), great
Re: Referenced attributes [message #70815 is a reply to message #70689] Thu, 23 November 2006 05:51 Go to previous messageGo to next message
Alexander Koezle is currently offline Alexander Koezle
Messages: 13
Registered: July 2009
Junior Member
hi Ed,
thank you for your quick answer and your explanations.
getContent().isAttributeDeclarationReference() works

best regards
Alexander
Re: Referenced attributes [message #70828 is a reply to message #70703] Thu, 23 November 2006 06:05 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Alexander,

Yeah. Prohibited attributes effectively disappear from the semantic
model for the restricted complex type. Just as the base content type is
completely replaced by a new version of it for a restricted type.


Alexander Koezle wrote:
> sorry, forget it
> i have defined that "ref" as "prohibited" (not in the example), great
>
Re: Referenced attributes [message #599161 is a reply to message #70674] Thu, 23 November 2006 05:26 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25746
Registered: July 2009
Senior Member
Alexander,

Comments below.


Alexander Koezle wrote:
> Hi,
>
> i have a little problem by retrieving of top-level attributes
> referenced in <xsd:attribute/> by "ref".
>
> E.g. we have the following schema:
>
> <!-- top level attribute -->
> <xsd:attribute name="attr1" type="xsd:string"/>
> <!-- complex type that reference that attribute -->
> <xsd:complexType name="complexType1">
> <xsd:attribute ref="attr1"/>
> </xsd:complexType>
>
> <!-- complex type that extends defined above complex type -->
> <xsd:complexType name="extComplexType1">
> <xsd:complexContent>
> <xsd:extension base="complexType1">
> <xsd:attribute name="extAttr1" type="xsd:string" />
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> 1. I can reach the attribute "attr1" on the complex type
> "complexType1" by calling of
> XSDComplexTypeDefinition#getAttributeContents instead of
> XSDComplexTypeDefinition#getAttributeUses
If you are doing semantic analysis, rather than syntactic analysis,
you'd probably want to use the later rather than the former.
> 2. XSDComplexTypeDefinition#getAttributeContents on the extension
> "extComplexType1" doesn't return the "attr1" in the list, so i should
> check all my base types recursive to find all "ref"-attributes that i
> missing.
Yep. In the syntax, extAttr1 is all that appears in the
extComplexType1, so you'd have to follow all the syntax up the
inheritance chain to find all things this way.
>
> So here is my first question - how can i distinguish those
> "ref"-attributes from the "normal"? - it seems to be also the instance
> of XSDAttributeUse in the list, returned by
> XSDComplexTypeDefinition#getAttributeContents
Given an XSDAttributeUse, getContent and getAttributeDeclaration will
return different things in the case of an attribute reference. In that
case, the former will return an XSDAttributeDeclaration for which
isAttributeDeclarationReference is true and the later will return the
getResolvedAttributeDeclaration. So if getContent and
getAttributeDeclarations return different things (and when
getContent().isAttributeDeclarationReference() is true), then you are
looking at an attribute declaration reference.
>
> And why don't return the "ref"-attributes in
> XSDComplexTypeDefinition#getAttributeUses like by referencing of an
> attribute group?
I'm not sure I understand this comment. The getAttributeUses will
return exactly what's specified in the XML Schema specification, i.e.,
the set of attributes uses of the complex type.
> What is the difference?
If I understand correctly, the difference is between semantics (which
follows what the XML Schema specification says) verses syntax, which
models exactly the concrete syntax so that you can manipulate it directly.
>
> thanks and warm regards,
> Alexander
>
Re: Referenced attributes [message #599168 is a reply to message #70674] Thu, 23 November 2006 05:46 Go to previous message
Alexander Koezle is currently offline Alexander Koezle
Messages: 13
Registered: July 2009
Junior Member
sorry, forget it
i have defined that "ref" as "prohibited" (not in the example), great
Re: Referenced attributes [message #599175 is a reply to message #70689] Thu, 23 November 2006 05:51 Go to previous message
Alexander Koezle is currently offline Alexander Koezle
Messages: 13
Registered: July 2009
Junior Member
hi Ed,
thank you for your quick answer and your explanations.
getContent().isAttributeDeclarationReference() works

best regards
Alexander
Re: Referenced attributes [message #599184 is a reply to message #70703] Thu, 23 November 2006 06:05 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25746
Registered: July 2009
Senior Member
Alexander,

Yeah. Prohibited attributes effectively disappear from the semantic
model for the restricted complex type. Just as the base content type is
completely replaced by a new version of it for a restricted type.


Alexander Koezle wrote:
> sorry, forget it
> i have defined that "ref" as "prohibited" (not in the example), great
>
Previous Topic:Referenced attributes
Next Topic:URIConverter question.
Goto Forum:
  


Current Time: Sat Apr 19 16:00:37 EDT 2014

Powered by FUDForum. Page generated in 0.03317 seconds