Hi all,
My question is about what happens when an element
with an anonymous type is defined in a group. Then when the group is referenced
in several locations, is it the same anonymous type or they’re actually
different types (of course with the same definition)?
When an anonymous type is used (e.g. in a XSLT or
XQuery) XDM (XQuery 1.0 and XPath 2.0 Data Model) says that anonymous
types must be given a unique name:
For anonymous types, the processor
must
construct an http://www.w3.org/TR/xpath-datamodel/#dt-anonymous-type-name#dt-anonymous-type-name that is distinct from the
name of every named type and the name of every other anonymous type. [Definition: An anonymous
type name is an implementation dependent, unique type name provided by the
processor for every anonymous type declared in the schemas available.]
Anonymous type names must be globally
unique across all anonymous types that are accessible to the processor. In the
formalism of this specification, the anonymous type names are assumed to be xs:QNames, but in practice implementations are
not required to use xs:QNames to
represent the implementation-dependent names of anonymous types.
Imagine we have this schema:
<xsd:group name="myGroup">
<xsd:sequence>
<xsd:element name="myElement">
<xsd:complexType>
<xsd:sequence>
…………………………………………………………………………………………………………………..
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:group>
<xsd:element name="parent1">
<xsd:complexType>
<xsd:group ref="myGroup"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="parent2">
<xsd:complexType>
<xsd:group ref="myGroup"/>
</xsd:complexType>
</xsd:element>
The question is:
Do myElement local element in parent1 and parent2 have
the same type? Or are they different as they’re local elements with
anonymous types?
So should myElement type in parent1 have a different unique-name
to myElement type in parent2? Or should they have the same unique name?
I mean, is a group like a “copy/paste” so
when a reference is done to a group is just like putting the group content there
(so it would be like declaring a anonymous type twice)? Or implementation can
be a bit “clever” and realise that they’re really the same
type even if it’s anonymous and assign the same unique name to myElement
type in both parent1 and parent2.
Thanks a lot.
Regards,
Leo Antoli