Hi Noam,
> My followup question is therefore - Is there a way I can run a batch command
> (e.g: Make_CSV.exe input.xml output.csv) where the XQuery would run taking
> as commands the input file name, output file name, and run?
That's indeed possible. You can e.g. bind XQuery variables when
running BaseX on command-line:
Query (query.xq):
declare variable $in external;
declare variable $out external;
let $result := doc($in)/any/path
let $csv := csv:serialize($result)
return file:write-text($out, $csv)
Command line:
basex -b in=input.xml -b out=output.csv query.xq
You can check out our Wiki for more details [1].
Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Command-Line_Options#Standalone
>
> Thanks,
> Noam
>
> On Tue, May 26, 2015 at 10:17 PM, Christian Grün <christian.gruen@gmail.com>
> wrote:
>>
>> Dear Noam,
>>
>> Welcome to the list. I guess the answer on your question mainly
>> depends on what you have done so far, so feel free to give us some
>> more information (e.g. the XQuery expression you wrote).
>>
>> The following XQuery expression reads two XML documents, navigates to
>> a certain path, serializes the resulting nodes as CSV and writes the
>> result to a file:
>>
>> for $doc in ('one.xml', 'two.xml')
>> let $result := doc($doc)/any/path
>> let $csv := csv:serialize($result)
>> return file:write-text($doc || '.csv', $csv)
>>
>> All the best,
>> Christian (Grün)
>>
>>
>>
>> On Tue, May 26, 2015 at 8:59 PM, Noam Green <green.noam@gmail.com> wrote:
>> > Hi,
>> >
>> > I'm new to BaseX, so apologize if this is a repetitive question.
>> > I have created an XQuery which currently runs on a specific XML file.
>> > What I'd like to do is to be able to create a batch command, which would
>> > receive as input a different XML source file, run the XQuery command,
>> > and
>> > save the results in a CSV file.
>> >
>> > Is there a way to do such a process?
>> >
>> > Thanks,
>> > Noam
>
>