XML Save or Export Question
Copy link to clipboard
Copied
As a newbie to structured Frame (but not XML) I need to
modify an existing application to provide 2 capabilities. So far after lots of searchingI have not found any clues to what I want to do.
Seems simple to me...
- When exporting/saving an XML file I want the resolved value of the cross references to be either added to an attribute of the cross reference tag, or as the content of the tag. If I have a tag called <refint refid="XXXXX"\> I would like the XML when saved to be something like <refint refid="XXXXX" text="Figure 1-1"\> or <refint refid="XXXXX">Figure 1-1</refint>. This is for input to a system that is not smart enough to calculate the numbering.
- When importing/exporting an XML file I would like the value of an attribute on the root element to sync with the $chapnum variable. e.g Tag <chapter chapnbr="1.0">...</chapter> should populate and use the Frame $chapnum variable from the chapnbr attribute and vice/versa.
Is this possible or am I barking up the wrong tree...
Thanks - Jim
Copy link to clipboard
Copied
Hi Jim,
It's not possible with read/write rules. Perhaps XSLT could get you there? Newer versions of FM allow you to apply an XSLT stylesheet (XSLT 1.0) automatically upon import and/or export. Although... I'm not sure if XSLT could handle that first request, which seems a bit complex. An XSLT guru would probably be able to answer that.
If XSLT can't do it, a custom import/export API client could certainly handle this with ease, if you have the resources to build one. No small task there, though, if you are new to it.
Russ
Copy link to clipboard
Copied
I can do #1 with XSLT if I have to. The troubling part is that I need to account for all the various ways the documents are numbered. Every time they change the Frame numbering I would need to update the xslt. I looked at the API and did not see a facility for getting the resolved reference value or the value for an ID. I would do that if someone could point me to the basic functions necessary.
Number 2 seems like it should be possible, but I don't see a way to do this at all.
Thanks - Jim
Copy link to clipboard
Copied
Jim,
I tend to agree that in this case, an API client would be functionally more sensible. However, I should throw in the disclaimer that I know the API much better than I know XSLT. It should be pointed out that API programming, while much more extensible in its capabilities, is far less flexible when it comes to minor updates (it's easy to tweak a stylesheet in an XML editor, more involved with special tools to compile an API client.)
Having said all that, let me tell you what I know... everything you need is in the FDK library, but youll need to piece together some low-level functions to get it working.
The first one might be fairly easy if you know what you are doing, and if all xrefs in the document are currently updated. Xref objects have a property called FP_XRefSrcText which contains, among other things, the text that appears in the document. So, if you can iterate through xref objects with a properties such as FP_FirstXRefInDoc and FP_NextXRefInDoc, you can query for the wrapping element (FP_Element), then set the desired attribute (F_ApiSetAttributes).
For the second one, it would be more straight forward. You could get the variable definition with F_ApiGetNamedObject (I think), then use FP_MainFlowInDoc to get the main flow, then FP_HighestLevelElement to get the root element, then F_ApiSetAttributes to set the attribute.
All that above is just a very short summary with lots of steps left out. I just wanted to get you started with some ideas... I'm not able to compose all the code at the moment. I should say that part of your confusion might be your newbie status with FrameMaker... a strong knowledge of FrameMaker functionality is just as important as knowledge of C. If you choose the API route, you should expect that there will be ramp up time involved simply to get the feel of how the program works.
I hope this helps some... let me know if I can clarify anything.
Russ
Copy link to clipboard
Copied
Thanks Russ - that was quite helpful. Might be more than I am willing to tackle - haven't done any C in 15 years - just getting set up with the compiler and libraries is a major ordeal...
On #2 I actually need the reverse - I need to read the attribute and set the chapter number variable, but I see what you mean.
I appreciate the help.
Jim

