ORE-private-repo / SPARQL Templates.txt
SPARQL Templates.txt
Raw
#NodeExists_GR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  FILTER NOT EXISTS { ?s ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI }
  BIND(STR('Node @@ConstrainedNodeBrowseName@@ does not exist') as ?msg)
}

#NodeExists_GR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  FILTER NOT EXISTS { ?s ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI }
  BIND(STR('Node http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType does not exists') as ?msg)
}




#AttributeExists_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  ?s ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
  FILTER NOT EXISTS { ?s @@AttributeName@@ ?o }
  BIND(STR('@@ConstrainedNodeBrowseName@@ @@AttributeName@@ does not exist') as ?msg)
}

#AttributeExists_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  ?s ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  FILTER NOT EXISTS { ?s ta:isAbstract ?o }
  BIND(STR('http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType ta:isAbstract does not exist') as ?msg)
}




#AttributeHasSpecificValue_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  ?s ta:browseName \"@@BrowseName@@\"^^xsd:anyURI .
  FILTER NOT EXISTS { ?s @@AttributeName@@ @@Value@@ }
  BIND(STR('@@BrowseName@@ @@AttributeName@@ is not @@Value@@') as ?msg)
}

#AttributeHasSpecificValue_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?msg
WHERE {
  ?s ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  FILTER NOT EXISTS { ?s ta:isAbstract false }
  BIND(STR('http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType ta:isAbstract is not false') as ?msg)
}




#EnumerationFieldExists_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE{
  FILTER NOT EXISTS {
    ?enumerationField a ?enumerationDataTypeNode .
    ?enumerationDataTypeNode ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
    ?enumerationField rdfs:label \"@@EnumString@@\"
  }
  BIND(STR('@@ConstrainedNodeBrowseName@@ does not specify a field with EnumString @@EnumString@@') as ?msg)
}

#EnumerationFieldExists_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE{
  FILTER NOT EXISTS {
    ?enumerationField a ?enumerationDataTypeNode .
    ?enumerationDataTypeNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceCategoryEnumeration"^^xsd:anyURI .
    ?enumerationField rdfs:label "OTHER"
  }
  BIND(STR('http://opcfoundation.org/UA/Robotics/MotionDeviceCategoryEnumeration does not specify a field with EnumString OTHER') as ?msg)
}




#EnumerationFieldHasValue_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE{
  ?enumerationField a ?enumerationDataTypeNode .
  ?enumerationDataTypeNode ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
  ?enumerationField rdfs:label \"@@EnumString@@\" .
  FILTER NOT EXISTS {
    ?enumerationField ia:value \"@@Value@@\"^^xsd:unsignedInt;
  }
  BIND(STR('Value of enumeration field @@ConstrainedNodeBrowseName@@ @@EnumString@@ is not @@Value@@') as ?msg)
}


#EnumerationFieldHasValue_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE{
  ?enumerationField a ?enumerationDataTypeNode .
  ?enumerationDataTypeNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceCategoryEnumeration"^^xsd:anyURI .
  ?enumerationField rdfs:label "OTHER" .
  FILTER NOT EXISTS {
    ?enumerationField ia:value "0"^^xsd:unsignedInt;
  }
  BIND(STR('Value of enumeration field http://opcfoundation.org/UA/Robotics/MotionDeviceCategoryEnumeration OTHER is not 0') as ?msg)
}




#MethodArgumentExists_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?msg
WHERE {
  ?s ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
  
  ?s rdfs:subClassOf ?blankNode1 .
  ?blankNode1 ?p1 ?methodNode .
  ?methodNode ta:browseName \"@@MethodBrowseName@@\"^^xsd:anyURI .
  
  FILTER NOT EXISTS {
    ?methodNode rdfs:subClassOf ?blankNode2 .
    ?blankNode2 ?p2 ?inputArgumentsNode .
    ?inputArgumentsNode ta:browseName \"http://opcfoundation.org/UA/InputArguments\"^^xsd:anyURI
  }
  BIND(STR('Method @@MethodBrowseName@@ of node @@ConstrainedNodeBrowseName@@ does not reference an InputArguments node') as ?msg)
}

