How to load an XML file and save it as a file fm

Hi Experts,

I have a bunch of XML files in a folder. I want to make is that I want iteratively, load the xml using a StructuredApplication and save it as a file FM. I was able to sucessfully load the XML file, but I'm having trouble to save a file of FM.

Here is the code I wrote so far:

If (sourceFolder! = null) {/ / If a valid file is selected}

files = new Array();

fileType = "*.xml";

files = sourceFolder.getFiles (fileType);  Download all the files that match the pattern

If (files.length > 0) {/ / get the destination to save the files}

destFolder = Folder.selectDialog ('Select the folder where you want to save the converted XML files.', ' ~');

for (var i = 0; i < files.length; i ++) {}

Set the options to open the XML file.

var openParams = GetOpenDefaultParams();

var j = GetPropIndex (openParams, Constants.FS_OpenAsType);

. propVal.ival openParams [j] = Constants.FV_TYPE_XML;

j = GetPropIndex (openParams, Constants.FS_StructuredOpenApplication);

. propVal.sval openParams [j] = "XML Snpsbook";

j = GetPropIndex (openParams, Constants.FS_FileIsOldVersion);

. propVal.ival openParams [j] = Constants.FV_DoOK;

j = GetPropIndex (openParams, Constants.FS_FontNotFoundInDoc);

. propVal.ival openParams [j] = Constants.FV_DoOK;

j = GetPropIndex (openParams, Constants.FS_FileIsInUse);

. propVal.ival openParams [j] = Constants.FV_DoCancel;

j = GetPropIndex (openParams, Constants.FS_AlertUserAboutFailure);

. propVal.ival openParams [j] = Constants.FV_DoCancel;

var returnParams = new PropVals();

I'M NOT ABLE TO GET THIS LINE TO RUN. sourceDoc RETURNS a REFERENCE of OBJECT INVALID.

sourceDoc = Open (files [i] .name, openParams, returnParams);  Returns the document object

Alert (SourceDoc.Name);

Function to save. XML file. Extension of the FM

var saveParams = GetSaveDefaultParams();

var returnParamsp = new PropVals();

Change the extension .xml FM

var k = GetPropIndex (saveParams, Constants.FS_FileType);

saveParams [k].propVal.ival = Constants.FV_SaveFmtBinary;

saveAsName = sourceDoc.name.replace (/ \.) [ ^\.\\]+$/,".fm");

var saveInFile = record (saveAsName, saveParams, returnParamsp);  Save as file FM

saveInFile = new file (destFolder + ' / ' + targetFile);

saveInFile.close ();  Close file

}

Alert ("the files are saved in the FM to ' + destFolder");

} else {}

Alert ('no matching files found!');

}

}

Hi reda,.

You are very close, but there are a few critical flaws in your code that will prevent the proper functioning:

-Your paths in string literals must have sequences to escape the backslashes. A backslash character is treated as an adverb in an escape sequence, so those need to be escaped themselves. For example: "C:\\Users\\rajrev\\file.xml."

-Your OpenXMLFile () function does not return anything, then the original DocumentSource variable never gets made.

-It is better to use the ObjectValid() method to test a valid object of FM.

-I am not an expert of regular expression, but I can't understand the logic in your replace() method, to create the new path of the file. In addition, the property "name" of the fileObject is invalid, it must be 'name '. I think that there are simpler ways to do.

-Your call to the Save() method is incorrect. It should be fileObject.Save (saveAsName, saveParams, returnParamsp).

All that being said, here is a quick review, without comment, that works for me:

var sourceDoc = openXmlFile("C:\\Users\\rajrev\\file.xml","XML snpsbook");
if (sourceDoc.ObjectValid()) {

    var path = sourceDoc.Name;
    var filename = path.substring((path.lastIndexOf("\\") + 1), path.length);
    filename = filename.replace(".xml", ".fm");

    path = path.substring(0, (path.lastIndexOf("\\") + 1));
    path = path + "transformed_files\\" + filename;

    //path testing
    //alert(path);

    saveToFm(sourceDoc, path);
    sourceDoc.Close(0);
}

