find referenced entity

Dear All

I have some questions about effectively using Java API to query the data stored in Tamino DB. In my data schema there are lots of ID, IDREF and IDREFS. One entity should find the related entity by IDREF attribute. There are several levels of such references before the right data can be found. Currently I use X-Path to find the IDREF attribute in the entity. Then use this IDREF to find the refereced entity with the same ID.

For example:
I use
http: //localhost/tamino/test/simtech?_XQL=/BLIS-XML/IfcRelAssignsProperties
to query for IfcRelAssignsProperties entity. I got a lists of them.




Then I want to find RelatedObject. Its IDREF is “i962”. Thus I use following X-Path to find the entity with “i962” as its ID.

http: //localhost/tamino/test/simtech?_XQL=/BLIS-XML/node()[@XMLID=“i962”]
I got:


This method is not practical as the reference could be more than 5 levels. I need to write five different X-Path commands to find the result. And there are thousands of entities. It is unacceptably slow as this method needs to visit database too often. Is there any effective method that I can use just a few lines of code to find the final results?

Best regards
Aaron

Hello Aaron,

I have two questions:
   - which version of Tamino are you using?
   - does the query have to be in XPath?

If you have Tamino 4.x, you could use XQuery to write a single, richer query to return the result you want.

Greetings,
Trevor.

Dear Trevor

I am using Tamino 4.1.1.1. If XQuery is the right solution, I will use it.

My main purpose is for objects storage. My data model is object-oriented. I am wondering whether I can query the data as easy as OQL (Object Query Language). For example, in OQL, I can query as
“select person from Person where person.address.town=‘Amsterdam’”

Is it possible to query “person” in XML DB like “person/address/town”, where “address” is a IDREF attribute of “person”.

Regards
Aaron

Hello Aaron,

before I start exploring how rusty my OQL skills have become :), let’s have a look at an XQuery to accomplish the goal you set out in the initial posting.

