cancel
Showing results for 
Search instead for 
Did you mean: 

Migrating XML content

gidion
Champ in-the-making
Champ in-the-making
Hi,

In the website i am creating (using alfrescos  wcm) i have created a number of xsd web forms that capture various content types:
profile
advice page
etc.

When viewing the content produced from completing one of these forms (which are saved as xml content) I get xml code.

My problem is.
When i convert all of my data from my current legacy system (non alfresco), into this xml format and load it, my content controllers are then unable to edit these content items via the form.
Instead they are asked to download the xml file to edit it.

NOTE: All content items that have been manually created in the system via the form are editable via the form interface.

Is there any way of overcomming this?

I have looked at acpGeneratr but if i need to use this and load my meta data as a csv and my content (body text) as the actual xml file then what format would the xml file take?
Would it still look like those manually created (ie. contatining a full xml description of content and meta-data)?
Or would i use the acpGeneratr method and load the content (body text) as plain text and the meta-data via the csv file.

Still, would this enable the content to be editable via my forms?

Thanks,
Luke
11 REPLIES 11

gidion
Champ in-the-making
Champ in-the-making
To note:

here is the view of the manually created form xml.

<?xml version="1.0" encoding="UTF-8" ?>
<prSmiley Tongueress_release xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr" xmlns:alf="http://www.alfresco.org" xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <pr:title>test for saturday</pr:title>
  <pr:body>test test sat</pr:body>
  <pr:keywords>saturday test</pr:keywords>
  </prSmiley Tongueress_release>


here is what i loaded via the "create" >> "add content" upload link:

<?xml version="1.0" encoding="UTF-8" ?>
<prSmiley Tongueress_release xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr" xmlns:alf="http://www.alfresco.org" xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <pr:title>test for friday</pr:title>
  <pr:body>test test fri</pr:body>
  <pr:keywords>friday test</pr:keywords>
  </prSmiley Tongueress_release>




as you can see. Both are the same, just the content of the xml has changed.

mark_smithson
Champ in-the-making
Champ in-the-making
Hi gidion

Alfresco are working on this… The xml files need to be associated with the web form in the meta data.

In the meantime, I have written a web script which associates all the xml files in a folder with a particular web form.  The code below should get you going, it may need some adjustment for your environment ..

script: {
   var sandbox = args.sb;
   var form = args.form;
   var path = url.extension;
   var storeRoot = avm.lookupStore(sandbox);
   var folder = storeRoot.lookupNode("ROOT/" + path);
   var files = folder.children;
   var updated = new Array();
   
   for (var i=0; i<files.length;i++){
      var file = files;
      if (file.isDocument && file.properties.content.mimetype == "text/xml"){
         // add aspect to associate the xml file with its form
         if (!hasAspect(file.aspects, "{http://www.alfresco.org/model/wcmappmodel/1.0}forminstancedata")){
            var props = new Array(2);
            props["{http://www.alfresco.org/model/wcmappmodel/1.0}parentformname"] = form;
            props["{http://www.alfresco.org/model/wcmappmodel/1.0}originalparentpath"] = file.parentPath;
            file.addAspect("{http://www.alfresco.org/model/wcmappmodel/1.0}forminstancedata", props);
            updated[updated.length] = file;
         }
      }
   }

   model.folder = folder;
   model.updated = updated;
}

function hasAspect(aspects, aspect){
   if (aspects.length == undefined){
      aspects = aspects.toArray();
   }
   for (var i=0; i< aspects.length; i++){
      if (aspects == aspect){
         return true;
      }
   }
   return false;
}

gidion
Champ in-the-making
Champ in-the-making
Hi Mark,

Thanks for that.

Sorry to ask for yet more info but I am unsure of how we get javascript files to run against a space or content item.
I can see how rules are added to spaces outside of the wcm but not within it.

Any help would be great.

Thanks,
Luke

mark_smithson
Champ in-the-making
Champ in-the-making
Hi Gidion,

I created a web script and then just call that using a web browser. I have not found a way to do it automatically.

There is some info on creating web scripts in the wiki and also in the Web Scripts space in the Data Dictionary on your Alfresco install.

gidion
Champ in-the-making
Champ in-the-making
Ok, thanks again mark. That at least saves our content controllers having to play with xml code.

I believe the feature i spoke of above is present in 2.1.0E.

Just a shame I am using the community version.

mark_smithson
Champ in-the-making
Champ in-the-making
me ot at the moment, but that may be changing …

jeyush
Champ in-the-making
Champ in-the-making
Hey mark ,thank you very much to put that script .

but i have some que for you.i hope u reply me.

your code:
script: {var sandbox = args.sb;var form = args.form;var path = url.extension;var storeRoot = avm.lookupStore(sandbox);var folder = storeRoot.lookupNode("ROOT/" + path);var files = folder.children;var updated = new Array();for (var i=0; i<files.length;i++){var file = files[i];if (file.isDocument && file.properties.content.mimetype == "text/xml"){// add aspect to associate the xml file with its formif (!hasAspect(file.aspects, "{http://www.alfresco.org/model/wcmappmodel/1.0}forminstancedata")){var props = new Array(2);props["{http://www.alfresco.org/model/wcmappmodel/1.0}parentformname"] = form;props["{http://www.alfresco.org/model/wcmappmodel/1.0}originalparentpath"] = file.parentPath;file.addAspect("{http://www.alfresco.org/model/wcmappmodel/1.0}forminstancedata", props);updated[updated.length] = file;}}}model.folder = folder;model.updated = updated;}function hasAspect(aspects, aspect){if (aspects.length == undefined){aspects = aspects.toArray();}for (var i=0; i< aspects.length; i++){if (aspects[i] == aspect){return true;}}return false;}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Que
[size=150]1)if i dont pass the argument from url so what i supposed to write in this line

var storeRoot = avm.lookupStore(sandbox);
what(path) i write in lookupStore instead of sandbox?
2)in this lines,if i dont pass arg from url then what should i write, instead of path?
var path = url.extension;
var folder = storeRoot.lookupNode("ROOT/" + path);[/size]


if you have any suggestion then pls rep-ly me.
thx in advance.
bye

kvc
Champ in-the-making
Champ in-the-making
Hey everyone -

Mark, that looks like a great customization.  Do you mind opening a JIRA feature request, and attaching your code?  That may help us expedite adding this to the core.

Also, please note that if you have an imported XML that is not generated via a Web Form, when you click EDIT and are prompted to download, there is a link on that very same page that allows you to associate it with an existing Web Form.  If you click on that link, you get to pick from a list of all Web Forms associated with your current Web Project.  You do have to select the correct one.  If you do, the XML will open in the form, and upon a subsequent save, the appropriate property will be set.

This does mean that the association happens on a file-by-file basis.  Ideally, we'd have a general action you can run against your entire site to auto-associate any and all XMLs to remove this additional bootstrap effort currently required by your individual content authors.

Kevin

dooley
Champ in-the-making
Champ in-the-making
Quick question, can you give me an example of what value you are passing in for sandbox