Hi Folks,
[Definition] Declarative: describe what you want, not how to do it. Hand your description off to a tool; the tool figures out how to do what you want, based on your description.
Below I show four XML technologies that epitomize the declarative way.
Scenario #1: You want to ensure that the input data is correct – it contains the requisite data, the number of occurrences (cardinality) is correct, the type of the data (datatype) is correct, and its structure is correct. You could implement your own custom validator to check the input data. But that’s not the declarative way. You want to simply describe the cardinality/datatype/structure rules that the input must conform to and then feed that description into a tool that will check the data based on your description – Hey tool, here’s my description of the rules that the input must conform to, now you figure out how to check that the data adheres to those rules. So, you need a language for declaratively describing the rules on the input data. In other words, you need a validation language. Such a language exists! It’s called XML Schema. XML Schema is a language for describing the rules on the input data. Interestingly, XML Schema is an XML language! An XML Schema processor takes two inputs: input data and a document describing the rules on the input data. That document is called an XML Schema document.
Scenario #2: You want to ensure that the co-dependencies in the input data are satisfied. You could implement your own custom co-dependency checker. But that’s not the declarative way. You want to simply describe the co-dependencies and then feed that description into a tool that will check the data based on your description – Hey tool, here’s my description of the co-dependencies, now you figure out how to determine that the data satisfies the co-dependencies. So, you need a language for declaratively describing the co-dependencies. In other words, you need a co-dependency language. Such a language exists! It’s called Schematron. Schematron is a language for describing the co-dependencies that must be satisfied by input data. Interestingly, Schematron is an XML language! A Schematron processor takes two inputs: input data and a document describing the co-dependencies. That document is called a Schematron document.
Scenario #3: You want to query the input data. You could implement your own custom query code to navigate the input data and fetch the desired results. But that’s not the declarative way. You want to simply describe the query and then feed that description into a tool that will perform the navigation and fetching of the results – Hey tool, here’s my description of the query, now you figure out how to navigate the input and fetch the results. So, you need a language for declaratively describing queries on the input data. In other words, you need a query language. Such a language exists! It is called XQuery. XQuery is a query language. An XQuery processor takes two inputs: input data and a document describing the query. That document is called an XQuery document.
Scenario #4: You want to convert non-XML data to XML. You could implement your own custom parser to process the input data. But that’s not the declarative way. You want to simply describe the input and then feed that description into a tool that will parse the data based on your description – Hey tool, here’s my description of the input’s format, now you figure out how to parse it. So, you need a language for declaratively describing the format of the input data. In other words, you need a data format description language. Such a language exists! It’s called DFDL (Data Format Description Language). DFDL is a language for describing data formats, both text and binary. Interestingly, DFDL is an XML language! A DFDL processor takes two inputs: input data and a document describing the logical and physical format of the input data. That document is called a DFDL schema document.
The declarative way is awesome.
/Roger