About Arbortext Styler > Publishing XML Documents as RTF Files > Publishing XML Attributes to Unique Word Paragraph or Character Styles
  
Publishing XML Attributes to Unique Word Paragraph or Character Styles
With Arbortext Import/Export, you can publish a document as an RTF file, mapping a context and its attributes to multiple paragraph or character styles. This will create generated text that presents attribute values as well-formatted visible text such as #PCDATA. This technique can be beneficial when a top-level element contains metadata attributes that must be included in the content of the published document.
Consider the following markup:
<topic audience="marketing"
importance="urgent"
otherprops="company-confidential"
platform="windows"
product="Widget 1.0" xml:lang="en-us">
You may want the resulting RTF document to contain content similar to the following:
Product: Widget 1.0
Department: Marketing
Platform: Windows
Priority: Urgent
For Internal Use Only
You may want each newly-created paragraph to use a Word style name that reflects its role, such as Product, Department, Platform, Priority, and Status. The values could also be accurately re-imported as attributes on the topic element.
To map a context and its attributes to multiple paragraphs in Arbortext Styler, create a User Formatting Element (UFE) for each attribute on the context you wish to publish. The default context of each newly-created UFE makes it simple to assign a Word style name and sophisticated generated text to highlight and display attribute data which is very important, yet has no corresponding structural counterpoint in RTF. Word has no concept of attributes except at the level of document stylesheet properties. The technique described here serves the purpose well at any structure level, not just the document level.
Use the following steps to create the published output described in the earlier example:
1. In Arbortext Styler, create UFEs for each attribute to be published. Refer to Adding User Formatting Elements to Generated Text for steps on adding UFEs.
For this example, create the following UFEs:
ufe:product
ufe:audience
ufe:importance
ufe:platform
ufe:otherprops
2. In the Generated text category for the topic element, click Edit to add generated text before the element. Use the Insert > User Formatting Element menu option to insert your UFEs in the required order, then add leading text to the first 4 UFEs as shown below:
The Gentext Editor with the described UFE markup.
3. In the case of _ufe:otherprops, the attribute value is not published as document content. Instead, unique generated text is created based on the value of the attribute.
Create a condition on _ufe:otherprops that will output the generated text For Internal Use Only when the otherprops attribute has the value company-confidential:
The Gentext Editor with the described condition on ufe:otherprops.
Refer to Adding User Formatting Elements to Generated Text for information on working with conditions.
4. Assign direct styling to each of the newly-created UFE elements, or reference a Word style name, to format the output.
5. The granularity of the output in terms of paragraph styles and character styles is at the discretion of the stylesheet developer. If the published document might be later re-imported, consider creating UFE elements with an Inline style to denote the generated text and UFE elements styled as Block to wrap the #PCDATA. This makes it is easier to filter out and remove the character styles which were the result of generated text, and simplifies the mapping of the text back into the appropriate XML attributes.