Parsers

From BaseX Documentation
Revision as of 16:55, 23 March 2011 by Michael (talk | contribs) (→‎Command Line: 6.6 CSV added parser options)
Jump to navigation Jump to search

XML Parsers

By default, the standard Java SAXParser is used to parse the input XML documents. Some documents may not be fully processed by the default parser. This may e.g. be the case if they are too large or contain too many or incorrect entities.

The internal, built-in XML parser of BaseX is more fault-tolerant than the default parser. Additionally, it allows you to switch off DTD and/or entity parsing. There are two ways to switch to the internal XML parser:

GUI

Go to Menu DatabaseNew, then choose the Parsing tab and activate Use internal XML parser.

The parsing of entities and DTDs can be turned on/off by clicking on the two check boxes below.

Command Line

Turn on the database option INTPARSE before parsing documents: SET INTPARSE ON.

Entity and DTD parsing can be changed by modifying the ENTITY and DTD options.

CSV Parser

BaseX can be used to import CSV document into the database.

GUI

Go to Menu DatabaseNew, choose the Parsing tab and activate "csv" in the input format combobox. You can set the following options for parsing CSV documents:

Header
Activate this option if the incoming CSV files have a header line.
Column Separator
Choose the column separator of the CSV file (possible: comma, semicolon, tab).
XML format
Choose the XML format (possible: verbose, simple).

Command Line

Turn on the CSV Parser before parsing documents: SET PARSER csv. Next, use PARSEROPT to set parser-specific options.

The default values are: SET PARSEROPT encoding=utf-8, lines=true, format=verbose, header=false, separator=comma

Text Parser

Plain text can be imported as well:

GUI

Go to Menu DatabaseNew, choose the Parsing tab and activate "text" in the input format combobox. You can set the following option for parsing text documents:

Lines
Activate this option to create a <line> element for each line of the input text file.

Command Line

Turn on the text parser before parsing documents: SET PARSER TEXT. Next, use PARSEROPT to set parser-specific options.

Example: SET PARSEROPT lines=yes