SPARQL DROP MACRO  LIBRARY <urn:spin:nanotation:demo:royal:family:lib> ; 

SPARQL

PREFIX  rel:  <http://purl.org/vocab/relationship/> 

## CREATE SPIN LIBRARY <urn:spin:nanotation:demo:royal:family:lib>

CREATE SPIN LIBRARY <urn:spin:nanotation:demo:royal:family:lib> {
  CLASS <#RoyalPerson> {
    				comment """
								Class instance generated from a Macro that customizes relations such as
								rel:siblingOf while introducing new relations such as <#hasAuntie>, <#hasUncle>, and <#hasCousin> . 
							"""
					
     			   	defmacro rel:ancestorOf { ?this rel:ancestorOf ?n } 
											{{ 
												{ ?this rel:parentOf+ ?n . }
												UNION 
												{ ?this rel:siblingOf ?n . }
												FILTER ( NOT EXISTS {?this rel:siblingOf|^rel:siblingOf ?n} )			

											}}
											
	 			   	defmacro rel:descendantOf { ?this rel:descendantOf ?n } 
											{{ 
												{ ?this ^rel:parentOf+ ?n . }		

											}}
											
     			   	defmacro rel:sibingOf  { ?this rel:siblingOf ?n } 
										   {{ 
										   	  [] rel:parentOf ?this, ?n.  
										         FILTER (?n != ?this) .
										   }}
										   
				   	defmacro <#hasAuntie>  { ?this <#hasAuntie> ?n } 
										  {{				 
											  [] rel:parentOf ?this ; 
											     rel:siblingOf ?n . 
												 ?n a <#FemalePerson> .
										  }}	
										  	
  				   	defmacro <#hasUncle>  { ?this <#hasUncle> ?n } 
  										  {{				 
  											  [] rel:parentOf ?this ; 
  											     rel:siblingOf ?n . 
  												 ?n a <#MalePerson> .
  										  }}	
										  
				   	defmacro <#hasCousin>  { ?this <#hasCousin> ?n } 
										  {{				 
											  [] rel:parentOf ?n ;  
											     rel:siblingOf [ rel:parentOf ?this ] .
										  }}			   									   
    			}
}
ASK FROM virtrdf: 
WHERE { ?s <nosuch> ?o } ;
