Parsers

From BaseX Documentation
Revision as of 12:01, 2 February 2011 by AW (talk | contribs)
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 checkboxes 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

It is possible to parse CSV documents and create databases with them.

GUI

Go to Menu DatabaseNew, then choose the Parsing tab and activate "csv" in the input format combobox. The below panel will change and you can set several options for the csv parsing.

Header
activate if the CSV file has a header
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
Additionally the above options can be set e.g.: SET PARSEROPT header=true, format=simple, separator=tab

Text Parser

It is possible to parse Text documents and create databases with them.

GUI

Go to Menu DatabaseNew, then choose the Parsing tab and activate "text" in the input format combobox. The below panel will change and you can set the line option for the text parsing.

Line
activate if the input has to be split into lines


Command Line

Turn on the CSV Parser before parsing documents: SET PARSER TEXT
Additionally the above options can be set e.g.: SET PARSEROPT lines=true