Read an XQuery file, substitute a filename for a symbol and save in a string

I'd like to be able to take a filename that represents a text file containing a query for the XQuery
language (that means it can have spaces, lt, gt signs, etc. but no binary data).

What I expect the file to contain is an XQUERY, and possibly (no guarantee), a place holder that I'd
like to replace with a set of fully qualified filenames in a loop, processing the XQuery with each
file I have in a String.

So for example, my program will have a parameter that specifies a fully qualified file xquery file
that looks like this:
{--
returns this data:
<theElement>include<theAttribute id="pageHeader">include</theAttribute></theElement>
--}
for $b in document("%1l")//presentation
for $a in $b//*
where $a[fn:lower-case(@* as xs:string)="pageHeader"]
return
<theElement> {name($a)}
<theAttributes>
{ $a/@*, name($a)}
</theAttributes> </theElement>

Another parameter for the program contains a wildcard that will result in a list of fully qualified
filenames.

And I have a nice little qexo app that will loop through the list of fully qualified filenames, and
for each file will:

put the data from the xquery into a string
substituting the first occurence (if any) of %1 with the current fully qualified filename
pass the resulting transformed string to the qexo object that will process the XQuery.

Can someone help me out with the best way to read in the file, and do the substitution?

I was thinking of FileReader object, and read line by line, but I'm not sure about the string
substitution.

Advertisements

"Jeff Kish" <> wrote in message
news:...
> Greetings
>
> I'd like to be able to take a filename that represents a text file
containing a query for the XQuery
> language (that means it can have spaces, lt, gt signs, etc. but no binary
data).
>
> What I expect the file to contain is an XQUERY, and possibly (no
guarantee), a place holder that I'd
> like to replace with a set of fully qualified filenames in a loop,
processing the XQuery with each
> file I have in a String.

<snip>

If all you're looking for is search and replace functionality, the
String.replaceAll() method will do the trick.

Advertisements

On Sun, 14 Nov 2004 23:38:07 -0600, "Chris" <> wrote:
>"Jeff Kish" <> wrote in message
>news:...
>> Greetings
>>
>> I'd like to be able to take a filename that represents a text file
>containing a query for the XQuery
>> language (that means it can have spaces, lt, gt signs, etc. but no binary
>data).
>>
>> What I expect the file to contain is an XQUERY, and possibly (no
>guarantee), a place holder that I'd
>> like to replace with a set of fully qualified filenames in a loop,
>processing the XQuery with each
>> file I have in a String.
>
><snip>
>
>If all you're looking for is search and replace functionality, the
>String.replaceAll() method will do the trick.
>
Thanks. This will give the app the ability to just replace the first occurrence? Perfect.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!