#!/usr/bin/env python

import coral
import coral.util.search.query as Q

prj=coral.loadDocument("testMatchQueryTargetElement.xml")

query_set=None
target_set=None

for elem in prj.contents():
    if elem.oclIsKindOf(coral.lang.UML14.Model):
        if elem.name=="Query":
            query_set=elem.ownedElement
        if elem.name=="Target":
            target_set=elem.ownedElement

assert len(query_set)>2
assert len(target_set)>5



for t_elem in target_set:
    match=Q.match_query_elem(query_set, t_elem)
    if match:
        print match
    else:
        assert 0
            