#MethodArgumentExists_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?msg
WHERE {
  ?s ta:browseName \"http://opcfoundation.org/UA/DI/LockingServicesType\"^^xsd:anyURI .
  
  ?s rdfs:subClassOf ?blankNode1 .
  ?blankNode1 ?p1 ?methodNode .
  ?methodNode ta:browseName \"http://opcfoundation.org/UA/DI/InitLock\"^^xsd:anyURI .
  
  FILTER NOT EXISTS {
    ?methodNode rdfs:subClassOf ?blankNode2 .
    ?blankNode2 ?p2 ?inputArgumentsNode .
    ?inputArgumentsNode ta:browseName \"http://opcfoundation.org/UA/InputArguments\"^^xsd:anyURI
  }
  BIND(STR('Method http://opcfoundation.org/UA/DI/InitLock of node http://opcfoundation.org/UA/DI/LockingServicesType does not reference an InputArguments node') as ?msg)
}




#NodeIsSubtypeOf_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>

SELECT  ?referencedNode
WHERE {
  
  ?typeNode ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
 
  FILTER NOT EXISTS {
    ?typeNode rdfs:subClassOf \"@@ReferencedNodeBrowseName@@\".
  }
  BIND(CONCAT(ConstrainedNodeBrowseName is no subtype of  \"@@ReferencedNodeBrowseName@"@") as ?msg)
}


#NodeIsSubtypeOf_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?instance ?referencedNode
WHERE {
  
  ?typeNode ta:browseName "http://opcfoundation.org/UA/Robotics/Controls"^^xsd:anyURI .
 
  FILTER NOT EXISTS {
    ?typeNode rdfs:subPropertyOf ns0:hierarchicalReferences.
  }
  BIND(CONCAT(STR(?instance), STR(' is no subtype of  http://opcfoundation.org/UA/hierarchicalReferences')) as ?msg)
}
  

#ReferencedNodeHasTypeDefinition_TR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName \"@@BrowseName@@\"^^xsd:anyURI .
  ?instance ns0:hasComponent ?referencedNode .
  ?referencedNode ia:browseName \"@@ReferencedNodeBrowseName@@\"^^xsd:anyURI .

  FILTER NOT EXISTS {
    ?referencedNode ns0:hasTypeDefinition ?typeDefinitionNode .
    ?typeDefinitionNode ta:browseName \"@@TypeDefinition@@\"^^xsd:anyURI
  }
  BIND(CONCAT(STR(?instance), STR(' does not specifiy hasTypeDefinition @@TypeDefinition@@')) as ?msg)
}


#ReferencedNodeHasTypeDefinition_TR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  ?instance ns0:hasComponent ?referencedNode .
  ?referencedNode ia:browseName "http://opcfoundation.org/UA/Robotics/MotionDevices"^^xsd:anyURI .

  FILTER NOT EXISTS {
    ?referencedNode ns0:hasTypeDefinition ?typeDefinitionNode .
    ?typeDefinitionNode ta:browseName "http://opcfoundation.org/UA/FolderType"^^xsd:anyURI
  }
  BIND(CONCAT(STR(?instance), STR(' does not specifiy hasTypeDefinition http://opcfoundation.org/UA/FolderType')) as ?msg)
}


#ReferenceCardinalityExactly_TR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
  ?instance ?referenceType ?referencedNode .
  ?referencedNode ia:browseName \"@@ReferencedNodeBrowseName@@\"^^xsd:anyURI .
  BIND(CONCAT(STR(?instance), STR(' does not reference exactly @@Cardinality@@ @@ReferencedNodeBrowseName@@')) as ?msg)
}
GROUP BY ?referencedNode ?msg
HAVING (COUNT(?referencedNode) != @@Value@@)


#ReferenceCardinalityExactly_TR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  ?instance ns0:hasComponent ?referencedNode .
  ?referencedNode ia:browseName "http://opcfoundation.org/UA/Robotics/MotionDevices"^^xsd:anyURI .
  BIND(CONCAT(STR(?instance), STR(' does not reference exactly 1 http://opcfoundation.org/UA/Robotics/MotionDevices')) as ?msg)
}
GROUP BY ?referencedNode ?msg
HAVING (COUNT(?referencedNode) != 1)




