String tns = xs.getTargetNamespace();
rest.adjust(xs.ont);
List<OntClass> restrictions = new Vector<OntClass>();
// minCardinality (and cardinality)
for (String key: rest.getMinCard().keySet()) {
OntModel ont = rest.getModel(key);
OntProperty p = ont.createOntProperty(key);
Integer minCard = rest.getMinCard().get(key);
// maxCard includes occurrences of any
Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key), rest.getAny(key,tns));
if (maxCard!=null && minCard==maxCard)
restrictions.add(xs.ont.createCardinalityRestriction(null,p,minCard));
else if (minCard>0)
restrictions.add(xs.ont.createMinCardinalityRestriction(null,p,minCard));
}
// maxCardinality
for (String key: rest.getMaxCard().keySet()) {
OntModel ont = rest.getModel(key);
OntProperty p = ont.createOntProperty(key);
int m = rest.getMaxCard().get(key);
if (m==Integer.MAX_VALUE) continue;
Integer minCard = rest.getMinCard().get(key);
Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key), rest.getAny(key,tns));
if (minCard==null || minCard!=maxCard)
restrictions.add(xs.ont.createMaxCardinalityRestriction(null,p,maxCard));
}
// add value restrictions
for (String key: rest.getRange().keySet()) {
OntModel ont = rest.getModel(key);
OntProperty p = ont.getOntProperty(key);
Set<Resource> s = rest.getRange().get(key);
if (s.size()==1) {
Resource t = s.iterator().next();