• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Use attribute value for setting paragraph formating parameter

Explorer ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Hello,

This seems like a basic question but I couldn't find the answer yet:

I would like to use the integer value of a parameter to set the value of a paragraph formating parameter (here: number of allowed orphan lines)

Here is what my element looks like in the EDD:

Element (Container): Para
	General rule:	<TEXT> | etc...
	Attribute list
		Name: orphan_lines 	Integer 	Optional 
		Range: from 1    to 999
		Default:	1
	Text format rules
		In all contexts.
			Pagination properties
				Widow/orphan lines: orphan_lines

Nevertheless this doesn't work: the parameter "Window Orphan Lines" from Parafraph Designer doesn't get set to the value value of "orphan_lines"

Is the syntax I'm using correct ?

Thanx in advance

Best regards

Eric

Views

161

Translate

Translate

Report

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

correct answers 2 Correct answers

Mentor , Mar 16, 2022 Mar 16, 2022

Hi Eric,

You can't reference an attribute value that way. It seems logical, but it's unfortunately not that flexible. You would need to reference the value in context rules in a more explicit manner, such as:

 

RussWard_0-1647423316768.png

 

...unless somebody knows some syntax that I am forgetting. It's been a while since I wrote EDDs. Hope this helps.

 

Russ

 

[edit] Postscript... with this method, you probably would want to make the attribute a Choice type, so you can limit the values to only those supported by the context rules

...

Votes

Translate

Translate
Community Expert , Mar 16, 2022 Mar 16, 2022

An alternative to Russ's EDD approach would be to use ExtendScript. Here is a snippet that illustrates the basic concept:

 

 

var doc, element, attrValue, pgf;

// Assuming you have doc, element, and pgf objects in scope...
// ...
attrValue = getAttributeValue (element, "orphan_lines");
if ((attrValue) && (attrValue !== "")) {
   pgf.BlockLines = attrValue;
}

function getAttributeValue (element, name) {
    
    var attrList = element.Attributes, i = 0;
    
    for (i = 0; i < attrList.length;
...

Votes

Translate

Translate
Mentor ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

Hi Eric,

You can't reference an attribute value that way. It seems logical, but it's unfortunately not that flexible. You would need to reference the value in context rules in a more explicit manner, such as:

 

RussWard_0-1647423316768.png

 

...unless somebody knows some syntax that I am forgetting. It's been a while since I wrote EDDs. Hope this helps.

 

Russ

 

[edit] Postscript... with this method, you probably would want to make the attribute a Choice type, so you can limit the values to only those supported by the context rules you specify.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

LATEST

Thanx a lot for your answer !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2022 Mar 16, 2022

Copy link to clipboard

Copied

An alternative to Russ's EDD approach would be to use ExtendScript. Here is a snippet that illustrates the basic concept:

 

 

var doc, element, attrValue, pgf;

// Assuming you have doc, element, and pgf objects in scope...
// ...
attrValue = getAttributeValue (element, "orphan_lines");
if ((attrValue) && (attrValue !== "")) {
   pgf.BlockLines = attrValue;
}

function getAttributeValue (element, name) {
    
    var attrList = element.Attributes, i = 0;
    
    for (i = 0; i < attrList.length; i += 1) {
        if (attrList[i].name === name) {
            if (attrList[i].values[0] !== undefined) {
                return (attrList[i].values[0]);
            }
        }
    }
}

 

Votes

Translate

Translate

Report

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