// Function to open and XML file
function openXmlFile(filePath, structApp) {
    var openParams = GetOpenDefaultParams();
    var i = GetPropIndex(openParams, Constants.FS_OpenAsType);
    openParams[i].propVal.ival = Constants.FV_TYPE_XML;
    i = GetPropIndex(openParams, Constants.FS_StructuredOpenApplication);
    openParams[i].propVal.sval = structApp;
    var  returnParams = new PropVals();
    var doc = Open(filePath, openParams, returnParams);
    return doc;
}

//Function to save the opened XML as an FM file
function saveToFm(fileObject, savePath) {
    var saveParams = GetSaveDefaultParams();
    var i = GetPropIndex(saveParams, Constants.FS_FileType);
    saveParams[i].propVal.ival = Constants.FV_SaveFmtBinary;
    var saveAsName = savePath;
    var returnParamsp = new PropVals();
    fileObject.Save(saveAsName, saveParams, returnParamsp);
}

Tags: Adobe FrameMaker

Similar Questions

  • How to load an XML file for salesforce using API BULK?

    Hello

    Please let me know how to download an XML file for salesforce using API bulk?

    Thank you

    AND

    Hello

    I think it's a matter of SalesForce.com more and think that you will have better luck in looking at SOAP API Developer Guide for salesforce. Sending of a server API SOAP request is very straight forward and there are several tutorials and well documented in this topic.

    See you soon,.

    Stefan

  • [Database Toolbox] possibility to Load From xml file in Labview and then in the database

    Before you write in my database, I want to save it and reload if the user wants to cancel the new charge that can last several minutes.

    If he cancels the load I get back my previous database data.

    I managed to save my database in XML through the "DB tools SaveRecordSet To File" VI. This VI records directly contains my database table in the xml file. And finally, I only if the other VI to load file will do the same thing, means load the file and save it in my database but it gives just a recordset in labview.

    Question: is it possible just to load the xml file into the database directly through Labview?

    Why, finally, these screws do not have the same behavior?

    I don't know, but I just thought I would chime, that if you fail to do with LabvIEW, you might want to look by making your writing in a 'Transaction' database, if your DBM takes in charge (most except MS Access)

  • Need help with loading the XML file

    Hello

    I spent reviewing the web/forums for an example on how to do this for a few days now.  I managed to get this working in Flash Pro easily enough, but I think I'm missing something when I want to do the same thing in Flex.

    Basically, I want to load an XML file and then set the values of the text of labels 5, equal to the data in the XML file.

    So I have a button created in MXML and have put the following click event:

    Click = "dsSetup (Event)" "

    I also stated the following:

    public var myRequest:URLRequest = new URLRequest ("assets/myFile.xml");   folder located under the CBC in project

    public var myLoader:URLLoader = new URLLoader();

    public var myXML:XML;

    My function that loads is as follows:

    public function dsSetup(event:MouseEvent):void

    {

         trace ("dsSetup");

    myXML = new XML (myLoader.data);

    H3. Text = myXML.source.itemA;

    H4.text = myXML.source.itemB;

    H5.text = myXML.source.itemC;

    H7.text = myXML.source.itemD;

    H8.text = myXML.source.itemE;

    currentState = "MainMenu";

    }

    myLoader.addEventListener (Event.COMPLETE, dsSetup);   I think that this line is no longer as I put it in the MXML

    myLoader.load (myRequest);

    It's the way I did in Flash and it worked fine, but I must be missing something when it comes to Flex.

    Can you explain or point me to a good tutorial that shows how to load XML in Flex code?

    Those I've found seems to have about 50 lines of code just to load a file and add through a complex for a beginner.

    Thank you very much

    I suggest you save the data loaded in a variable that can be linked, then bind the properties of the text - who:

    [Bindable]

    var myXML:XML;

    public void dsSetup(event:MouseEvent):void

    {

    myXML = new XML (myLoader.data);

    currentState = "MainMenu";

    }

    ...

  • load the xml file into a database to help table of travel point

    Hello

    Someone help me please with a possible approach. I have an interface for APEX users where users can download a file xml in apex table wwv_flow_files using the element to browse with a button "submit". Now, after loading the xml file in the wwv_flow_files table. I need to read and load the xml data into a table sample_tbl. I'm using the version of Oracle APEX 4.0 and Oracle 10 g R2 database. Here is an example of XML file to load. Please help me possible suggestions.

    <? XML version = "1.0" encoding = "UTF-8"? >

    < dataroot generated =... >

    < MySample >

    < KeyId > 1234 < / KeyId >

    eddskc < KeyName > < / KeyName >

    < scheduleDate > 2013-06-16T 00: 00:00 < / ScheduleDate >

    < StartTime > 2013-06-16T 08: 00:00 < / StartTime >

    < EndTime > 2013-06-16T 08:30:00 < / EndTime >

    < / MySample >

    < MySample >

    < KeyId > 5678 < / KeyId >

    jppdf < KeyName > < / KeyName >

    < scheduleDate > 2013-05-19T 00: 00:00 < / ScheduleDate >

    < StartTime > 2013-05-19T 08: 00:00 < / StartTime >

    < EndTime > 2013-05-19T 08:30:00 < / EndTime >

    < / MySample >

    < / dataroot >

    Thanks in advance.

    Thank you

    Orton

    orton607 wrote:

    My sample_tbl has a start_time field and its data type DATE.

    Good.  Be sure to always store dates as the DATE.

    The application (in this case, APEX) needs to format the date date type in the appropriate human-readable format.

    The problem with the incoming data is the 't'.  You will need to convert a space using REPLACE() in the framework so that your SELECT statement

    From there on, conversion to the DATE data type is simply

    to_date( replace( start_time_str, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS') as start_time
    

    And, just in case where, the conversion of DATE for the desired format:

    to_char( start_time, 'MM/DD/YYYY HH12:MI:SS AM')
    

    Although, I'm 'hours' as being left-padded with zeros... Am I looking for how / if you can get rid of the zero prefix (0).

  • How to load 2 xml galleries loop only function.

    How to load 2 xml galleries loop only function.

    my function is-

    var myGalleryXML = new XML();

    myGalleryXML.ignoreWhite = true;

    myGalleryXML.load ("gallery.xml");

    function callThumbs()

    {

    _root.createEmptyMovieClip ("Wall", _root.getNextHighestDepth ());

    Wall._x = _root.gallery_x;

    Wall._y = _root.gallery_y;

    wall.addEventListener (MouseEvent.CLICK);

    var clipLoader = new MovieClipLoader();

    preloader var = new Object();

    clipLoader.addListener (preloader);

    for (i = 0; i < 6; i ++)

    {

    thumbURL = myImages [i].attributes.thumb_url;

    myThumb_mc = wall.createEmptyMovieClip (i, wall.getNextHighestDepth ());

    myThumb_mc._x = _root.thumb_height * i;

    myThumb_mc._x = _root.thumb_position = - 3100 + (i - j) * 765;

    clipLoader.loadClip ("store /" + thumbURL, myThumb_mc);  I want to load this XML Gallery "gallery1.xml".

    preloader.onLoadStart = function (target)

    {

    target.createTextField ("my_txt", target.getNextHighestDepth (), 0,0,10, 10);

    Target.my_txt. Selectable = false;

    };

    preloader.onLoadProgress = function (target, loadedBytes, totalBytes)

    {

    Target.my_txt. Text = Math.floor ((loadedBytes / totalBytes) * 100);

    };

    preloader.onLoadComplete = function (target)

    {

    The new Tween (target, "_alpha", Strong.easeOut, 0, 100,.5, true);

    Target.my_txt.removeTextField ();

    target.onRelease = function()

    {

    callFullImage (this._name);

    };

    target.onRollOver = function()

    {

    This ._alpha = 100;

    };

    target.onRollOut = function()

    {

    This ._alpha = 100;

    };

    };

    }

    for (i = 0; i < 6; i ++)

    {

    thumbURL = myImages [i].attributes.thumb_url;

    myThumb_mc = wall.createEmptyMovieClip (i, wall.getNextHighestDepth ());

    myThumb_mc._x = _root.thumb_height * i;

    myThumb_mc._x = _root.thumb_position =-7210 + (i - j) * 765;

    myThumb_mc._y = _root.thumb_position = 180;

    clipLoader.loadClip ("banner /"+ thumbURL, myThumb_mc ");  / / I want to load this XML Gallery 'gallery2.xml'

    preloader.onLoadStart = function (target)

    {

    target.createTextField ("my_txt", target.getNextHighestDepth (), 0,0,10, 10);

    Target.my_txt. Selectable = false;

    };

    preloader.onLoadProgress = function (target, loadedBytes, totalBytes)

    {

    Target.my_txt. Text = Math.floor ((loadedBytes / totalBytes) * 100);

    };

    preloader.onLoadComplete = function (target)

    {

    The new Tween (target, "_alpha", Strong.easeOut, 0, 100,.5, true);

    Target.my_txt.removeTextField ();

    target.onRelease = function()

    {

    callFullImage (this._name);

    };

    target.onRollOver = function()

    {

    This ._alpha = 100;

    };

    target.onRollOut = function()

    {

    This ._alpha = 100;

    };

    };

    }

    }

    combine the two into a single xml files if you want to create a gallery.

    If you want two different galleries that display at different times, tear down the wall of movieclip after that finished with gallery1 and run myGalleryXML.load("gallery2.xml");

  • I can't seem to figure out how to import multiple XML files in Flex

    I can't figure out how to import multiple XML files in Flex and connect it to the DataGrids. Does anyone have ideas how to make this happen?

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:fx s:Application ' http://ns.Adobe.com/MXML/2009 "
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" minWidth = "955" = "600" minHeight >

    < s:creationComplete >
    <! [CDATA]
    loader.addEventListener (Event.COMPLETE, getData);
    loader.load (new URLRequest ("http://www.student.hint.no/~100471/mmt134/images/Reiseregning-Konradi_Kare_2011-01-30.xml"));   

    []] >
    < / s:creationComplete >

    < fx:Declarations >
    <! - Place non-visual elements (e.g., services, items of value) here - >
    < / fx:Declarations >

    < fx:Script >
    <! [CDATA]
    var testData:XML;

    var loader: URLLoader = new URLLoader();

    public void getData(E:Event):void {}
    testData = new XML (E.currentTarget.data);
    grid.dataProvider = testData.descendants ('TravelSpecificationVO');
    }

    []] >
    < / fx:Script >

    < mx:TabNavigator "22.7" = x y = '39.35' width = '536' height = "312" >
    < s:NavigatorContent label = "Tab 1" width = "100%" height = "100%" >
    < mx:DataGrid = "1.3" x = "-2.35" width = "507" height = "269" id = "grid" >
    < mx:columns >
    < mx:DataGridColumn dataField = "to_destinasion" headerText = "Til destinasjon" / >
    < mx:DataGridColumn dataField = "from_date" headerText = "Klokkeslett" / >
    < mx:DataGridColumn dataField = "from_destinasion" headerText = "Fra destinasjon" / >
    < mx:DataGridColumn dataField = "to_date" headerText = "Klokkeslett" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / s:NavigatorContent >
    < s:NavigatorContent label = "hkuhk" width = "100%" height = "100%" >
    < / s:NavigatorContent >
    < / mx:TabNavigator >
    < / s:Application >

    Hope this helps you:

    
    
     
      
     
    
     
      
       
       
       
       
      
     
    
    
    

    Let me know if you need additional information.

    Best regards

    Pablo Souza

  • shipment value of the PHP variable to Flash to load an xml file

    I would like to load an XML file to the local location or on the server to ignore the name of the file. I use PHP to send the name of the Flash file.

    Here it is the PHP code:

    <? PHP

    filesInDir ('C:\Documents and Settings\457305\My Documents\shrikant\Flash Tutorials\webassist');

    function filesInDir ($tdir)

    {

    $dirs = rewinddir(3) ($tdir);

    foreach ($dirs as $file)

    {

    If (($file == '.') |) ($file == '..'))

    {

    }

    else if (is_dir ($tdir. » /'. $file))

    {

    filesInDir ($tdir. » /'. $file);

    }

    on the other

    {

    echo "fileName = $file";

    }

    }

    }

    ? >

    And here is the Actionscript code loading:

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.events.Event;

    to import flash.net.URLVariables;

    Stop();

    Set the PHP file to load

    var phpFile:String = " " http://localhost/WebAssist/test.php ";

    var cons_xml:XML;

    var xmlLoader:URLLoader = new URLLoader();

    Specify the property dataFormat of the URLLoader to be "VARIABLE".

    This ensures the variables loaded into Flash with the same variable names

    xmlLoader.dataFormat = pouvez;

    xmlLoader.load (new URLRequest (phpFile));

    xmlLoader.addEventListener (Event.COMPLETE, processXML);

    function processXML(evt:Event):void

    {

    trace (evt. Target.Data.FileName);

    cons_xml = new XML (evt.target.data.fileName);

    gotoAndPlay (2);

    }

    When I trace evt.target.data it displays "fileName = mainOpenEndedXML % 2Exml" and when I trace evt.target.data.fileName the file name is correctly displayed as 'mainOpenEndedXML.xml'.

    But in the two next lines where the loading is done that it does not load the file IE does not play the SWF to an xml file.

    I've searched the Internet to find answers, but not able to find solutions.

    Loading works fine if I insert the xml file directly in the code and the SWF in the XML file plays correctly. Here it is the code for the same thing:

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.events.Event;

    to import flash.net.URLVariables;

    Stop();

    var cons_xml:XML;

    var xmlLoader:URLLoader = new URLLoader();

    xmlLoader.load (new URLRequest ("mainOpenEndedXML.xml"));

    xmlLoader.addEventListener (Event.COMPLETE, processXML);

    function processXML(evt:Event):void

    {

    cons_xml = new XML (evt.target.data);

    gotoAndPlay (2);

    }

    Any help on this would be greatly appreciated


    You said you use PHP to send the name of the Flash file.  If the php file you provide only the name of the xml file that you need to load, then you will have to load the xml file in the same way that you show in your last set of code where you say that load you it directly.

  • Problem loading an xml file if not placed locally.

    Hey!

    I started a discussion on my capture setting problem and I now reduced it now. It turns out it wasn't settings do not have caught. The swf file takes the fine settings, so this apparently isn't the issue. My problem is that it seems that the file won't loaded .xml. When I have my .xml and .swf file locally on my computer and it works, it works very well. When I place it on my web server the same way, it works fine. However, when someone puts my .swf in embedded on their Web site that the XML will not be loaded by the SWF for a reason any. Here's the AS3 code, load the xml file. He was works well all the way until I started playing with the call of the swf from different sources (web server of my friend in the integrating etc.).

    -loading of the external xml file.

    var urlRequest:URLRequest = new URLRequest ("http://www.website.com/folder/myfile.xml");

    var urlLoader:URLLoader = new URLLoader();

    var myXML:XML = new XML();

    var xmlList:XMLList;

    myXML.ignoreWhitespace = true;

    urlLoader.addEventListener (Event.COMPLETE, fileLoaded);

    urlLoader.load (urlRequest);

    function fileLoaded(event:Event):void {}

    the code to play with the xml file once loaded

    }

    It seems that fileLoaded() is never executed unless the swf runs locally or on my computer or my server or called directly in the browser (like by typing in the web address field). I really can't understand what is wrong. Any suggestion is appreciated!

    try to create a file crossdomain.xml with this information:

    http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">     
    
  • Loading multiple Xml files.

    Ive got a menu based on xml and xml Photo Gallery based on the same chassis on my calendar.
    When I try to preview the film only the photogallery load xml file.

    I was wondering if anyone knows a method to load two xml files at a time or one after the other...

    Ive been after Jacques tutorials for menu xml and xml photo gallery... my code is very similar to them.
    Thanks in advance.
    Chris.

    Simply create separate XML objects.

    myXmlMenu = new XML();
    myXmlGallery = new XML();
    myXmlMenu.load (...)
    myXmlGallery.load (...)
    etc.

  • Load the XML file into oracle using sql loader

    Hello

    I'm trying to load an xml file into a table using sqlldr.
    I have a table as follows:
    CREATE TABLE xmlloadtable
    ( id number,
     data_xml XMLType
     )
      XmlType data_xml STORE AS CLOB;
    I have a control file that I know is perfectly false:
    LOAD DATA 
    INFILE '/home/oraread/'
    INTO TABLE xmlloadtable 
    (
    id,
    data_xml 
    )
    I googled for the file control and tried in different ways, but of no use.
    I want to load the entire xml file into the table.
    Can someone help me with the correct control file. Any help is appreciated!

    Try this

    LOAD DATA
    INFILE '/home/oraread/'
    INTO TABLE xmlloadtable
    (id,
     file_name          filler,
     data_xml          lobfile(file_name) terminated by eof
    )
    

    You can add the file as a column name field to your table between the id and xml column and remove the word to fill in the .ldr file if you need to keep the name of the file

  • How to import the XML file into an oracle table using a BPEL process

    Hi friends

    How can I import XML file in the db oracle table using a BPEL process

    (1) I have generated an XML file in my local system with a field
    (2) I created a temporary table in my oracledb with the same field in the XML file
    (3) that I want to import these XML files which is the local host to my db oracle using a BPEL process
    (4) for that what steps should I me fallow please suggest me if there is no document for this?

    Thanks in advance
    AT

    Hi to

    Here you go...

    http://blogs.Oracle.com/ajaysharma/2011/03/using_file_adapter_database_adapter_and_mediator_component_in_soa_11g.html

    I hope that helps!

    Thank you
    AJ

  • Load the XML file into oracle DB using OWB

    Hi friends,

    I'm new XML data.
    I had a requirememnt to load the xml file into an oracle table.
    Can someone procedure to load the data.

    Thanks in advance

    see this

    http://blogs.Oracle.com/warehousebuilder/2007/09/leveraging_xdb.html

  • How to load the ase file?

    I apologize in advance for this fundamental question, but... I'm on a mac osx use illus/photoshop cs2. How to load kuler .ase files?

    Hello, please check this thread earlier .
    Saami

  • How to have an XML file in the app and / or installation

    My application is an xml file that accompanies it (actually more than one) and contains data for the application

    We choose based on user input.

    Is it possible to have a resource file such as an xml file that is provided with the blackberry .cod file?

    I think of how you can put a java application needs resources in the java app jar file.

    If I can't do that, where these xml files should be?

    I see some file access described in the forum using the SD card.

    But obviously I don't want that, because these files xml are always necessary when the user starts the application.

    These files are part of the application, they should not be changed by the user.

    How would this work?

    Thank you!!

    lucidbee

    You add the XML file to your project and get as a resource in your code.

    See the following article:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

Maybe you are looking for

  • Get tabs for reload on startup

    I use Firefox to read the news. I have it on a schedule, so that it opens half an hour before I get up, so when I'm in front of my computer, they are all loaded and waiting. Before the last update, all tabs loaded at startup. Today, many sites don't.

  • Audio Jack display empty

    Hello Recently, I just took my Mac Mini and used Boot Camp to put Windows 10 on it. Now for some reason any the audio jack, I have Logitech speakers plugged in, does not show as having something plugged. I tried to update the drivers Audio Cirrus and

  • Toshiba e-studio 206 does not print USB cable

    Hello! We have Toshiba e studio 206 which is installed with the usb cable.Official drivers for e-studio 206 granted official website (here and later - a Russian) had been installed without error, the device shows any errors as well and can be used as

  • An easy way to re-import massive media after a hard disk crash if the library files are intact?

    Hello I'm running 10.2.3 on OS X 10.11.3 FCPX. My external hard drive just crashed, and while I was able to save most everything else (including library files, proxy support, etc.), Miss me about 90% of the media about 2 000 "original" files. Because

  • c:\windows\eqixoxiwakev.dll the specific module could not be found

    Error message when starting windows xp: c:\windows\eqixoxiwakev.dll the specific module could not be found. Can anyone help? Thank you.