Referenced attributes [message #70674] |
Thu, 23 November 2006 10:02  |
Eclipse User |
|
|
|
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 10:26   |
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 #70828 is a reply to message #70703] |
Thu, 23 November 2006 11:05  |
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 10:26  |
Eclipse User |
|
|
|
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 #599184 is a reply to message #70703] |
Thu, 23 November 2006 11:05  |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.06907 seconds