BaseX

validating conversion of JSON to XML

扶醉桌前 提交于 2020-03-05 06:06:42
问题 While the JSON is correctly formatted (the jsonTweet variable): The JSON input is valid according to RFC 4627 (JSON specfication). Close The JSON input is valid in JavaScript. However, the xml output is obviously invalid (as xmlStringTweet isn't xml at all). The key lines, as it were: JSONObject jsonTweet = tweets.getJSONObject(Long.toString(id)); xmlStringTweet = XML.toString(jsonTweet); where the jsonTweet is found by the "snowflake" id, and, then, ostensibly, converted to an xml string.

How to parse or read JSON into an XML document for BaseX?

只谈情不闲聊 提交于 2020-03-05 00:34:47
问题 This one-liner in powershell achieves the purpose of converting JSON from Twitter to XML , albeit probably formatted differently: $tweets = Get-Content 'tweets.json' | Out-String | ConvertFrom-Json | Export-Clixml "./tweets.xml" Also, certainly it's easy enough to create an XML document from a JSON file using org.json below: package basex; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.logging

How to parse or read JSON into an XML document for BaseX?

倾然丶 夕夏残阳落幕 提交于 2020-03-05 00:34:26
问题 This one-liner in powershell achieves the purpose of converting JSON from Twitter to XML , albeit probably formatted differently: $tweets = Get-Content 'tweets.json' | Out-String | ConvertFrom-Json | Export-Clixml "./tweets.xml" Also, certainly it's easy enough to create an XML document from a JSON file using org.json below: package basex; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.logging

how to export JSON from Basex with Java?

送分小仙女□ 提交于 2020-03-04 19:39:30
问题 In order to build a JSONArray , how is data from BaseX exported as JSON ? Or queried with XQuery so that the String can be read with Java. Output as: [ { "0":"z10", "1":"y9", "2":"x7", "3":"atrib6", "name":"alice" }, { "0":"home5", "1":"cell4", "name":"sue" }, { "0":"phone3", "1":"phone2", "2":"phone1", "name":"joe" }, { "name":"people" } ] How would loadPeople perform the inverse operation of addPeople ? There must be an input of String to addPeople . Where addPeople takes a JSONArray and

cannot add string to database: BaseXException: Name '' is invalid

丶灬走出姿态 提交于 2020-03-04 19:36:07
问题 After adding valid XML from a file to BaseX , how do I now add valid XML from a String ? thufir@dur:~/NetBeansProjects/twitterBaseX$ thufir@dur:~/NetBeansProjects/twitterBaseX$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information. > > list Name Resources Size Input Path ------------------------------------------------------------------------------- com.w3schools.books 1 6290 https://www.w3schools.com/xml/books.xml db 1 101838 twitter 0 4570 w3school_data 1 5209 https://www

How to get a File or Stream from a JSONObject?

六月ゝ 毕业季﹏ 提交于 2020-02-25 05:36:04
问题 How is a JSONObject from Twitter4J converted to an IOFile for use with the JsonParser from BaseX ? So, looking to use Twitter4J to get either a file or stream. The JsonParser looks to work with a File fine: JsonParser public JsonParser(IO source, MainOptions opts, JsonParserOptions jopts) throws java.io.IOException Constructor. Parameters: source - document source opts - database options jopts - parser options Throws: java.io.IOException - I/O exception although other IO works: org.basex.io

add an XPath statement to a FLOWR to select “id” nodes from Twitter database

孤人 提交于 2020-02-08 10:17:10
问题 Looking at the "id" field for a twitter database: thufir@dur:~/flwor$ thufir@dur:~/flwor$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information. > > open twitter Database 'twitter' was opened in 218.67 ms. > > xquery //id <id type="number">1224165280068382720</id> <id type="number">60919433</id> <id type="number">1224160851797643264</id> <id type="number">60919433</id> .. <id type="number">14248074</id> Query executed in 268.13 ms. > how would I get the same result from a FLWOR

how to extract an XPATH from an html page with Saxon-PE commandline

随声附和 提交于 2020-01-06 08:14:33
问题 I would like to extract the XPATH //DIV[@id="ps-content"] out from this web page: http://www.amazon.com/dp/1449319432 (saved as a local file) I would like to do it with a single line of command-line with one of the best parsers, like Saxon-PE or BaseX. So far the shortest solution that I (seemed to have) found is with these two lines: java -jar tagsoup-1.2.1.jar <page.html >page.xhtml" java -cp saxon9pe.jar net.sf.saxon.Query -s:"page.xhtml" -qs:"//DIV[@id='ps-content']" but all what it

how to extract an XPATH from an html page with Saxon-PE commandline

依然范特西╮ 提交于 2020-01-06 08:14:12
问题 I would like to extract the XPATH //DIV[@id="ps-content"] out from this web page: http://www.amazon.com/dp/1449319432 (saved as a local file) I would like to do it with a single line of command-line with one of the best parsers, like Saxon-PE or BaseX. So far the shortest solution that I (seemed to have) found is with these two lines: java -jar tagsoup-1.2.1.jar <page.html >page.xhtml" java -cp saxon9pe.jar net.sf.saxon.Query -s:"page.xhtml" -qs:"//DIV[@id='ps-content']" but all what it

BaseX get line-breaks return between node-data

ぃ、小莉子 提交于 2020-01-06 03:23:50
问题 I'm using BaseX as my XML based DB. I make a simple query like xquery for $Book in /Libraray/Literaturelist/Literature/Title return fn:data($Book) I get all titles, just as a String that has got no line breaks. Is there a way to add line-breaks with XQuery after each node found by the query to separate the data? This is not really dependant on my XML file because I do not add line-breaks hardcoded within the tags. ;) 回答1: it depends on how you retrieve the query results. The most elegant way