Copy link to clipboard
Copied
Hi,
I am using FDK 12.0 on Windows (using Visual Studio 2012) to make some changes in a FrameMaker document programmatically. I have never used this or any other Adobe API before and am somewhat struggling with the concepts. Primarily I am using the sample programs, coming along with the FDK to guide me.
Now, I want to open and parse an XML file, whose content I will use later to manipulate the texts in a FrameMaker document. In .NET framework there are several classes (XMLReader, XMLTextReader etc.) to read and parse XML files easily. However, it seems I cannot use these Common Language Runtime classes because, apparently, a FDK plug-in needs to be a) C program and b) should not use CLR. In view that, can anyone please indicate if there are any suitable set of functions in FDK itself for parsing an XML file. Otherwise, is there any pure C based XML parser I can use? Some actual sample will be very helpful.
Thanks in advance,
Joydeep
[Discussion moved by moderator]
Copy link to clipboard
Copied
Hi Joydeep,
This is a complicated topic, one that could not really be addressed via a forum post. I will try to clarify one thing for you though... the majority of FDK functions are intended to work on documents that are open within FM. When you open an XML file in FM, it becomes a structured FM document and thus is no longer really an XML file. Unfortunately, the FDK (like the rest of FM) really lacks any good structure-aware features to operate upon the markup. So, the FDK answer is... nothing much at a high level to parse structural metadata in an FM document.
Because an XML file opened in FM is no longer XML, any other third-party library will be useless for this purpose. Once in FM, you are locked into the FM object model.
Now, this is all assuming you are operating on files opened in FM. If you are working with the files directly, then you can use third-party libraries. But then again, you wouldn't need FM and all and thus probably not the FDK. So, the fact that you are looking at the FDK leads me to believe that your requirement is to parse XML-tagged data within FM.
Those of us who have been around for a while have built up our own personal libraries to deal with structure. For example, I have my own XPath parser and navigator that I use within my software. However, I think we all (and there are very few of us) just keep this type of software to ourselves to protect our intellectual property.
I know this doesn't directly answer your question, but I hope it helps some.
Russ
Copy link to clipboard
Copied
I think you might be better off checking in the Scripting forum (https://forums.adobe.com/community/framemaker/extendscript?view=overview) rather than the unstructured FM forum
Copy link to clipboard
Copied
Hi Joydeep...
To follow up on Russ' comments .. yes, if a file (XML or otherwise) is opened in FM, it's no longer a file of the original type, it's an FM document, and you'll need to use the standard FDK libraries to work with it. However, there's no reason that you can't parse XML files "on disk" using libraries other than those provided by the FDK. I use a C library called MiniXML for this purpose. Other developers use other libraries. I've not used .NET, but I know that some do, and have likely overcome the issue of using CLR. For FDK questions, you'll probably have better luck using the frame_dev Yahoo group ..
https://groups.yahoo.com/neo/groups/frame_dev/info
Cheers,
…scott
Copy link to clipboard
Copied
Hi all,
Thanks for your replies. I have managed to solve the problem by using a 3rd party C based XML parser, named libxml.
I am sorry my original question was not very clear. I did NOT need the XML file to be opened in FM as a framemaker document. I only needed to parse it "on disk" as saprentice has said. However, I needed this to happen within a FrameMaker plug-in. My actual requirement is to search and replace certain texts in a framemaker document, where the texts to be searched for and texts to be replaced with, will both come from an XML file. Hence, I had to parse this XML from a plug-in developed by FDK. Anyway, it is solved now, following your suggestions.
Best regards,
Joydeep
Copy link to clipboard
Copied
Hi Joydeep,
I'm happy to hear this response, because I feared that you were much further from the solution than it seems. Without a doubt, you'll have much better luck with raw XML and libxml than the FDK and structured documents. By itself, Structured Frame is like a world where someone invented XML but then virtually nothing else... no XPath, XSLT, etc. A tragic waste of such rich markup capabilities.
Russ
Copy link to clipboard
Copied
Hi guys,
this may be not too helpful at all to the original topic - but wouldn't it have been much easier to solve this issue using some XSLT on import/export of the document?
This is just to clarify that a bit for my own mental model.
Currently I'm using such a transformation to convert some legacy documents into our new structure, replacing quotation marks with XML tags for further processing.
-Alex