MarkLogic Server requires that XML be encoded in UTF8. I believe JAVA has some handy libraries to help with this, provided you know the source character set.
Kelly -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, January 05, 2007 3:00 PM To: [email protected] Subject: General Digest, Vol 31, Issue 4 Send General mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit http://xqzone.com/mailman/listinfo/general or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of General digest..." Today's Topics: 1. RE: External file uploadinto marklogicdatabase ([EMAIL PROTECTED]) 2. Re: External file uploadinto marklogicdatabase (Jason Hunter) ---------------------------------------------------------------------- Message: 1 Date: Fri, 5 Jan 2007 12:04:48 +0530 From: <[EMAIL PROTECTED]> Subject: RE: [MarkLogic Dev General] External file uploadinto marklogicdatabase To: <[email protected]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" Hi all, As per the below discussion I made the following change in my code { System.out.println("before new session content insertion"); File file = new File(strSourceLocation);// strSourceLocation==c:/temp/strutsvalidatorframework.pdf strTargetLocation += file.getName();// strTargetLocation== /root/strutsvalidatorframework.pdf === marklogic uri Content content = ntentFactory.newContent(strTargetLocation,file,ContentCreateOptions.newT extInstance()); //tried ContentCreateOptions.newBinaryInstance() instance also............. session.insertContent(content); System.out.println("after new session content insertion"); } Im getting the below exception....... com.marklogic.xcc.exceptions.XQueryException: XDMP-DOCUTF8SEQ: Invalid UTF-8 esc ape sequence at /root/Integ-Struts-JSF.doc line 1 -- document is not UTF-8 encod ed in /insert JH can u throw some input regarding this............. Regards Venkatesh M S mob-+91 9980096470 When you decide to stand still in life. You mark the beginning of your end. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Hunter Sent: Thursday, January 04, 2007 12:20 PM To: General Mark Logic Developer Discussion Subject: Re: [MarkLogic Dev General] External file uploadinto marklogicdatabase Happy to help. To insert a document to MarkLogic using XCC does not involve any XQuery, only Java. You'll need to call Session.insertContent() as documented at http://developer.marklogic.com/pubs/3.1/javadoc/com/marklogic/xcc/Sessio n.html#insertContent(com.marklogic.xcc.Content) The XCC Developer's Guide (http://developer.marklogic.com/pubs/3.1/default.xqy) will give you an overview of XCC, how to make sessions, pointers to some examples, and all that. -jh- [EMAIL PROTECTED] wrote: > > Hi JH, > > Very Thrilled by your reply. > > Infact we are using XCC APIs!!!!!!!!!!!!!!!!!!!!! > > Below is the detailed explanation. > > Im using struts DynaActionForm to upload File below is my form and > form bean. > > <form id="form1" name="form1" method="post" action="" > enctype="multipart/form-data"> > <tr> > <td valign="top" class="bodytxt_bld">Attachment:</td> > > > <td valign="top" class="bodytxt_bld"> > > > <input type="file" name="uploadFile" /></td> > <td width="24%" align="left" > class="bodytxt"></td> > > > </tr> > </form> > > > > > <form-bean > name="fileUploadForm" > type="org.apache.struts.action.DynaActionForm"> > <form-property > name="uploadFile" > type="org.apache.struts.upload.FormFile"/> > </form-bean> > > Below is my action method code. > > > public ActionForward uploadFile(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) throws > Exception { > > HttpSession session=request.getSession(false); > DynaActionForm fileUploadForm=(DynaActionForm)form; > FileUtil fileUtil=null; > String uri=null; > //String strFileName=null; > String strFileType=null; > String strFileCategory=null; > ArrayList fileArray=null; > int publicationElementInstanceId = 0; > > try{ > System.out.println("Inside Publication Upload > Action"); > FormFile myFile = > (FormFile)fileUploadForm.get("uploadFile"); > String contentType = myFile.getContentType(); > String fileName = myFile.getFileName(); > //int fileSize = myFile.getFileSize(); > byte[] fileData = myFile.getFileData(); > > System.out.println("contentType: " + contentType); > System.out.println("File Name: " + fileName); > HierarchyService service = getHierarchyService(); > uri=service.addDocument(fileName,fileData); > fileUtil=new FileUtil(); > strFileType=fileUtil.getFileType(fileName); > strFileCategory=fileUtil.getFileCategory(strFileType); > > > publicationElementInstanceId=Integer.parseInt(request.getParameter("publ > icationElementInstanceId")); > > service.createFile(uri,strFileType,strFileCategory,publicationElementIns > tanceId); > > > fileArray=listFileDetails(publicationElementInstanceId,service); > > //req.setAttribute(IPPConstants.FILE_ARRAY,fileArray); > > } > catch(Exception e) > { > e.printStackTrace(); > log.error(e.getMessage()); > } > System.out.println("fileArray"+fileArray); > return new > ActionForward("/PublicationElementInstanceAction.do?action=editPublicati > onElementInstance&nodeID="+publicationElementInstanceId); > } > > > > > > > > > Below is my service method. > > public String addDocument(String fileName,byte[] fileData) throws > Exception { > String uri = null; > try{ > > String > destPath=versionControl.getTempFolder()+"\\"+fileName; > System.out.println("destPath"+destPath); > FileOutputStream destStr = new FileOutputStream(new > File(destPath)); > InputStream in = new ByteArrayInputStream(fileData); > int i; > while((i=in.read()) != -1) > { > destStr.write(i); > } > destStr.close(); > System.out.println(" here"); > versionControl.setSession(); > > uri=versionControl.addDocument(fileName, > destPath, null); > > > }catch(Exception e) > { > log.error(e.getMessage()); > } > return uri; > > } > > versionControl is a DAO for marklogic database > > Below is the xcc code written to insert File > > public String addDocument(String strSourceName, String > strSourceLocation, String strTargetLocation) > throws FileAlreadyExistException, > FolderNotFoundException, > FileNotFoundException { > try > { > String modPath = tempFolder + "/" + > strSourceName; > String > query="xdmp:document-load('"+modPath+"',\n <options > xmlns='xdmp:document-load'>\n <uri>" + rootFolder + > "/"+strSourceName+"</uri>\n <repair>full</repair>\n > <permissions>{xdmp:default-permissions()}</permissions>\n </options>)"; > > AdhocQuery req = session.newAdhocQuery(query);// > Provide the cq-query as a parameter > ResultSequence rs = session.submitRequest(req); > rs.close(); > session.close(); > > session = contentSource.newSession(); > > query= cmsModule + "\n" + > > "cms:create('"+strSourceName+"', doc('" + rootFolder + > "/"+strSourceName+"'))";//removed "/*" from > "cms:create('"+strSourceName+"', doc('/root/"+strSourceName+"')/*)" for > versioning documents other than xml > > req = session.newAdhocQuery(query); > rs = session.submitRequest(req); > rs.close(); > session.close(); > > > } > catch(Exception e) > { > e.printStackTrace(); > } > > return rootFolder+"/"+strSourceName; > } > > > Im getting the below XCCException > > com.marklogic.xcc.exceptions.XQueryException: SVC-FILOPN: > xdmp:document-load("c: > /temp/WhitePaper.zip", /options) -- File open error: open > 'c:/temp/WhitePaper.zi > p': No such file or directory > > The file is getting uploaded into the Jboss server till that point I > don't face any problem, but when I try to insert the uploaded file into > marklogic database > > Regards > Venkatesh M S > mob-+91 9980096470 > > When you decide to stand still in life. > You mark the beginning of your end. > > > > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jason > Hunter > Sent: Thursday, January 04, 2007 11:18 AM > To: General Mark Logic Developer Discussion > Subject: Re: [MarkLogic Dev General] External file upload into > marklogicdatabase > > Hi Venkatesh, > > If you simply need to load a file from a client machine and can put > software on the client machine, then the XCC library is your best bet. > It lets you stream a file across the net into MarkLogic. It is to > MarkLogic what JDBC is for a relational database. There are Java and > .NET versions available at developer.marklogic.com. > > If you're wanting to handle a web browser file upload (RFC 1867) then > you'll need something on the server that understands the special file > format with which a browser uploads the file. If you have a Java front > end (aka JBoss), there are lots of Java libraries that can do this > (Apache has one, and I wrote one myself at http://servlets.com/cos). > Tthe Java layer can catch the file(s) and use XCC to insert them into > MarkLogic (or you could just save them on the filesystem and do an > xdmp:load() for a dirt simple approach). > > Or if your server is pure XQuery you could write an RFC 1867 parser in > XQuery or maybe someone on the list has already written one in XQuery > and would be willing to share. > > If you have another kind of situation, let us know more. > > -jh- > > [EMAIL PROTECTED] wrote: >> hi all, >> >> we run our web server(JBOSS) and Marklogic server in two different > machines. >> >> i have a requirement where im supposed to upload a file (non-xml) into > >> marklogic from client machine(user). >> >> xdmp:load("sourcepath","targetpath"); >> >> i cant use the above function since the sourcepath doesnt > exist........ >> >> plz give some inputs regarding this. >> >> thanks in advance. >> >> Regards >> Venkatesh M S >> mob-+91 9980096470 >> >> When you decide to stand still in life. >> You mark the beginning of your end. >> >> >> >> >> >> The information contained in this electronic message and any > attachments >> to this message are intended for the exclusive use of the addressee(s) > >> and may contain proprietary, confidential or privileged information. > If >> you are not the intended recipient, you should not disseminate, >> distribute or copy this e-mail. Please notify the sender immediately > and >> destroy all copies of this message and any attachments. >> >> WARNING: Computer viruses can be transmitted via email. The recipient >> should check this email and any attachments for the presence of > viruses. >> The company accepts no liability for any damage caused by any virus >> transmitted by this email. >> >> www.wipro.com >> >> >> > ------------------------------------------------------------------------ >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > > > The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. > > www.wipro.com > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com ------------------------------ Message: 2 Date: Fri, 05 Jan 2007 01:23:20 -0800 From: Jason Hunter <[EMAIL PROTECTED]> Subject: Re: [MarkLogic Dev General] External file uploadinto marklogicdatabase To: General Mark Logic Developer Discussion <[email protected]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed You're telling the server the file is a "TextInstance" but it's a PDF or Word document so it should be expecting binary. Your comments say you tried binary, but when you did what happened? I can't imagine it was the same UTF8 error. -jh- [EMAIL PROTECTED] wrote: > Hi all, > > As per the below discussion I made the following change in my code > > { > System.out.println("before new session content insertion"); > > File file = new File(strSourceLocation);// > strSourceLocation==c:/temp/strutsvalidatorframework.pdf > strTargetLocation += file.getName();// > strTargetLocation== /root/strutsvalidatorframework.pdf === marklogic > uri > > Content content = > ntentFactory.newContent(strTargetLocation,file,ContentCreateOptions.newT > extInstance()); //tried ContentCreateOptions.newBinaryInstance() > instance also............. > session.insertContent(content); > > System.out.println("after new session content > insertion"); > } > > Im getting the below exception....... > > com.marklogic.xcc.exceptions.XQueryException: XDMP-DOCUTF8SEQ: Invalid > UTF-8 esc > ape sequence at /root/Integ-Struts-JSF.doc line 1 -- document is not > UTF-8 encod > ed > in /insert > > JH can u throw some input regarding this............. > Regards > Venkatesh M S > mob-+91 9980096470 > > When you decide to stand still in life. > You mark the beginning of your end. > > > > > > > > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jason > Hunter > Sent: Thursday, January 04, 2007 12:20 PM > To: General Mark Logic Developer Discussion > Subject: Re: [MarkLogic Dev General] External file uploadinto > marklogicdatabase > > Happy to help. > > To insert a document to MarkLogic using XCC does not involve any XQuery, > > only Java. You'll need to call Session.insertContent() as documented at > > http://developer.marklogic.com/pubs/3.1/javadoc/com/marklogic/xcc/Sessio > n.html#insertContent(com.marklogic.xcc.Content) > > The XCC Developer's Guide > (http://developer.marklogic.com/pubs/3.1/default.xqy) will give you an > overview of XCC, how to make sessions, pointers to some examples, and > all that. > > -jh- > > > [EMAIL PROTECTED] wrote: >> >> Hi JH, >> >> Very Thrilled by your reply. >> >> Infact we are using XCC APIs!!!!!!!!!!!!!!!!!!!!! >> >> Below is the detailed explanation. >> >> Im using struts DynaActionForm to upload File below is my form and >> form bean. >> >> <form id="form1" name="form1" method="post" action="" >> enctype="multipart/form-data"> >> <tr> >> <td valign="top" class="bodytxt_bld">Attachment:</td> >> >> >> <td valign="top" class="bodytxt_bld"> >> >> >> <input type="file" name="uploadFile" /></td> >> <td width="24%" align="left" >> class="bodytxt"></td> >> >> >> </tr> >> </form> >> >> >> >> >> <form-bean >> name="fileUploadForm" >> type="org.apache.struts.action.DynaActionForm"> >> <form-property >> name="uploadFile" >> type="org.apache.struts.upload.FormFile"/> >> </form-bean> >> >> Below is my action method code. >> >> >> public ActionForward uploadFile(ActionMapping mapping, ActionForm > form, >> HttpServletRequest request, HttpServletResponse response) throws >> Exception { >> >> HttpSession session=request.getSession(false); >> DynaActionForm fileUploadForm=(DynaActionForm)form; >> FileUtil fileUtil=null; >> String uri=null; >> //String strFileName=null; >> String strFileType=null; >> String strFileCategory=null; >> ArrayList fileArray=null; >> int publicationElementInstanceId = 0; >> >> try{ >> System.out.println("Inside Publication Upload >> Action"); >> FormFile myFile = >> (FormFile)fileUploadForm.get("uploadFile"); >> String contentType = myFile.getContentType(); >> String fileName = myFile.getFileName(); >> //int fileSize = myFile.getFileSize(); >> byte[] fileData = myFile.getFileData(); >> >> System.out.println("contentType: " + contentType); >> System.out.println("File Name: " + fileName); >> HierarchyService service = getHierarchyService(); >> uri=service.addDocument(fileName,fileData); >> fileUtil=new FileUtil(); >> strFileType=fileUtil.getFileType(fileName); >> strFileCategory=fileUtil.getFileCategory(strFileType); >> >> >> > publicationElementInstanceId=Integer.parseInt(request.getParameter("publ >> icationElementInstanceId")); >> >> > service.createFile(uri,strFileType,strFileCategory,publicationElementIns >> tanceId); >> >> >> fileArray=listFileDetails(publicationElementInstanceId,service); >> >> //req.setAttribute(IPPConstants.FILE_ARRAY,fileArray); >> >> } >> catch(Exception e) >> { >> e.printStackTrace(); >> log.error(e.getMessage()); >> } >> System.out.println("fileArray"+fileArray); >> return new >> > ActionForward("/PublicationElementInstanceAction.do?action=editPublicati >> onElementInstance&nodeID="+publicationElementInstanceId); >> } >> >> >> >> >> >> >> >> >> Below is my service method. >> >> public String addDocument(String fileName,byte[] fileData) throws >> Exception { >> String uri = null; >> try{ >> >> String >> destPath=versionControl.getTempFolder()+"\\"+fileName; >> System.out.println("destPath"+destPath); >> FileOutputStream destStr = new FileOutputStream(new >> File(destPath)); >> InputStream in = new ByteArrayInputStream(fileData); >> int i; >> while((i=in.read()) != -1) >> { >> destStr.write(i); >> } >> destStr.close(); >> System.out.println(" here"); >> versionControl.setSession(); >> >> uri=versionControl.addDocument(fileName, >> destPath, null); >> >> >> }catch(Exception e) >> { >> log.error(e.getMessage()); >> } >> return uri; >> >> } >> >> versionControl is a DAO for marklogic database >> >> Below is the xcc code written to insert File >> >> public String addDocument(String strSourceName, String >> strSourceLocation, String strTargetLocation) >> throws FileAlreadyExistException, >> FolderNotFoundException, >> FileNotFoundException { >> try >> { >> String modPath = tempFolder + "/" + >> strSourceName; >> String >> query="xdmp:document-load('"+modPath+"',\n <options >> xmlns='xdmp:document-load'>\n <uri>" + rootFolder + >> "/"+strSourceName+"</uri>\n <repair>full</repair>\n >> <permissions>{xdmp:default-permissions()}</permissions>\n > </options>)"; >> >> AdhocQuery req = session.newAdhocQuery(query);// >> Provide the cq-query as a parameter >> ResultSequence rs = session.submitRequest(req); >> rs.close(); >> session.close(); >> >> session = contentSource.newSession(); >> >> query= cmsModule + "\n" + >> >> "cms:create('"+strSourceName+"', doc('" + rootFolder + >> "/"+strSourceName+"'))";//removed "/*" from >> "cms:create('"+strSourceName+"', doc('/root/"+strSourceName+"')/*)" > for >> versioning documents other than xml >> >> req = session.newAdhocQuery(query); >> rs = session.submitRequest(req); >> rs.close(); >> session.close(); >> >> >> } >> catch(Exception e) >> { >> e.printStackTrace(); >> } >> >> return rootFolder+"/"+strSourceName; >> } >> >> >> Im getting the below XCCException >> >> com.marklogic.xcc.exceptions.XQueryException: SVC-FILOPN: >> xdmp:document-load("c: >> /temp/WhitePaper.zip", /options) -- File open error: open >> 'c:/temp/WhitePaper.zi >> p': No such file or directory >> >> The file is getting uploaded into the Jboss server till that point I >> don't face any problem, but when I try to insert the uploaded file > into >> marklogic database >> >> Regards >> Venkatesh M S >> mob-+91 9980096470 >> >> When you decide to stand still in life. >> You mark the beginning of your end. >> >> >> >> >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of Jason >> Hunter >> Sent: Thursday, January 04, 2007 11:18 AM >> To: General Mark Logic Developer Discussion >> Subject: Re: [MarkLogic Dev General] External file upload into >> marklogicdatabase >> >> Hi Venkatesh, >> >> If you simply need to load a file from a client machine and can put >> software on the client machine, then the XCC library is your best bet. > >> It lets you stream a file across the net into MarkLogic. It is to >> MarkLogic what JDBC is for a relational database. There are Java and >> .NET versions available at developer.marklogic.com. >> >> If you're wanting to handle a web browser file upload (RFC 1867) then >> you'll need something on the server that understands the special file >> format with which a browser uploads the file. If you have a Java > front >> end (aka JBoss), there are lots of Java libraries that can do this >> (Apache has one, and I wrote one myself at http://servlets.com/cos). >> Tthe Java layer can catch the file(s) and use XCC to insert them into >> MarkLogic (or you could just save them on the filesystem and do an >> xdmp:load() for a dirt simple approach). >> >> Or if your server is pure XQuery you could write an RFC 1867 parser in > >> XQuery or maybe someone on the list has already written one in XQuery >> and would be willing to share. >> >> If you have another kind of situation, let us know more. >> >> -jh- >> >> [EMAIL PROTECTED] wrote: >>> hi all, >>> >>> we run our web server(JBOSS) and Marklogic server in two different >> machines. >>> >>> i have a requirement where im supposed to upload a file (non-xml) > into >>> marklogic from client machine(user). >>> >>> xdmp:load("sourcepath","targetpath"); >>> >>> i cant use the above function since the sourcepath doesnt >> exist........ >>> >>> plz give some inputs regarding this. >>> >>> thanks in advance. >>> >>> Regards >>> Venkatesh M S >>> mob-+91 9980096470 >>> >>> When you decide to stand still in life. >>> You mark the beginning of your end. >>> >>> >>> >>> >>> >>> The information contained in this electronic message and any >> attachments >>> to this message are intended for the exclusive use of the > addressee(s) >>> and may contain proprietary, confidential or privileged information. >> If >>> you are not the intended recipient, you should not disseminate, >>> distribute or copy this e-mail. Please notify the sender immediately >> and >>> destroy all copies of this message and any attachments. >>> >>> WARNING: Computer viruses can be transmitted via email. The recipient > >>> should check this email and any attachments for the presence of >> viruses. >>> The company accepts no liability for any damage caused by any virus >>> transmitted by this email. >>> >>> www.wipro.com >>> >>> >>> > ------------------------------------------------------------------------ >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://xqzone.com/mailman/listinfo/general >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general >> >> >> The information contained in this electronic message and any > attachments to this message are intended for the exclusive use of the > addressee(s) and may contain proprietary, confidential or privileged > information. If you are not the intended recipient, you should not > disseminate, distribute or copy this e-mail. Please notify the sender > immediately and destroy all copies of this message and any attachments. >> WARNING: Computer viruses can be transmitted via email. The recipient > should check this email and any attachments for the presence of viruses. > The company accepts no liability for any damage caused by any virus > transmitted by this email. >> >> www.wipro.com >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general >> > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > > > The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. > > www.wipro.com > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > ------------------------------ _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general End of General Digest, Vol 31, Issue 4 ************************************** _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