I think that the easiest thing to do is just to combine the two XPath queries into a single XQuery, for example:

   for $ifcRel in input()/BLIS-XML/IfcRelAssignsProperties
   let $ifcRef := input()/BLIS-XML/node()[@XMLID = $ifcRel/@RelatedObjects]
   return $ifcRef</pre><BR>This is just a first go - we can refine/tune the query to work with your schema.  As I don't have the schema, I just made a simple test document (which you can find at the end of this posting).<BR><BR>This XQuery will iterate through all the /BLIS-XML/IfcRelAssignsProperties nodes, and return any child nodes where the value of the XMLID attribute matches that of the RelatedObjects attribute.<BR><BR>I wasn't entirely sure what you meant by "the reference could be more than 5 levels".  Perhaps it is the wrong approach, but I buried a matching node five levels deep in my test document (it is called IfcOther).<BR>The expression /BLIS-XML/node() will return three nodes from the test document: IfcRelAssignsProperties, levelOne (and all its children) and IfcWall.<BR>As there is no XMLID attribute in the levelOne node, this is not matched by the query and neither is (its child) the IfcOther node.<BR>To match this node the filter condition can be changed to [//@XMLID=...] so that the attribute is searched for on all levels (this costs more time, of course).<BR><BR>I hope that this helps, but if it doesn't answer all your questions please let me know.<BR>The next step should probably be to have a look at the schema, some example documents and example results that you would like to get from the queries.<BR><BR>Greetings,<BR>Trevor.<BR><BR>The test XML Document:<BR><pre class="ip-ubbcode-code-pre">
<?xml version="1.0" encoding="UTF-8" ?>
<BLIS-XML>
   <IfcRelAssignsProperties DomainView="Generic"
                            GlobalId="|.CYF$>o+Hw=#rH0,xe8"
                            OwnerHistory="i501"
                            RelatedIsDependent="0"
                            RelatedObjects="i962"
                            RelatingIsDependent="1"
                            RelatingPropertyDefinition="i554"
                            XMLID="i606" />
   <levelOne>
      <levelTwo>
         <levelThree>
            <levelFour>
               <levelFive>
                  <IfcOther GlobalId="gRB*gk/YT?w=slF/,,=!"
                            Label="Top wall#5"
                            LayerInformation="i480"
                            LocalPlacement="i431"
                            OwnerHistory="i501"
                            Representations="i519"
                            XMLID="i962"
                            calcWallArea="35"
                            calcWallVolume="8.75" />
               </levelFive>
            </levelFour>
         </levelThree>
      </levelTwo>
   </levelOne>
   <IfcWall GlobalId="gRB*gk/YT?w=slF/,,=!"
            Label="Top wall#5"
            LayerInformation="i480"
            LocalPlacement="i431"
            OwnerHistory="i501"
            Representations="i519"
            XMLID="i962"
            calcWallArea="35"
            calcWallVolume="8.75" />
</BLIS-XML>

Hello Trevor

I think I should clarify the meaning of ‘five levels’ in my first email. Here is an example. (My comments were behind “//”.) If I want to get the location information of a IfcWall, I have to query the following seven entities.

<IfcWall ino:id=“1” GlobalId=“8K$0:dtX3&b?sBqh=/`#”
Label=“Wall#273”
LayerInformation=“i8571” LocalPlacement=“i8339”
OwnerHistory=“i8659”
Representations=“i12570” XMLID=“i19768”
calcWallArea=“0” calcWallVolume=“0”
/>

//Representations of IfcWall is IDREFS. In this case it has only one value, which points to an
IfcProductDefinitionShape

<IfcProductDefinitionShape ino:id=“1”
GlobalId=“UmdsmP^<5+>CZ~>0Hrxi”
OwnerHistory=“i8659” ShapeRepresentations=“i13365
i13366” XMLID=“i12570”
/>

//ShapeRepresentations of ifcProductDefinitionShape is IDREFS. It has two values in this case, one of which point to an IfcShapeRepresentation entity

<IfcShapeRepresentation ino:id=“1”
ContextOfItems=“i7867” Items=“i285”
RepresentationIdentifier=“IAI”
RepresentationType=“Standard”
XMLID=“i13365” />
//Items of IfcShapeRepresentation is an IDREFS. It has only one value in this case. It points to an IfcAttrDrivenExtrudedSolid entity

<IfcAttDrivenExtrudedSolid ino:id=“1” Segments=“i68”
XMLID=“i285” />
//Segments of IfcAttDrivenExtrudedSolid is an IDREFS. It has one value in this case. It points to an IfcAttDrivenExtrudedSegment entity.

<IfcAttDrivenExtrudedSegment ino:id=“1” Depth=“4000”
Position=“i702”
ProfileDef=“i12799” XMLID=“i68” />
//Position is an IDREF. It points to IfcAxis2Placement3D

<IfcAxis2Placement3D ino:id=“1” Axis=“i7496”
Location=“i6982”
RefDirection=“i7495” XMLID=“i702” />
//Location is an IDREF, which points to
IfcCartesianPoint






//Finally the information I need is here.

There are tens of thousands of entity data.

I have attached the zipped XML schema file with this post.

Aaron
BLIS_XML_IFC20_longform_CL.zip (16.5 KB)

Hi Trevor

Let me explain my intention further.

My objective is to find a general method for select, update, and delete partial model data that contains specific part of product model data. If there is a idref, I need to get the selected referenced entity recursively (The referenced objects of referenced objects). There are some models to describle the operation. For example, in PMQL of IMSvr (a IFC data model server for architecture, structure and construction industry), the problem in my last post can be described as





















I need to implement this or similar methodology on Tamino database.

I think this problem should be a common problem faced by other people, as the response XML document with broken references can not be validated.

Best regards
Aaron

Hi All

I have tried to solve the problem. First I indexed XMLID. Then I use XPath to query all IDREFS. Then use XPath to find the entity with XMLID that euqals to IDREFS. It seems not a good algorithm, but it works.

My XML data file is more than 2M (20892 lines). When I use XQuery to do some simple query (like find IfcRelAssignsProperties in the example Trevor’s second post), the response is either very slow or returns error information. So I choose XPath finally.

Hope this information is helpful to others :slight_smile:

Aaron

Hi Aaron,

you might check out Tamino 4.1.4, which has been released lately. It should have some performance improvements on the XQuery-side.

regards,

Timm

Hello Aaron,

I’m sorry, I lost track of this thread!

Timm’s suggestion is a good one - XQuery performance has been improved in Tamino 4.1.4.

In addition to [or instead of] this, you could post the Tamino schema you are using, the document(s) and queries (or the code which generates the queries) to the Forum and we can try and help improve performance.

Greetings,
Trevor.