PBS XSL User Guide

Page last updated: 4 November 2011

There are many different ways that the PBS XML may be used. This is a quick guide for using the XSL stylesheets supplied by the Department of Health and Ageing for extracting certain values from the XML document published every month.

Tools

To make use of the XML that is published every month, you will need some tools. At the very least, an XML parser is required to read the XML document. There are a wide variety of XML parsers available, for every popular programming language, both commercial and open source. Check with your software vendor or tool supplier for more information, or search Google .

XSLT (XSL Transformations) is a particular technology for processing XML documents. It is purpose-designed for reading an XML document and producing some kind of result, such as another XML document, a Web page or even just plain text. How the XML document is transformed into a result is controlled by an "XSL stylesheet".

The Department makes available a number of simple XSL stylesheets that are designed to work with the PBS XML. The Reference Guide provides detailed information in their use. Below are some simple ways to use the stylesheets.

An "XSLT Engine" is a software library or application that reads an XML document plus an XSL stylesheet and implements the rules given in the stylesheet. There are many XSLT engines available, both commercial and open source. Some are standalone and others may be used from a programming language. Check with your software vendor or tool supplier for more information, or check a list implementations.

Please note that the tools and applications used or mentioned below do not constitute an endorsement by the Department of Health and Ageing of those products. These are simple examples and are meant only to illustrate a few of the possible uses of the PBS XML. Many other methods, techniques and applications are possible. As is often said, Your Mileage May Vary.

Dispensing Incentive for Premium-Free Medicines

Two XSL stylesheets are available that extract the list of items/brands that attract the $1.50 Dispensing Incentive for Premium-free Medicines. One presents the list as a Web page and the other extracts the list as a text file.

This guide gives a number of methods for extracting the list of items that attract the $1.50 Dispensing Incentive. Please note that these are not the only methods for doing so - this guide is only informational. Also note that the same techniques may be applied to using the other XSL stylesheets provided by the Department.

Quick-and-Dirty Browser Method

This method takes advantage of the XML and XSLT capabilities of Microsoft Internet Explorer. You will need:

Perform the following steps:

  1. Make sure all of the files mentioned above are in the same folder

  2. Unzip the PBS XML Schedule, if you haven't already done so. You should now have an XML document, about 10MB in size, in the folder named G2B YYYYMM01.xml

  3. Make a copy of the PBS XML Schedule and name it PBS-XML.xml

  4. Open (double-click) the file extract-di.xml

