Customising XML reports – Part 2

Introduction

In Part 1 of this series, we looked at the background behind the XML reports in 12d Model and how to create a new report template. Now, in this post, we will make some minor changes to the way the report template and look at how they affect the output.

If you haven’t yet read Part 1, I recommend you do so now. This post assumes that you have already followed the steps in Part 1 and we have:

  • Copied the default “html tables” report template/XSLT (super_alignment_report_htm.xslt) into the User directory and renamed it to super_alignment_report_htm_advanced12d.xslt
  • Defined a new report template called “html Advanced12d” inside 12d Model via the Report→Utilities→Report templates panel

Minor modifications – Headings and text

Now that we have our custom XSLT and have added our custom report template to 12d’s list of template, we can look at actually modifying our report. I’ll first show you how to make some basic modifications- changing headers or text- before we look at more advanced ways of modifying our report.

Open up the XSLT- super_alignment_report_htm_advanced12d.xslt – in your text editor. If you need to, enable XML syntax highlighting.

A few things to mention about the XSLT file and XML in general:

  • XSLT is itself written in XML.
  • The XSLT consists of nodes, which can be different types- element, text, attribute, comments, etc.
  • The XSLT document is tree-like and can have nested branches.
  • An element is an item between angle brackets- < and > and each element must have a closing tag. e.g. <example></example> or <example/>
  • Comments are contained within <!– and –> . e.g. <!-- This is a comment -->
  • XSLT is a set of templates that match different parts of an XML document and produce output (or not) based on that data.
To make matters even more confusing, the format of HTML itself being produced by our XSLT actually appears very similar to XML. HTML is not XML, but it shares a lot of similar formatting, such as elements with opening and closing tags, e.g. <h1></h1> and comments ( <!-- This is a comment --> ). HTML is a lot more strict and regulated about the tags allowed, what they mean and how they are displayed. For more information on HTML, see Wikipedia or W3Schools.

With that brief introduction to XML and XSLT, let’s look at a typical report produced by the default “html tables” report type from the Super Alignment Report panel.

To make some basic changes to, say, for example, the headings, we need to find where in the XSLT those headings are output. The easiest way to do this is by searching in your text editor for one of the headings. In my example, I find the first set of headings for the Horizontal IPs section starting at line 153. For basic modifications, we can edit and replace the text between elements, so long as we don’t modify the elements themselves or the structure of the elements.

Once you’ve made those basic changes, you can generate a report from 12d Model, using your custom report type and check the resulting output.

SA Report - Custom HTML report - Horizontal IPs with uppercase headings

SA Report – Custom HTML report – Horizontal IPs with uppercase headings

Next, we’ll look at some extra formatting changes we can make.


2 thoughts on “Customising XML reports – Part 2

  1. i am trying to get 12d to output a report that only produces the 3D length of a super string and the start and end point information as coordinates without including any information for the verticies in between. any guidance on how i can achieve this would be very much appreciated

    • Trent, I think the best you could do without a custom macro would be to use the Attribute Manipulator to add the Length 3d as a vertex attribute. Then you could use the XYZ General output to report the XYZ and attribute value. Unfortunately, I can’t think of any way of not reporting on the intermediate points.

      You could also potentially write an XSLT to convert a 12dXML file to the required output. That would probably take longer to write than a macro!

      Depending on what you’re after, it would be a very quick and easy macro. Let me know if you’re heading down that path. I could probably whip something up in an hour or two.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.