An Ontology-Driven Approach for the Syntactic and Semantic Validation of SPARQL Queries
DOI:
https://doi.org/10.19153/cleiej.29.3.2Keywords:
SPARQL, SHACL, Semantic Web, OWL Ontology, Syntactic and Semantic ValidationAbstract
The Semantic Web enables data exchange and knowledge exploitation through SPARQL queries; however, users often encounter difficulties when formulating such queries, leading to unexpected results and iterative trial-and-error processes. These issues are aggravated by incomplete knowledge of the application domain and the underlying ontological schema, frequently causing unnecessary query executions and increased computational load on RDF repositories. This work proposes a method for the prior syntactic and semantic validation of SPARQL queries, based on an ontology and independent of its instances. The method operates before query execution and detects inconsistencies arising from literal writing errors and violations of object property axioms, providing explicit feedback to users. The development of the proposed approach follows a classical methodological framework grounded in the software engineering process. Experimental results show that the additional computational overhead introduced by validation is minimal, while the benefits are significant in scenarios involving incorrect queries. In particular, prior validation prevents the execution of erroneous queries, reduces processing time, and maintains negligible overhead for correct queries, demonstrating a favorable trade-off between computational efficiency and reduced manual intervention. Overall, the results indicate that prior validation improves SPARQL query quality and enhances developer productivity in semantic data–driven applications.
References
J. Collio, A. Aguilera, and I. Dongo, “Efficient method for validating sparql queries using semantic web ontologies,” in 2025 LI Latin American Computer Conference (CLEI), 2025, pp. 1–10.
A. Patel and S. Jain, “Present and future of semantic web technologies: A research statement,” International Journal of Computers and Applications, vol. 43, no. 5, pp. 413–422, 2021.
A. Loizou, R. Angles, and P. Groth, “On the formulation of performant SPARQL queries,” Journal of Web Semantics, vol. 31, pp. 1–26, 2015.
J. Almendros-Jim´enez and A. Becerra-Ter´on, “Debugging of wrong and missing answers in SPARQL,” in 18th International Symposium on Database Programming Languages. NY, USA: ACM, 2021, p. 7–16.
K. Kim, B. Moon, and H.-J. Kim, “R3F: RDF triple filtering method for efficient SPARQL query processing,” World Wide Web, vol. 18, no. 2, pp. 317–357, Mar 2015.
Y. Amsterdamer and Y. Callen, “Interactive SPARQL query formulation using provenance,” knowledge and Information Systems, vol. 66, no. 3, pp. 2165–2191, Mar 2024.
S. Subhashree and P. S. Kumar, “Augmenting linked data ontologies with new object properties,” New Generation Computing, vol. 38, no. 1, pp. 125–152, Mar 2020.
B. Lakzaei and M. Shamsfard, “Ontology learning from relational databases,” Information Sciences, vol. 577, pp. 280–297, 2021.
H. Silvennoinen, A. Chadzynski, F. Farazi, A. Gri?si¯ut?e, Z. Shi, A. von Richthofen, S. Cairns, M. Kraft,M. Raubal, and P. Herthogs, “A semantic web approach to land use regulations in urban planning: TheOntoZoning ontology of zones, land uses and programmes for Singapore,” Journal of Urban Management, vol. 12, no. 2, pp. 151–167, 2023.
T. Berners-Lee, J. Hendler, and O. Lassila, “The Semantic Web: A New Form of Web Content that is Meaningful to Computers will Unleash a Revolution of New Possibilities”, 1st ed. New York, NY, USA: Association for Computing Machinery, 2023, p. 91–103.
O. Lassila and J. Hendler, “Embracing ‘Web 3.0’,” IEEE Internet Computing, vol. 11, no. 3, pp. 90–93, 2007.
D. Wu, H.-T. Wang, and A. U. Tansel, “A survey for managing temporal data in RDF,” Information Systems, vol. 122, p. 102368, 2024.
L. Parkin, B. Chardin, S. Jean, and A. Hadjali, “Explaining unexpected answers of SPARQL queries,” in Web Information Systems Engineering. Cham: Springer International Publishing, 2022, pp. 136–151.
O. Cur´e and G. Blin, “RDF Database Systems: Triples Storage and SPARQL Query Processing”’, 1st ed. USA: Elsevier, 2015.
O. H. Jader, S. Zeebaree, and R. R. Zebari, “A state of art survey for web server performance measurement and load balancing mechanisms,” International Journal of Scientific & Technology Research, vol. 8, no. 12, pp. 535–543, 2019.
R. Pressman, “Ingenier´?a del software un enfoque pr´actico”, 7th ed. McGRAW-HILL, 2010.
E. Guzel Kalayci, T. E. Kalayci, and D. Birant, “An ant colony optimisation approach for optimising SPARQL queries by reordering triple patterns,” Information Systems, vol. 50, pp. 51–68, 2015.
C. Liu, H. Wang, Y. Yu, and L. Xu, “Towards efficient SPARQL query processing on RDF data,” Tsinghua Science & Technology, vol. 15, no. 6, pp. 613–622, 2010.
S. Saharan, J. Lather, and R. Radhakrishnan, “Optimisation using rearrangement of order of BGP and TLBO approach,” Procedia Computer Science, vol. 125, pp. 282–289, 2018, the 6th International Conference on Smart Computing and Communications.
J. M. Almendros-Jim´enez, A. Becerra-Ter´on, and A. Cuzzocrea, “Syntactic and semantic validation of SPARQL queries,” in Symposium on Applied Computing. NY, USA: ACM, 2017, p. 349–352.
J. M. Almendros-Jim´enez and A. Becerra-Ter´on, “Discovery and diagnosis of wrong SPARQL queries with ontology and constraint reasoning,” Expert Systems with Applications, vol. 165, p. 113772, 2021.
I. Dongo, Y. Cardinale, and R. Chbeir, “RDF-F: RDF datatype inferring framework,” Data Science and Engineering, vol. 3, no. 2, pp. 115–135, Jun 2018.
K. Abicht, “OWL reasoners still useable in 2023,” 2023, arXiv:2309.06888.
A. N. Lam, B. Elvesæter, and F. Martin-Recuerda, “A performance evaluation of OWL 2 DL reasoners using ORE 2015 and very large bio ontologies,” in 1st International Workshop on Data Management for Knowledge Graphs. RWTH Aachen University, 2023.
A. Gashkov, A. Perevalov, M. Eltsova, and A. Both, “Improving question answering quality through language feature-based SPARQL query candidate validation,” in The Semantic Web. Cham: Springer International Publishing, 2022, pp. 217–235.
Z. B. Ozger and N. Y. Uslu, “An effective discrete artificial bee colony based SPARQL query path optimization by reordering triples,” Journal of Computer Science and Technology, vol. 36, no. 2, pp. 445–462, 2021.
N. Guido, “On the Static Analysis for SPARQL Queries Using Modal Logic,” in IJCAI 2015, Buenos Aires, Argentina, Jul. 2015.
K. Rabbani, M. Lissandrini, and K. Hose, “SHACL and ShEx in the wild: A community survey on validating shapes generation and adoption,” in Companion Proceedings of the Web Conference. NY, USA: ACM, 2022, p. 260–263.
R. B. Thapa and M. Giese, “Optimizing SPARQL queries with SHACL,” in The Semantic Web – ISWC 2023. Cham: Springer Nature Switzerland, 2023, pp. 41–60.
J. Corman, F. Florenzano, J. L. Reutter, and O. Savkovic, “Validating SHACL constraints over a SPARQL endpoint,” in The Semantic Web – ISWC 2019. Springer, 2019, pp. 145–163.
A. Oudshoorn, M. Ortiz, and M. Simkus, “SHACL validation in the presence of ontologies: Semantics ? and rewriting techniques,” Artificial Intelligence, vol. 352, p. 104483, 2026.
C. Wang, L. Zhang, and W. Yan, “Enhancement and validation of ifcOWL ontology based on shapes constraint language (SHACL),” Automation in Construction, vol. 160, p. 105293, 2024.
J. Collio, A. Aguilera, and I. Dongo, “Toward an enrichment of ontologies inferred from RDF documents,” IEEE Access, vol. 12, pp. 148 037–148 056, 2024.
Y. M. Saber, H. Abdel-Galil, and M. A. E. F. Belal, “Arabic ontology extraction model from unstructured text,” Journal of King Saud University-Computer and Information Sciences, vol. 34, no. 8, B, pp. 6066–6076, Sep 2022.
G. Stumme, A. Hotho, and B. Berendt, “Semantic web mining: State of the art and future directions,” Journal of Web Semantics, vol. 4, no. 2, pp. 124–143, 2006, semantic Grid –The Convergence of Technologies.
W. hao Chen, Y. Cai, H. fung Leung, and Q. Li, “Generating ontologies with basic level concepts from folksonomies,” Procedia Computer Science, vol. 1, no. 1, pp. 573–581, 2010, iCCS 2010.
B. DuCharme, “Learning SPARQL: querying and updating with SPARQL 1.1”, 2nd ed. USA: O’Reilly Media, 2013.
B. Ben Mahria, I. Chaker, and A. Zahi, “A novel approach for learning ontology from relational database: From the construction to the evaluation,” Journal of Big Data, vol. 8, no. 1, pp. 1–22, Dec. 2021.
K. Alaoui, “A categorization of RDF triplestores,” in SCA 19: 4th International Conference on Smart City Applications. NY, USA: ACM, 2019, pp. 1–7.
V. Senthooran, “Review of querying RDF techniques with SPARQL in semantic web technologies,” International Journal of Scientific & Engineering Research, vol. 3, no. 10, pp. 36–38, 2015.
F. Saïs, C. Pruski, and M. Da Silveira, “Inferring the evolution of ontology axioms from RDF data dynamics,” in 9th Knowledge Capture Conference, ser. K-CAP ’17. NY, USA: ACM, 2017.
A.-C. N. Ngomo, S. Auer, J. Lehmann, and A. Zaveri, “Introduction to Linked Data and Its Lifecycle on the Web”. Cham: Springer International Publishing, 2014, pp. 1–99.
P. Pareti and G. Konstantinidis, “A Review of SHACL: From Data Validation to Schema Reasoning for RDF Graphs”’. Cham: Springer International Publishing, 2022, pp. 115–144.
L. Jean-Baptiste, Accessing ontologies in Python. Berkeley, CA: Apress, 2021, pp. 83–112.
D. International, “DAMA Guia Para o Corpo de Conhecimento em Gerenciamento de Dados”, 1st ed. Sao Pablo-Brasil: Technics Publications, 2012.
Downloads
Published
Issue
Section
License
Copyright (c) 2026 JUAN COLLIO BARRA, Ana Aguilera, Irvin Dongo

This work is licensed under a Creative Commons Attribution 4.0 International License.
CLEIej is supported by its home institution, CLEI, and by the contribution of the Latin American and international researchers community, and it does not apply any author charges whatsoever for submitting and publishing. Since its creation in 1998, all contents are made publicly accesibly. The current license being applied is a (CC)-BY license (effective October 2015; between 2011 and 2015 a (CC)-BY-NC license was used).