xquery with objectref

I have two doctypes that one is conected to the other with objectref.
there is a pair doctype that has inself data from student doctype.
how can i get the data from the second doctype in xquery?
in the first mail i did not send the pair doc.

<?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs=“XML Schema” xmlns:tsd=“http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition”>
- xs:annotation
- xs:appinfo
- <tsd:schemaInfo name=“students”>
<tsd:collection name=“example1” />
- <tsd:doctype name=“student”>
- tsd:logical
tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
- tsd:adminInfo
tsd:versionTSD3</tsd:version>
tsd:created2002-02-12T21:32:22.828+02:00</tsd:created>
tsd:modified2002-02-12T21:32:22.828+02:00</tsd:modified>
</tsd:adminInfo>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
- <xs:element name=“student”>
- xs:complexType
- xs:sequence
<xs:element name=“name” type=“xs:int” />
<xs:element name=“age” type=“xs:string” />
<xs:element name=“faculty” type=“xs:string” />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


<?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs=“XML Schema” xmlns:tsd=“http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition”>
- xs:annotation
- xs:appinfo
- <tsd:schemaInfo name=“pairs”>
<tsd:collection name=“example1” />
- <tsd:doctype name=“pair”>
- tsd:logical
tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
- tsd:adminInfo
tsd:versionTSD3</tsd:version>
tsd:created2002-02-12T21:42:25.593+02:00</tsd:created>
tsd:modified2002-02-12T21:42:25.593+02:00</tsd:modified>
</tsd:adminInfo>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
- <xs:element name=“pair”>
- xs:complexType
- xs:sequence
- <xs:element name=“name” type=“xs:int”>
- xs:annotation
- xs:appinfo
- tsd:elementInfo
- tsd:physical
- tsd:native
- tsd:objectRef
tsd:collectionRefexample1</tsd:collectionRef>
<tsd:dereference />
- <tsd:accessPredicate operator=“=”>
tsd:nodeRefstudent/name</tsd:nodeRef>
</tsd:accessPredicate>
</tsd:objectRef>
</tsd:native>
</tsd:physical>
</tsd:elementInfo>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Hello Arnon Ben Yakar,

could you please tell us which version of Tamino you would like to do this with?

Could you please also clarify whether you would like to use XQuery or X-Query for the queries?
(XQuery is only supported from Tamino 4.1 onwards, so the answer to the first question may already answer the second question!)

Greetings,
Trevor.

Hello Trevor
Today I am going to start with the 4.1 version
but I would like to do this with x-query.
I have another question
whay there isn’t something similar to aql primary key in Tamino?
I can load the same instance many times to the same doctype.(I can “do” primary key in aplication level but I would like the Tamino to do it for me)
thank you for your replay,
Arnon.

Hello,
I am also not sure whether you want to use Tamino XQuery 4 or X-Query.
If you want to access objectref Mapping in Tamino XQuery 4 you have to formulate the join your self in the query. To get the same effect as the objectref mapping you can use such a query:

for $a in input()/collaboration
return {
$a/node() [local-name(.) != “jazzMusician”],
$a/@,
for $c in input()/jazzMusician
where $a/jazzMusician/@ID = $c/@ID
return {
$a/jazzMusician/text(),
$c/node(),
$c/@

}
}


Depending on whether you have mixed content or you know your elements in the query, the query can be simpler.

The query is for the attached example schema in a documentation chapter.

Best regards
Walter



<xs:element name = “collaboration”>
xs:complexType
xs:sequence
<xs:element name = “name” type = “xs:string”>
xs:annotation
xs:appinfo
tsd:elementInfo
tsd:physical
tsd:native
tsd:index
tsd:standard</tsd:standard>
</tsd:index>
</tsd:native>
</tsd:physical>
</tsd:elementInfo>
</xs:appinfo>
</xs:annotation>
</xs:element>
xs:choice
<xs:element name = “performedAt”>
xs:complexType
xs:all
<xs:element name = “location” type = “xs:string”></xs:element>
<xs:element name = “time” type = “xs:dateTime”></xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name = “period”>
xs:complexType
xs:sequence
<xs:element name = “from” type = “xs:date”></xs:element>
<xs:element name = “to” type = “xs:date” minOccurs = “0”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:element name = “jazzMusician” minOccurs = “2” maxOccurs = “unbounded”>
xs:complexType
<xs:attribute name = “ID” type = “xs:NMTOKEN” use = “required”>
xs:annotation
xs:appinfo
tsd:attributeInfo
tsd:physical
tsd:native
tsd:index
tsd:standard</tsd:standard>
</tsd:index>
tsd:objectRef
tsd:collectionRefencyclopedia1</tsd:collectionRef>
<tsd:accessPredicate operator = “=”>
tsd:nodeRefjazzMusician/@ID</tsd:nodeRef>
</tsd:accessPredicate>
</tsd:objectRef>
</tsd:native>
</tsd:physical>
</tsd:attributeInfo>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name = “result” minOccurs = “0” maxOccurs = “unbounded”>
xs:complexType
<xs:attribute name = “albumNo” type = “xs:NMTOKEN” use = “required”></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name = “type” use = “required”>
xs:simpleType
<xs:restriction base = “xs:NMTOKEN”>
<xs:enumeration value = “jamSession”></xs:enumeration>
<xs:enumeration value = “project”></xs:enumeration>
<xs:enumeration value = “band”></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name = “ID” type = “xs:NMTOKEN” use = “required”></xs:attribute>
</xs:complexType>
</xs:element>

Hello Arnon,

I will leave the query questions to Walter, but I would like to point you to the “Unique Constraints Server Extension” that is available for download in the Community.

I believe that this will provide the behaviour that you would like to see.
The Server Extension will reject inserts of/updates to documents which will lead to none-unique values in defined keys.

I hope that helps,
Trevor.