At this point Internet Explorer will open a new window and display the list of items that attract the dispensing incentive. The Web page is formatted as a HTML table. Note that with this method there is no way to change the format of the display, or what information is displayed (that's why it is quick-and-dirty).

Command-line Method

To get the full benefit of the XSL stylesheet it is best to use an XSL engine. Some freely available XSL engines only have a command-line interface. To access these, you must start a Command Prompt (on Windows), a Terminal (on Mac OS X) or an xterm (on Linux).

Implementations of an XSL engine for use on the command-line include MSXML (Windows only), Saxon (requires Java) or libxslt (all platforms). There are other implementations, see above.

To use this method you will need:

Perform the following steps:

  1. Make sure all of the files mentioned above are in the same folder

  2. Open a command-line interface:

    • On Windows, start a Command Prompt

    • On Linux (or Unix), start an xterm

    • On Mac OS X, start Terminal

  3. Change directory to where the files are kept.

    Windows:

    cd \path\to\XML\files

    Linux/Unix/Mac OS X:

    cd /path/to/XML/files
  4. Invoke the XSL engine:

    • MSXSL:

      msxsl "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl -o disp-incentive.txt
    • Saxon:

      saxon -o disp-incentive.txt "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl
    • libxslt:

      xsltproc -o disp-incentive.txt extract-dispensing-incentive.xsl "G2B YYYYMM01.xml"

Once the XSL engine has finished, there will be a new file created in the directory that contains the list of items/brands that attract the $1.50 Dispensing Incentive. This file will be named disp-incentive.txt.

Using Parameters

The XSL stylesheet extract-dispensing-incentive.xsl accepts the following parameters:

  • mode

    What mode to operate in. Allowed values are: auto, full or update. full mode (the default) produces a full list of brands. update mode compares this schedule to the previous schedule and produces a list of brands that have been added or deleted. update mode requires the previous-schedule parameter to be specified. auto mode attempts to discover if the previous schedule is available; if it is then it switches to update mode, if not then full mode is used.

  • previous-schedule

    The URL for the previous schedule. This parameter is required for update mode, but is otherwise ignored.

  • display

    What information to display, and the order in which to display it. Allowed values are: drug-name, item-code, org-code and amount.

When using this XSL stylesheet to process the PBS XML a parameter may be specified. The following example produces an update list.

To use this method you will need:

  • All of the requirements for the "Command Line Method", from above

  • The PBS XML for the previous month's schedule. You may have kept this from the last month, or you may download it from the website 

Perform the following steps:

  1. Make sure all of the files mentioned above are in the same folder

  2. In the command line environment from the previous method, invoke the XSL engine:

    • MSXSL:

      msxsl "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl -o update.txt mode=auto
    • Saxon:

      saxon -o update.txt "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl mode=auto
    • libxslt:

      xsltproc -o update.txt --stringparam mode auto extract-dispensing-incentive.xsl "G2B YYYYMM01.xml"

Once the XSL engine has finished, there will be a new file created in the directory that contains the list of new items/brands that now attract the $1.50 Dispensing Incentive, along with a list of items/brands that no longer attract the incentive. This file will be named update.txt.

"Point-and-Click" Method

There are many applications available that allow you to invoke an XSL stylesheet, see the "Tools" section above. A very simple example is called Tkxsltproc. It is a GUI interface for the libxslt command-line application used in the method above.

To use this method you will need:

Perform the following steps:

  1. Make sure all of the files mentioned above are in the same folder

  2. On Windows, unzip the Tkxsltproc application. This will create a directory called tkxsltproc-1.7. In that directory, double-click tkxsltproc.exe.

    On Mac OS X, mount the disk image and copy the Tkxsltproc application to your Applications. Then double-click the Tkxsltproc application.

  3. Select the XSL stylesheet to use. Locate the extract-dispensing-incentive.xsl file.

Figure 1:  Select XSL Stylesheet

Select the XML source document. Locate the PBS XML document.

Figure 2:  Select Source XML Document

Select where to save the result. In the dialog box, type "disp-incentive.txt".

Figure 3:  Select Result

Invoke the transformation - click on the "Transform" button. You will see the progress of the processing in the bottom feedback window.

Figure 4:  Invoke Transformation

After the last step has been completed, there will be a new file created in the directory called disp-incentive.txt. This file contains the complete list of items/brands that attract the $1.50 Dispensing Incentive for that month.

"Point-and-Click" Method For Updates

The Tkxsltproc application is able to set parameters for the XSL stylesheets. What parameters may be set is detailed above.

As an example of using parameters, the following steps may be followed to produce an update list.

To use this method you will need:

  • All of the requirements for the "Point-and-Click Method", from above

  • The PBS XML for the previous month's schedule. You may have kept this from the last month, or you may download it from the website 

Perform the following steps:

  1. Make sure all of the files mentioned above are in the same folder

  2. Change the "mode" parameter to the value auto. This value must be in quotes.

    Select where to save the result. Type the file name update.txt in the dialog box.

Figure 5:  Select Result

Invoke the transformation - click on the "Transform" button. You will see the progress of the processing in the bottom feedback window.

Figure 6:  Invoke Transformation

After the last step has been completed, there will be a new file created in the directory called update.txt. This file contains the items/brands that now attract the incentive for that month, along with items/brands that no longer attract the incentive.

Using Microsoft XML Notepad 2007

Another "point-and-click"application is Microsoft's XML Notepad 2007. This application is able to open an XML document and an XSL stylesheet and perform the transformation.

To use this method you will need:

Perform the following steps:

  1. Install XML Notepad 2007 on your Windows computer.

  2. Make sure all of the files mentioned above are in the same folder

  3. Open XML Notepad 2007

  4. Open the PBS XML document, either by clicking on the "open document" icon or by dragging the file on to the application.

Figure 7:  Open XML

When the PBS XML document has finished opening, you may notice many warning messages displayed. These can be safely ignored.

Click on the "XSL Output" tab.

Figure 8:  XSL Output Tab

Open the XSL stylesheet, extract-disensing-incentive.xsl, and click on the "Transform" button.

Figure 9:  XSL Transform

The "XSL Output" pane will then display the result.

Figure 10:  Transformation Result

Right-click in the "XSL Output" pane and select "View Source".

Figure 11:  View Source

Notepad will then open with the text list displayed. You may then use the "File->Save As..." menu to save the list into a file.

Figure 12:  Notepad

XProc

XProc is a Web standard that controls the processing of XML documents. The PBS XML Schema distribution includes an XProc pipeline document that will create all of the text files from the PBS XML document using the XSL stylesheets provided in the distribution package.

Packaged Press Desktop Edition is an XProc pipeline controller. It reads the pipeline document and will perform the processing as specified in that document.

Please note that Packaged Press Desktop Edition is commercial software; it requires payment for ongoing use, though it may be downloaded at no charge for evaluation purposes. An alternative is Calabash , which is open source, command-line oriented and written in Java.

To use Packaged Press Desktop Edition you will need:

  • Packaged Press Desktop Edition.

  • The PBS XML Schedule, which may be emailed to you or downloaded from the website .

  • The PBS XML Schema distribution.

Perform the following steps:

  1. Download the Packaged Press application to your computer.

  2. Download the PBS XML Schema distribution from dev.pbs.gov.au.

  3. Download the PBS XML document from www.pbs.gov.au.

  4. Launch Packaged Press Desktop Edition. A window will open that appears like this:

Figure 13:  PPDE Application

Open the PBS XML pipeline document by using the File->Open menu. Locate the xpl/pbs.xpl file.

Figure 14:  Open Pipeline

When the pipeline has been loaded, it will appear like this:

Press the "power on" button:

Figure 15:  Power On

The application will present a dialog box. Navigate to where the PBS XML document is located, select it and choose OK.

Figure 16:  PBS XML Source

Packaged Press Desktop Edition will perform all of the necessary processing. You will see the "active" LEDs turn green as each XSL stylesheet is run. Once this has finished all of the text files will be automatically saved in the same folder as the PBS XML document.

Figure 17:  PBS XML Processing