Skip to main content
Participant
April 3, 2013
Question

Representing XML Data in a Table

  • April 3, 2013
  • 2 replies
  • 987 views

Hi All,

I have an XML document that looks like this:

<params>

     <param>

          <name>Parameter 1 name</name>

          <description>Parameter 1 name</description>

          <default>Parameter 1 default value</default>

      </param>

      <param>

          <name>Parameter 2 name</name>

          <description>Parameter 2 name</description>

          <default>Parameter 2 default value</default>

      </param>

</params>

I want to open this file in Structured FrameMaker, and make this information to be displayed in a tabular form. That is, I want to get a table where each <param> will be represented by a table row, and <name>, <description>, and <default> will be columns.

I know how to create an EDD for this, but how can I make it display in a tabular form?

Any help is greatly appreciated.

Many thanks,

Stewart

This topic has been closed for replies.

2 replies

Inspiring
April 3, 2013

I'll try to help you with some basic r/w-rules:

element "params" {

  is fm table element;

  fm property columns value is "3";

}

element "param" {

  is fm table row element;

}

element "name" {

  is fm table cell element;

}

element "description" {

  is fm table cell element;

}

element "default" {

  is fm table cell element;

}

This won't work out of the box, but is a place to start with.

Stewart0Author
Participant
April 3, 2013

Thanks!

But what should I specify in the EDD to make FrameMaker to create a table? Or shoud I code an XSL transform that will convert <params> to <table>, <param> to <row>, etc.?

Inspiring
April 4, 2013

Well, without knowing what you want to with that table, it's hard to say.

Sure, you could just do an identity transform to fit your raw data into an existing table formatting (like DITA).

Or you could build your own EDD.

Depends on what you  want to accomplish.

If you want to know how you build a table in an EDD, just look at the DITA EDDs in your installation directory (subdir structured/xml/dita/...).

The tgroup element translates in your structure into <params>, tbody has no equivalent in your structure, thead can be set as optional, row translates to <param> and the entry element translates into <name>, <description> and <default>.

So the basic declarations in your EDD would look something like this:

Element (Table): params

  General Rule: tablebody

Element (Table Body): tablebody

  General Rule: row+

Element (Table Row): param

  General Rule: name, description, default

Element (Table Cell): name

  General Rule: <TEXT>

Element (Table Cell): description

  General Rule: <TEXT>

Element (Table Cell): default

  General Rule: <TEXT>

But from here on, you're on your own which formatting you are going to apply, if you introduce paragraphs, or what else you like to do.

Be sure to include the EDD into your structapps and use the correct r/w rules. As Russ already mentioned, the Structure Developers Guide is a good reference for further development.

Legend
April 3, 2013

Hi Stewart,

This should not be too difficult with some basic read/write rules, although you won't have any control over table formatting and column widths unless you put that metadata into the XML file beforehand. Are you familiar with structure applications and read/write rules? If not, you'll need to do some reading up in the Structure Developers Guide and learn about how to declare elements as specific types; ie, the <params> element as a table, etc. From start to finish, it is considerably more than I could address within a simple forum post.

Russ