Advertisement

Declarative XML Schema Validation with SWI–Prolog

System Description
  • Falco Nogatz
  • Jona Kalkus
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10997)

Abstract

Xml Schema is a well–established mechanism to define the structure and constrain the content of an Xml document. While this approach taken by itself is declarative, currently available tools for Xml validation are not. In this paper we introduce an implementation of an Xsd validator in Swi–Prolog, made publicly available as the package library(xsd). Our approach is based on flattening the Xsd and Xml documents into Prolog facts. The top–down validation makes great use of Prolog’s backtracking and unification capabilities. To ensure the compliance to the Xsd standard and to support the test–driven development, we have created a test framework based on the Test Anything Protocol and Swi–Prolog’s quasi–quotations.

Keywords

Xml Schema Xsd Xml Swi–Prolog Validation Quasi–quotation 

References

  1. 1.
    Bray, T., Paoli, J., Sperberg-McQueen, C.M., Maler, E., Yergeau, F.: Extensible markup language (XML). World Wide Web J. 2(4), 27–66 (1997)Google Scholar
  2. 2.
    Fallside, D.C., Walmsley, P.: XML schema part 0: primer second edition. W3C Recommendation (2004)Google Scholar
  3. 3.
    Gao, S., Sperberg-McQueen, C.M., Thompson, H.S., Mendelsohn, N., Beech, D., Maloney, M.: W3C XML schema definition language (XSD) 1.1 part 1: structures. W3C Candidate Recommendation (2009)Google Scholar
  4. 4.
    Clark, J., DeRose, S., et al.: XML path language (XPath) version 1.0 (1999)Google Scholar
  5. 5.
    Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-Prolog. Theor. Pract. Log. Program. 12(1–2), 67–96 (2012)MathSciNetCrossRefGoogle Scholar
  6. 6.
    Specification of the Test Anything Protocol. https://testanything.org/tap-specification.html. Accessed 12 Mar 2018
  7. 7.
    Wielemaker, J., Hendricks, M.: Why it’s nice to be quoted: quasiquoting for prolog. In: Proceedings of 23rd Workshop on Logic-based Methods in Programming Environments (WLPE) (2013)Google Scholar
  8. 8.
    Beckett, D., McBride, B.: RDF/XML syntax specification (revised). W3C recommendation 10(2.3) (2004)Google Scholar
  9. 9.
    Wielemaker, J., Schreiber, G., Wielinga, B.: Prolog-based infrastructure for RDF: scalability and performance. In: Fensel, D., Sycara, K., Mylopoulos, J. (eds.) ISWC 2003. LNCS, vol. 2870, pp. 644–658. Springer, Heidelberg (2003).  https://doi.org/10.1007/978-3-540-39718-2_41CrossRefGoogle Scholar
  10. 10.
    Wielemaker, J., Huang, Z., Van Der Meij, L.: SWI-Prolog and the web. Theor. Pract. Log. Program. 8(3), 363–392 (2008)MathSciNetCrossRefGoogle Scholar
  11. 11.
    Wielemaker, J., Beek, W., Hildebrand, M., van Ossenbruggen, J.: Cliopatria: a SWI-Prolog infrastructure for the semantic web. Semant. Web 7(5), 529–541 (2016)CrossRefGoogle Scholar
  12. 12.
    Goldfarb, C.F., Rubinsky, Y.: The SGML Handbook. Oxford University Press, Oxford (1990)zbMATHGoogle Scholar
  13. 13.
    Wielemaker, J.: SWI-Prolog SGML/XML parser. SWI, University of Amsterdam, Roetersstraat 15, 1018 (2005)Google Scholar
  14. 14.
    Seipel, D.: Processing XML-documents in prolog. In: Workshop on Logic Programming (WLP) (2002)Google Scholar
  15. 15.
    Seipel, D., Baumeister, J., Hopfner, M.: Declaratively querying and visualizing knowledge bases in Xml. In: Seipel, D., Hanus, M., Geske, U., Bartenstein, O. (eds.) INAP/WLP-2004. LNCS (LNAI), vol. 3392, pp. 16–31. Springer, Heidelberg (2005).  https://doi.org/10.1007/11415763_2CrossRefGoogle Scholar
  16. 16.
    Nogatz, F., Frühwirth, T.: From XML schema to JSON schema: translation with CHR. In: Proceedings of the 11th International Workshop on Constraint Handling Rules (2014)Google Scholar
  17. 17.
    Frühwirth, T.: Theory and practice of constraint handling rules. J. Log. Program. 37(1), 95–138 (1998)MathSciNetCrossRefGoogle Scholar
  18. 18.
    Swift, T., Warren, D.S.: XSB: extending prolog with tabled logic programming. Theor. Pract. Log. Program. 12(1–2), 157–187 (2012)MathSciNetCrossRefGoogle Scholar
  19. 19.
    Desouter, B., Van Dooren, M., Schrijvers, T.: Tabling as a library with delimited control. Theor. Pract. Log. Program. 15(4–5), 419–433 (2015)MathSciNetCrossRefGoogle Scholar
  20. 20.
    Nogatz, F., Seipel, D.: Implementing GraphQL as a query language for deductive databases in SWI-Prolog using DCGs, quasi quotations, and dicts. In: Proceedings 30th Workshop on Logic Programming (WLP) (2016)Google Scholar
  21. 21.
    Seipel, D., Nogatz, F., Abreu, S.: Domain-specific languages in prolog for declarative expert knowledge in rules and ontologies. Comput. Lang. Syst. Struct. 51, 102–117 (2018).  https://doi.org/10.1016/j.cl.2017.06.006CrossRefGoogle Scholar

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversity of WürzburgWürzburgGermany

Personalised recommendations