get attribute value of .fm files with extendscript

Community Beginner ,
Dec 18, 2018

Copy link to clipboard

Copied

I want to get concept-outputclass value with extend script ?

TOPICS
Scripting

Views

187

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Advocate ,
Dec 18, 2018

Copy link to clipboard

Copied

Hello Jacob,

It is a little unclear what you are asking for:

a) Getting some properties of a File object for an .fm file ?

b) Getting the value of the outputclass attribute on a DITA concept ?

I am guessing you mean to ask the second question. To get an attribute value of an element in any structured file, you need the following code:

function GetAttribute( oElement, sAttribute )

{

  /*  This function retrieves the value of the named attribute on the element. */

  var oaAttrs = oElement.Attributes;

  var sRetVal = "";

  var i = 0;

    var bFound = false;

    while( i < oaAttrs.length && !bFound )

    {

  if( oaAttrs.name == sAttribute )

        {

  bFound = true;

  if( oaAttrs.values.length > 0 )

  {

  sRetVal = oaAttrs.values[0];

  }

        }

        i++;

  }

  return sRetVal;

}

Then find the concept element, which is the root of your document:

var oConcept = app.ActiveDoc.MainFlowInDoc.HighestLevelElement;

and get the @outputclass value

var sOutputClass = GetAttribute( oConcept, "outputclass");

Kind regards

4everjang

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jacob_AA AUTHOR LATEST
Community Beginner ,
Dec 18, 2018

Copy link to clipboard

Copied

Hi, it works thanks

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more