Copy link to clipboard
Copied
I need to publish structured documents to xml. Some of the Headings are created by prefix rules in the EDD. When I publish the document to xml, the headings are missing in the xml.
I am a scripting novice to be honest, I have no clue how to get the text out of the prefix rule, which depends on the context. In the FrameMaker scripting guide I found the following objects which may or may not handle the prefixes
- Element.MatchingPrefixClause; of data type Objects (ID of the prefix clause that apply to the element)
- ElementDef.PrefixRules; of data type objects (IDs of the prefix format rules)
- FmtRuleClause.ElemPrefixSuffix: of data type string (The text of the string)
I am able to select the heading element, but how the hell do I get the content of the prefix from there?
Any hints appreciated!
This is kind of a brute force method, but it looks like a prefix shows up in the list of the element's strings. If you know for sure that the element has a prefix, you can probably use something like this. Note that you may have to drop the delimiter between the prefix and the main element text from the end of the string.
#target framemaker
main ();
function main () {
var doc, element, stringArray, prefix;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
element
...
Copy link to clipboard
Copied
This is kind of a brute force method, but it looks like a prefix shows up in the list of the element's strings. If you know for sure that the element has a prefix, you can probably use something like this. Note that you may have to drop the delimiter between the prefix and the main element text from the end of the string.
#target framemaker
main ();
function main () {
var doc, element, stringArray, prefix;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
element = doc.ElementSelection.beg.child;
stringArray = (getAnArrayOfStrings (element, doc));
prefix = stringArray[0];
alert (prefix);
}
}
function getAnArrayOfStrings (textObj, doc) {
// Gets an array of strings from the text object or text range.
var text, textItems, count, i;
text = [];
// Get a list of the strings in the text object or text range.
if (textObj.constructor.name !== "TextRange") {
textItems = textObj.GetText(Constants.FTI_String);
} else {
textItems = doc.GetTextForRange(textObj, Constants.FTI_String);
}
// Concatenate the strings.
count = textItems.len;
for (i = 0; i < count; i += 1) {
text.push (textItems[i].sdata);
}
return text; // Return the array
}
Copy link to clipboard
Copied