>zorba -e text-file=my-pipe-delimited-text-file.txt -o My_Output_XML_File.xml -f -q my-Xquery-script-file.xq
When I try to run it I get the following error.
While binding external variable $text-file: <eval@-4-1>:1,2 (in data 1,1): dynamic error [err:FODC0006]: invalid content passed to fn:parse-xml(): "":1,1: loader parsing error: empty XML document ('<' expected)
Like I said earlier, if the input file is XML, I am able to read it in. If it is a text file, it complains that "invalid content passed"
Let's simplify the script even further. What if I just reduce the program (xquery-read-text-file.xq) to this?
declare variable $text-file external;
let $input-text := $text-file
return
$input-text
I make my text file (sample-text-file.txt) this:
This is line 1
This is line 2
This is line 3
I call this program from my command line like this:
zorba -e text-file=sample-text-file.txt -f -q xquery-read-text-file.xq
I receive an error like this:
While binding external variable $text-file: <eval@-4-1>:1,2 (in data 1,1): dynamic error [err:FODC0006]: invalid content passed to fn:parse-xml(): "":1,1: loader parsing error: empty XML document ('<' expected)
If I were to instead, read in a XML file (sample-xml-file.xml), this script would work fine.
Is there a special function I need to use to read text files in? It sounds like, from your response, that there is nothing special I need to do to read text files in. Is that correct? Are you able to run the scenario I have outlined here?
declare variable $text-file external;
let $input-text := file:read-text($text-file)
return
$input-text
If I don't use the file:read-text() function, it just returns the name of the file that I pass in.
I am a little confused because I thought I was experiencing something different the other day. I will need to go back and try to recreate the issue.
Nick