Customising XML reports – Part 1

In V10, 12d Model introduced the use of XML reports for a few of the reporting options in the software. Prior to this any customisations or modifications to the formatting of reports by clients required either manual editing in a text editor or in 12d- e.g. deleting columns, changing headings, etc, or a custom 12d app to be written. The move to XML reports allows clients and 12d to more easily modify the format of these reports or add custom reports. Here I will give an introduction to which reports in 12d Model use the new XML format and explain the process for customising XML reports.

XML, XSLT, XPath – What does it all mean?

XML is a markup language defined by the W3C and designed to markup documents so that they are easy to read by both humans and machines.

XSLT is a related technology that is used to convert (transform) a document into another format- XML, HTML for web pages, plain text or even PDF. The source document is typically XML, though it does not need to be. XSLT files themselves are written in XML and use XPath to query parts of the source document being transformed. The XSLT specification can also be found at W3C. XSLTs are also sometimes called XML stylesheets.

XPath is another related technology that is used to define the syntax for the structure of an XML document and provides methods for navigating that structure (a query language). It is used heavily in XSLT to refer to parts of the XML and is also defined by the W3C. An XML document is effectively represented as a tree of many elements or nodes and the XPath is used to select specific parts of the tree for processing.

All three technologies are related and all will be used in this post. I will not be giving a detailed background or tutorial into either of these technologies, but should you wish to know more about them, there are plenty of resources online to help you.

A few I recommend:

W3Schools:

ZVON:

What you will need

Although there are a number of software tools available that can create custom XSLTs (e.g. from Altova, Stylus Studio, oXygen XML), most of these cost money so I will be showing a way to create/modify reports using a basic text editor. If you are making substantial modifications or creating an XSLT from scratch, it may be worth using one of the paid software options out there. For these posts, we’ll simply be making changes to existing XSLTs, so a text editor should be enough.

However, not all text editors are created equal. I recommend a text editor that supports syntax highlighting (specifically for XML files) and code-folding. Both of these features will make working with XML and XSLT files much easier. I also recommend a text editor that has full support for Unicode. I personally use Notepad++, which is free and supports all of the mentioned functionality and much more. Download it at http://notepad-plus-plus.org/. Only a masochist would use the default Windows Notepad for this.

You’ll also need a copy of 12d Model (duh) for testing. I don’t know if this will work on the Practise Version, but I’m guessing if you’re reading this you already have a full version of 12d Model, V10 or above. If you don’t have a copy of 12d Model, get in contact with your local sales person.

Ok, now we’ve got a little bit of background and the tools to help us, let’s continue.


2 thoughts on “Customising XML reports – Part 1

  1. This post has been very helpful. Any chance of a part 3/4?
    Is not every report customisable? ie. stockpile report doesn’t have an option to choose different report types, and unable to find xslt, does this mean there is no way to customise this report?

    • Thanks, Nelson. Glad you found it useful. Unfortunately, I’ve been very busy/lazy, so haven’t gotten around to writing follow-up posts. I’m happy to answer any specific questions you might have, though.

      Not every report is customisable in this way. Each option needs to be re-written to output to XML. AS you know, there are a lot of options inside 12d Model! Then, not only does 12d have to re-write the option, they have to write a stylesheet (XSLT) to go with it, test it and ship it with the next install. All of that adds up to a lot of work for 12d in amongst all the other bug fixes and new stuff they work on. They’re a small company- nothing like the size of an Autodesk or Bentley- so simply don’t have the programming resources available to do everything at once.

      However, they do listen to user requests, so if you ask for something they might do it. Unfortunately, that means that for now you can’t really customise the stockpile report. You could do some post-processing in a text editor, batch file, 12d Model macro or something like that. Otherwise, someone could write a macro that replicates the functionality but with XML outputs.

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.