Skip to main content
Inspiring
February 3, 2015
Question

Variable for the content of an attribute value? (EDD)

  • February 3, 2015
  • 1 reply
  • 1460 views

Hi all,

I would like to use the exact string of an attribute value as a property value when defining a text format rule in the EDD.

Is there a way to get the attribute value by using a variable?

---

Example:


This is a <font family="Helvetica">test</font>.

I have an element "font" with the attribute "family". The value of this attribute is the name of the font family that I would like to use for the text in the "font" element.

So in my example "test" shall be formatted with Helvetica.

Of course I could use a context rule for every font family, like this:

If context is: [family="Helvetica"]
     Text range.     
        Font properties
          Family: Helvetica If context is: [family="Arial"]      Text range.    
        Font properties
          Family: Arial If context is: [family="Times"]      Text range.    
        Font properties
          Family: Times ... etc.

The problem is that I can't tell which fonts I am going to use in future plus they can change from time to time. That's why I would like to avoid having to update my EDD and add or remove text format rules every time I know that I am going to use a new font. For that reason I am looking for a way to format the text with the value of the attribute "family".

I've found out that I can output the attribute value in a prefix or suffix rule by using <$attribute[value]>.

So the rule

In all contexts.
Prefix: <$attribute[family]>

would output the following:

This is a Helveticatest.

That means whatever the value of "family" is, it can be displayed as a prefix or suffix by using this variable. But unfortunately this kind of variable doesn't seem to work in text format rules as I always get this error message:

Referenced font family (<$attribute[family]>) does not exist. Property was not imported.

Do you have any helpful ideas? Thanks a lot in advance!

Best regards from Germany,

Sebastian

This topic has been closed for replies.

1 reply

ScottPrentice
Inspiring
February 3, 2015

This falls into the "advanced" category of EDD development, but can be a great trick.

As you've found, the <$attribute[value]> feature only works in certain locations in an EDD. However, you can modify the structure of the EDD to make this available in other locations. (Yes .. the EDD is just a "normal" structured document and has it's own EDD .. the EDD-EDD!) Just open your EDD and use Structure Tools > Export Element Catalog as EDD. This provides you with the EDD's EDD, which you can modify just like any other EDD. You'll see an element definition for the "AttributeValue" element. You'll also see where this element is valid (in general rules of other element definitions).

Locate the element that you'd like this feature to be enabled and add the AttributeValue element to its general rule. Save this EDD-EDD so you can use it later, then import that EDD into your structure application's EDD. This new node should be available to use in the way you suggest.

Well .. maybe. I've seen situations where this doesn't work. Not sure why, but apparently it doesn't work everywhere. Give it a try!

...scott

szfl89Author
Inspiring
February 4, 2015

Hi Scott,

First of all, thank you very much for the quick reply. Modifying the EDD-EDD sounds like a great idea.

I just tried to add the "AttributeValue" element to the general rule of the "Family" (like it's written in the general rules of "Prefix" and "Suffix"), but I still get an error message, because FrameMaker still thinks that I want to use a font called "<$attribute[family]>". So the variable doesn't seem to be accepted. Maybe "Family" is one of the elements where this doesn't work—or maybe I have missed something.

Do you know any elements where this modification definitely works, so I can try them first to check if I am doing it correctly?


Thanks again!

Sebastian

ScottPrentice
Inspiring
February 4, 2015

I'm unable to look at this today (maybe later in the day), but will try to take a look tomorrow to give you more details.

...scott