Xml Conversion Using Fdk

Ram kumar ramsambath at gmail.com
Mon Jul 14 01:30:10 PDT 2008


Hi Freinds...
                    i need to create an API which converts the .fm file to
Xml using Fdk7.2...(C++)

the code follows here

/*Open an XML File
This opens an XML file. In FrameMaker 7.0, the XML file opens as an FM file,
but in
FrameMaker 7.1 and above, is opens as XML and the file is locked on disk.
     */
#include "fapi.h"

VoidT openXML ()
              {
            F_PropValsT params, *returnParamsp = NULL;
            IntT i;

         params = F_ApiGetOpenDefaultParams();

         if (params.len == 0) {

      F_Printf(NULL, (StringT)"File not opened.Unable to allocate
memory.\n");
      return;
}

       i = F_ApiGetPropIndex(&params, FS_OpenAsType);
       params.val[i].propVal.u.ival = FV_TYPE_XML;


i = F_ApiGetPropIndex(&params, FS_ShowBrowser);
params.val[i].propVal.u.ival = True;


i = F_ApiGetPropIndex(&params, FS_StructuredOpenApplication);
params.val[i].propVal.u.sval = F_StrCopyString((StringT) "XDocBook");

if (!(F_ApiOpen("", &params, &returnParamsp)))
{
F_ApiAlert("Couldn't open file.\n", FF_ALERT_CONTINUE_NOTE);


F_ApiDeallocatePropVals(&params);
F_ApiDeallocatePropVals(returnParamsp);
return;
}
else
{
/* Deallocate property lists*/
F_ApiDeallocatePropVals(&params);
F_ApiDeallocatePropVals(returnParamsp);
return;
}

}
/*Save an XML File
This saves the active document to the file sample.xml. In FrameMaker 7.0,
the active FM
document is saved to disk as sample.xml, keeping the FM document active. In
FrameMaker 7.1

and above, the open XML document is saved to sample.xml, making sample.xml
the
active document.
*/
VoidT saveXML ()
{
F_PropValsT params, *returnParamsp = NULL;
IntT i;
F_ObjHandleT docId = F_ApiGetId(0,0,FP_ActiveDoc);
/* Get default save properties. Return if it can't be allocated. */

params = F_ApiGetSaveDefaultParams();
if (params.len == 0)
{
F_Printf(NULL, (StringT)"Couldn't get save parameters!\n");
return;
}

/*Specify XML as file type to save*/

i = F_ApiGetPropIndex(&params, FS_FileType);
params.val[i].propVal.u.ival = FV_SaveFmtXml;

/* Specify the XML application to be used when saving the document.*/
i = F_ApiGetPropIndex(&params, FS_StructuredSaveApplication);
params.val[i].propVal.u.sval = F_StrCopyString((StringT) "XDocBook");


if (!(F_ApiSave(docId, "sample.xml", &params, &returnParamsp)))
{
F_ApiAlert("Couldn't save file.\n", FF_ALERT_CONTINUE_NOTE);
/* Deallocate property lists*/

F_ApiDeallocatePropVals(&params);
F_ApiDeallocatePropVals(returnParamsp);
return;
}
else {
/*Deallocate property lists*/
F_ApiDeallocatePropVals(&params);
F_ApiDeallocatePropVals(returnParamsp);
return;
}
}



its leading to errors... is there any other way to do it using *FRAMESCRIPT
or MIF???

But in m y company they want me to convert using fdk....
Help me......
Thanks in Advance..............
*



More information about the framers mailing list