Hello All,
Now i have successfully connected my xquery with java using
MLJAM, but i have problem while generating output,
Actually my task is to convert one XML format to another XML format, I read
the XML file in my WEBDAV drive, after
transformation writing it into my local drive.
see the below Code:
xquery version "0.9-ml"
import module namespace cpf = "http://marklogic.com/cpf" at
"/MarkLogic/cpf/cpf.xqy"
import module namespace jam = "http://xqdev.com/jam" at
"/MarkLogic/cpf/jam.xqy"
define function test($x,$y)
{
jam:start("http://localhost:8080/mljam/mljam", "user",
"pass"),
jam:set("X",$x),
jam:set("Y",$y),
jam:eval-get('
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
String inputLine="";
try
{
HttpURLConnection urlConn;
URL url = new
URL("http://localhost:8020" + X);
urlConn =
(HttpURLConnection) url.openConnection();
String encoding = "Basic " +
new sun.misc.BASE64Encoder().encode("username:password".getBytes());
urlConn.setRequestProperty("Authorization", encoding);
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.connect();
BufferedReader in = new
BufferedReader(new InputStreamReader(urlConn.getInputStream()));
input_string=input_string+inputLine ;
}
catch(Exception e)
{
}
// transformation code here
try
{
FileOutputStream FOS = new
FileOutputStream("D:\\ML_Output\\" + Y + ".xml");
FOS.write(input_string.getBytes());
FOS.close();
}
catch(Exception e)
{
}
print(inputLine);
'),
jam:get-stdout(),
jam:end()
}
test("/ch01.xml","ch01")
If i put single file to trigger, it runs correctly, but if i put more than
one file to trigger at a time, i will get random
output, i.e., some files missing, some files coming in other file names, How
to rectify it?
Thanks in advance
Shri
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general