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

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

Community Beginner ,
Feb 03, 2015 Feb 03, 2015

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

TOPICS
Structured
1.5K
Translate
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
Advisor ,
Feb 03, 2015 Feb 03, 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

Translate
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 Beginner ,
Feb 04, 2015 Feb 04, 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

Translate
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
Advisor ,
Feb 04, 2015 Feb 04, 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

Translate
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
Advisor ,
Feb 04, 2015 Feb 04, 2015

I've added this to the general rule of the TableFormat element definition.

One thought .. when you're using this in the Family element general rule .. did you just type this in plain text, or did you insert the AttributeValue element? If you just type it in, it'll think that's the name of the font family .. after updating the EDD-EDD you should see the AttributeValue element available to insert as a child of the Family element in your EDD.

Hope that helps!

...scott

Translate
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 Beginner ,
Feb 05, 2015 Feb 05, 2015

I tried both, but it always think it's the name of the font family.

My general rule of the element in the EDD-EDD is:

(<TEXT>, AttributeValue)+

That's the only thing I've changed there which I hope is correct.

Then, in my EDD, I am able to insert the element as a child and enter the attribute there, so it looks like this:

Family: <$attribute[AttributeName]>

I also tried only to allow "AttributeValue" in the general rule, but I keep getting the error message.

Same with TableFormat (thanks for looking that up!). I used the above-written general rule for the TableFormat element in the EDD-EDD, imported this EDD into the EDD that I use for my structured document, adding a rule for tables telling to use the value of an attribute for a table format. I made sure that the table format is stored in the table catalog and created a table with this name as the value of the attribute that I use in the variable in my EDD. But after importing the EDD, I have the same problem with the table format: FrameMaker just creates a new table format called <$attribute[AttributeName]>.

Have I overlooked something?

Thanks,

Sebastian

Translate
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
Advisor ,
Feb 05, 2015 Feb 05, 2015

I'll have to test it. I know this works in TableFormat since I use it frequently. There must be something that you've overlooked in the process. You are importing the app EDD (the one that has the EDD-EDD imported) into your template, yes? And you're sure you've got the right version of the app? (Sorry, these are obvious questions, but often it's the obvious things that are overlooked.)

I'll get back to you after I've had a chance to see if I can get this to work in the Family general rule.

...scott

Translate
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
Advisor ,
Feb 05, 2015 Feb 05, 2015

Yup .. it doesn't work. I get an error when importing the EDD into the template. It looks like the import process is doing a pre-check for the validity of the value assigned to the Family element. If you use this in a location where the text string "<$attribute[val]>" was actually valid, then it should work, because the attribute value will get swapped in at "run time."

I don't think this is going to work the way you're hoping. Would be nice. The best thing I can suggest is to create a script or plugin that you run which assigns the font based on the attribute value.

Cheers,

...scott

Translate
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 Beginner ,
Feb 06, 2015 Feb 06, 2015

Ah, too bad ... Thanks a lot for your help, though! I really appreciate it.

Even though I am not able to solve this problem with the EDD, I am sure that knowing about the EDD's EDD is going to help me with other issues in the future. Seems to be a great trick for some things.

Best wishes,

Sebastian

Translate
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
Guest
Feb 09, 2015 Feb 09, 2015

Sebastian

You have your <Element> called <Font>. I would add that to all your general rules where you want the text range to appear. I would then create an @Attribute called @FontOverride or something to that effect. Then i would use these text format rules

Element: Font

General Rule: <TEXT>

Attribute List

Name:FontOverride          Choice           Optional           

Choices Yes, No

Default No

Text Format Rules

If context is: Font[FontOverride="Yes"]

     Text range.    

        Font properties

          Family: Times

Else

   No additional formatting

The font family i would control using a user variable so you can change that for all your instances by changing that one user variable instead of changing it in multiple places. To be fair you wouldn't need the variable if you just edited the EDD in that singular place The other option could be using Text Insets but that requires additional plugins.

Hope that helps you.

Translate
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 Beginner ,
Feb 10, 2015 Feb 10, 2015
LATEST

Thank you, but I am not sure if I got that right. It looks like this way only helps if I want to assign only one font family to all <Font> elements in the document.

But I need the possibility to use different font families by getting the font family name from the attribute of the <Font> element, so a variable which refers to the value of that attribute would be the best.

Example:

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

In this example, I would like to format the word "This" with "Times" and the word "test" with "Arial", so in the EDD I can't say that every <Font> element shall be formatted with a special font family, because it can always change depending on its attribute value.

Sebastian

Translate
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