Difference between revisions of "Parsers"

From BaseX Documentation
Jump to navigation Jump to search
Line 9: Line 9:
 
Go to Menu ''Database'' → ''New'', then choose the ''Parsing tab'' and activate ''Use internal XML parser''.
 
Go to Menu ''Database'' → ''New'', 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.
+
The parsing of entities and DTDs can be turned on/off by clicking on the two check boxes below.
  
 
==Command Line==
 
==Command Line==
Line 20: Line 20:
 
=CSV Parser=
 
=CSV Parser=
  
Parse input CSV documents for storing in the database.  
+
BaseX can be used to import CSV document into the database.  
  
 
==GUI==
 
==GUI==
  
Go to Menu ''Database'' → ''New'', then choose the ''Parsing tab'' and activate "csv" in the input format combobox.
+
Go to Menu ''Database'' → ''New'', 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. <font color="orange">Version 6.5.1</font>
+
You can set the following options for parsing CSV documents: <font color="orange">Version 6.5.1</font>
  
 
;Header
 
;Header
Line 38: Line 38:
 
==Command Line==
 
==Command Line==
  
Turn on the CSV Parser before parsing documents: SET PARSER CSV<br />
+
Turn on the CSV Parser before parsing documents: <code>SET PARSER csv</code>.<br />
Additionally the above options can be set e.g.: SET PARSEROPT header=true, format=simple, separator=tab <font color="orange">Version 6.5.1</font>
+
Additionally, the above options can be set e.g.: SET PARSEROPT header=true, format=simple, separator=tab <font color="orange">Version 6.5.1</font>
  
 
=Text Parser=
 
=Text Parser=
  
Parse input Text documents for storing in the database.
+
Plain text can be imported as well:
  
 
==GUI==
 
==GUI==
  
Go to Menu ''Database'' → ''New'', then choose the ''Parsing tab'' and activate "text" in the input format combobox.
+
Go to Menu ''Database'' → ''New'', choose the ''Parsing'' tab and activate "text" in the input format combobox.
The below panel will change and you can set the lines option for the text parsing. <font color="orange">Version 6.5.1</font>
+
You can set the following option for parsing text documents: <font color="orange">Version 6.5.1</font>
  
 
;Lines
 
;Lines
: activate if the input has to be split into lines
+
: activate this option to create a &lt;line&gt; element for each line of the input text file.
  
 
==Command Line==
 
==Command Line==
  
Turn on the Text Parser before parsing documents: SET PARSER TEXT<br />
+
Turn on the Text Parser before parsing documents: <code>SET PARSER TEXT</code>.
Additionally the above options can be set e.g.: SET PARSEROPT lines=true <font color="orange">Version 6.5.1</font>
+
The above option is specified via the <code>[[Options#Database_options|PARSEROPT]] option.
 +
 
 +
Example: <code>SET PARSEROPT lines=true<code>
  
 
[[Category: Internal]]
 
[[Category: Internal]]

Revision as of 03:05, 6 February 2011

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: Version 6.5.1

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 Version 6.5.1

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: Version 6.5.1

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. The above option is specified via the PARSEROPT option.

Example: SET PARSEROPT lines=true