Changes

Jump to navigation Jump to search
85 bytes added ,  16:32, 27 February 2020
no edit summary
The [[Database Module#db:add|db:add]] and [[Database Module#db:replace|db:replace]] functions can also be used to add new XML documents to the database. The following example query uses the internal XML parser and adds all files to the database <code>DB</code> that are found in the directory <code>2Bimported</code>:
<pre classsyntaxhighlight lang="brush:xquery">
for $file in file:list("2Bimported")
return db:add('DB', $file, '', map { 'intparse': true() })
</presyntaxhighlight>
=HTML Parser=
3. on the first tab, you can see an XML snippet like this:
<pre classsyntaxhighlight lang="brush:xml">
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
<version>1.2.1</version>
</dependency>
</presyntaxhighlight>
4. copy that in your own maven project’s <code>pom.xml</code> file into the <code><dependencies></code> element.
as function arguments:
<pre classsyntaxhighlight lang="brush:xquery">
fetch:xml("index.html", map {
'parser': 'html',
'htmlparser': map { 'html': false(), 'nodefaults': true() }
})
</presyntaxhighlight>
=JSON Parser=
the first lines as column headers:
<pre classsyntaxhighlight lang="brush:xquery">
for $file in file:list("2Bimported", false(), "*.csv")
return db:add("DB", $file, "", map {
'csvparser': map { 'header': true() }
})
</presyntaxhighlight>
=Text Parser=
Similar to the other formats, the text parser can also be specified via XQuery:
<pre classsyntaxhighlight lang="brush:xquery">
for $file in file:list("2Bimported", true(), "*.txt")
return db:add("DB", $file, "", map { 'parser': 'text' })
</presyntaxhighlight>
=Changelog=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu