Document Schemas

This article introduces you to the definition and setup of the document schema for processing data source(s) with the JsaPar library. This article assumes that you already have followed the instructions in the setting up article of this website, and that you have familiarized yourself with the API of the JsaPar library explained in the getting started article of this website. If not, please make sure that you have read these articles before continuing reading this article. 

A basic introduction to schemas

What is a schema?
A schema is a definition structure to describe how a data source is built up, so that it can be processed for input and/or output. The Jsapar library needs to know how to interpret the data source(s) it must process in order to be successful. Without such definition structure, the library is clueless in how to deal with these data sources. Therefore, a schema is always needed by the library.

How is a schema built up?
A schema consists of one specific schema class and one or more schemaline classes based on the type of data source that must be processed.



How to specify a schema?
A schema is always used in code, so at least one schema object is necessary to be constructed for using the JsaPar library. The schema class can be constructed by loading a XML document into the schema class or can be constructed programmatically by using Java code only. For simple data source structures the schema is easily constructed using Java code. For complex data source structures it is preferable to specify these schemas using a XML document. A schema is always adjustable, even if the schema structure is loaded before using a XML document.



What type of schemas are there?
For types of schemas are defined for use in conjuction with the JsaPar library. These are:
  • Comma Separated Value
  • Comma Separated Value control value
  • Fixed width
  • Fixed width control value

All schemas classes are derived from the default schema class: org.jsapar.schema.Schema.






TODO: All possible schema options for XML are discussed in this article.
Schema exception handling is discussed in the handling errors article.


Writing an XML specification file




Writing a Fixed Width xml file



Writing a Fixed Width control value xml file



Writing a Comma Separated Value xml file



Writing a Comma Separated Value control value xml file




Using xml as input for a Document

It is possilbe to build a org.jsapar.Document by using a xml document according to the XMLDocumentFormat.xsl (http://jsapar.tigris.org/XMLDocumentFormat/1.0). Use the class org.jsapar.input.XmlDocumentParser in order to convert a xml document into a org.jsapar.Document.