Home
Extended ECM
API, SDK, REST and Web Services
Working Code Example of XML Import
Rick_Strickland
Does anyone out there have a working example of OScript code that successfully imports an XML file and makes the contents of that XML file available in some understandable/usable format (maybe an assoc of assoces)?I have tried every example I can find (which have been very few) and cannot make anything work.No matter what I try, I seem to always get the same error:'An exception occured! Type:RuntimeException, Message:The primary document entity could not be opened. Id=C:\OPENTEXT\ <\IDMSObjectImport><\IDMSConfig>'HELP! Please. If I can get a functional example as a starting place, I may be able to continue from there. But I can't even get it to work from the start.Thanks,Robert,
Find more posts tagged with
Comments
Donna Nalls
Hi Robert,I have done several xmlimport customizations for clients where we are creating items in livelink based on the data within the xml documents.Because of the proprietary info contained in each, i probably can not release the complete modules to you.If you can tell me the purpose/approach of the customization, I would be more than happy to send anything that might be helpful - once removing proprietary info.Are you invoking a request handler to perform the xmlimport? Are you using a custom change agent?What type of data is it you are importing?Are you not creating Livelink items from the xml data??What type of information is it that you want to store it in assoces?? Will there be no permanent storage??What are you going to do with the data once it is parsed?Would it be feasible to use livelink out-of-box functionality for adding the xml document and creating search slices on the xml tags????Regards,Donnaps--don't be too frustrated - it is quite confusing to tackle the xmlimport objects - and nearly impossible to debug! i struggled greatly on my first customization. the good news is that it does work, quite well, once you get the hang of it all! ;o)
Rick_Strickland
Oops. Forgot to mention...If you are able to assist me on this and wish to do so directly, you can email be at: robert_j_roberts@rl.govThanks,
Rick_Strickland
Donna,Thank you so much for you rapid reply. I will try to addressyour questions in 10,000 words or less.Ultimately I am going to be reading XML feed files that willcontain several data elements that will be stored asattributes within categories for Livelink objects. Some ofthe data elements will even be attributes within sets so theXML file will have subsubelements within subelements withelements (or are they subnodes within nodes, etc.?).The XML feed files will also contain one tag/element foreach livelink object that will contain the actual contentsfor the object that I will have to create within Livelink.Each XML feed file can (and usually will) contain the tagsfor multiple Livelink objects.So, basically, I need to: - Read the file. - Find out where the objects are going. - Find out what data elements I should look for in the file. - Find out what attr_id's they are associated with. - Find out what type of object I should create. - Get the contents for that object. - I then need to create the object of the correct type containing the correct contents. - I then need to populate all of the category attributes with the data from the feed. - I need to repeat the above for all of the objects in the feed file.However, I haven't even gotten close to that yet!When I started the module, I first had some properties toset. They were the sort of properties that one stores in an.ini file. However, I did not like the fact that you haveto restart the services everytime you make a change to the.ini file, so... I had the brilliant idea that I would justput the values into a simple .xml file and read them ineverytime my import utility got called. It only runs once aday at the most so the overhead on the read is immaterial.That is as far as I got. I have NOT even been able to readthe first, simple, little Config.xml file!Armed with what I have said so far, I'll try to answer yourquestions directly. > Are you invoking a request handler to perform the xmlimport? Yes. I will be invoking a request handler to perform theactual xmlimport. I can even use the request handler forreading the config.xml file, I guess, because I'm not goingto be using the values from the config.xml file until therequest handler is called, anyway. I would like to be ableto read the config.xml file from places other than merelyRH's though just so I could read from the config.xml filewhenever.>Are you using a custom change agent?I have no idea. I have no idea what a "custom change agent"is. I'm sure my "Builder Fundamentals" instructor wouldchew me out because he probably explained it in the class,but I don't know what one is now.>What type of data is it you are importing?I explained some of this above. The XML Feed File format isfairly convoluted and too large to insert here. However,I can easily create a sample config.xml file that shouldrepresent (more or less) what I would like to be able to do.It should contain something like: My idea was to be able to put sections in the Config.xmlfile for each module and control them all from one spot.>Are you not creating Livelink items from the xml data??That's the plan.>What type of information is it that you want to store it in>assoces?? In the case of the pseudo config.xml file above, I wasthinking something like:A<1,?,"PROJConfig"=A<1,?, "name"="Config XML File", "id"="PROJConfig", "subelements"=A<1,?, "PROJObjectImport"=A<1,?, "name"="Import Module", "PROJObjectImportVersion"= A<1,?,"name"="Object Import Version", "val"="1.0.0">, "PROJHtmlTitle"= A<1,?,"name"="HTML Title", "val"="PROJ - Object Import">, "PROJObjectImportBucketIn" A<1,?,"name"="Import Bucket In", "val"="//px17811/idmsbucketin/">, "PROJObjectImportBucketOut"= A<1,?,"name"="Import Bucket Out" "val"="//px17811/idmsbucketout/">>, "PROJAnotherMod"= ... etc ... ... etc ...>> Something like that. I just made that up right now, on thefly, but basically I am looking for something that makes thecontents of the XML feed file available to me in a way thatI can use it to set my .ini type values and so I can createthe objects I need to creat with the correct data andcontents. >Will there be no permanent storage??Yes. There will be permanent storage. Not only are theobjects intended to be permanent, we also want to archivethe XML feed file and keep that copy for eternity.>What are you going to do with the data once it is parsed?Hopefully this is somewhat explained above.>Would it be feasible to use livelink out-of-box>functionality for adding the xml document and creating>search slices on the xml tags????I have no idea. If it is, let me know. I'll do it anywaythat works about now!Hopefully this makes some sense.I will be more than happy to send you a copy of the firstcut at a sample XML feed file I created and I could send acopy of the actual XML Config as it is today if that wouldhelp also.In an attempt to get the code to work I did an XML Exportfrom Livelink and also tried reading that file just to makesure that the syntax of the .xml file was valid. I receivedthe same error on the exported file.Let me know if you need me to be clearer on something.And, again, THANKS for your help with this!Robert,
Donna Nalls
Okay, now i understand what you want to do and i think i might have some stuff that would help --- i am going to pull some sample stuff for you this evening and send to the email you posted in your earlier thread......best,donna