#ReferencedNodeHasDataType_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE {
  ?s ta:browseName \"@@BrowseName@@\"^^xsd:anyURI .
  FILTER NOT EXISTS {
    ?s rdfs:subClassOf rdfs:subClassOf/(<>|!<>) ?referencedNode1 .
    ?referencedNode1 ta:browseName \"@@ReferencedNodeBrowseName@@\"^^xsd:anyURI .
  
    ?referencedNode1 rdfs:subClassOf/(<>|!<>) ?referencedNode2 .
    ?referencedNode2 ta:dataType \"@@DataTypeDefinition@@\"^^xsd:anyURI
  }
BIND(STR('@@BrowseName@@ does not reference a node with browseName @@ReferencedNodeBrowseName@@ of DataType @@DataTypeDefinition@@') as ?msg) }
  

#ReferencedNodeHasDataType_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE {
  ?s ta:browseName \"http://opcfoundation.org/UA/Robotics/MotionDeviceType\"^^xsd:anyURI .
  FILTER NOT EXISTS {
    ?s rdfs:subClassOf rdfs:subClassOf/(<>|!<>) ?referencedNode1 .
    ?referencedNode1 ta:browseName \"http://opcfoundation.org/UA/DI/Manufacturer\"^^xsd:anyURI .
  
    ?referencedNode1 rdfs:subClassOf/(<>|!<>) ?referencedNode2 .
    ?referencedNode2 ta:dataType \"http://opcfoundation.org/UA/LocalizedText\"^^xsd:anyURI
  }
BIND(STR('http://opcfoundation.org/UA/Robotics/MotionDeviceType does not reference a node with browseName http://opcfoundation.org/UA/DI/Manufacturer of DataType http://opcfoundation.org/UA/LocalizedText') as ?msg) }




#ReferencedNodeHasNodeClass_NR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE {
  ?s ta:browseName \"@@ConstrainedNodeBrowseName@@\"^^xsd:anyURI .
  FILTER NOT EXISTS {
    ?s rdfs:subClassOf/(<>|!<>) ?referencedNode .
    ?referencedNode ta:browseName \"@@ReferencedNodeBrowseName@@\"^^xsd:anyURI .
    ?referencedNode ta:nodeClass \"@@NodeClass@@\"^^xsd:int
    }
  BIND(STR('@@ConstrainedNodeBrowseName@@ does not reference a node with browseName @@ReferencedNodeBrowseName@@ and node class @@NodeClass@@') as ?msg)
}

#ReferencedNodeHasNodeClass_NR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?msg
WHERE {
  ?s ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  FILTER NOT EXISTS {
    ?s rdfs:subClassOf/(<>|!<>) ?referencedNode .
    ?referencedNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDevices"^^xsd:anyURI .
    ?referencedNode ta:nodeClass "1"^^xsd:int
    }
  BIND(STR('http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType does not reference a node with browseName http://opcfoundation.org/UA/Robotics/MotionDevices and node class 1') as ?msg)
}




#ReferencedNodeHasNodeClass_TR TEMPLATE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName \"@@BrowseName@@\"^^xsd:anyURI .
  ?instance ns0:hasComponent ?referencedNode .
  ?referencedNode ia:browseName \"@@ReferencedNodeBrowseName@@\"^^xsd:anyURI .

  FILTER NOT EXISTS {
    ?referencedNode ia:nodeClass \"@@NodeClassIndex@@\"^^xsd:int
  }
  BIND(CONCAT(STR(?instance), STR(' does not reference a node with browse name @@ReferencedNodeBrowseName@@ and node class @@NodeClassIndex@@')) as ?msg)
}

#ReferencedNodeHasNodeClass_TR EXAMPLE
PREFIX ta: <http://opcfoundation.org/UA/Meta/TA/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns0: <http://opcfoundation.org/UA/>
PREFIX ia:  <http://opcfoundation.org/UA/Meta/IA/> 

SELECT ?msg
WHERE {
  ?instance ns0:hasTypeDefinition ?typeNode .
  ?typeNode ta:browseName "http://opcfoundation.org/UA/Robotics/MotionDeviceSystemType"^^xsd:anyURI .
  ?instance ns0:hasComponent ?referencedNode .
  ?referencedNode ia:browseName "http://opcfoundation.org/UA/Robotics/MotionDevices"^^xsd:anyURI .

  FILTER NOT EXISTS {
    ?referencedNode ia:nodeClass "1"^^xsd:int
  }
  BIND(CONCAT(STR(?instance), STR(' does not reference a node with browse name http://opcfoundation.org/UA/Robotics/MotionDevices and node class 1')) as ?msg)
}