PLEASE NOTE: ALL existing forms of PBS Schedule data currently distributed to vendors will cease soon. The new PBS embargo API will be the only source of embargo data available. Subscribe to the PBS Developer email list to receive notifications of PBS Developer News.
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.
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.
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.
This method takes advantage of the XML and XSLT capabilities of Microsoft Internet Explorer. You will need:
The PBS XML Schedule, which may be emailed to you or downloaded from the website
The format-dispensing-incentive.xsl XSL stylesheet
Perform the following steps:
Make sure all of the files mentioned above are in the same folder
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
Make a copy of the PBS XML Schedule and name it PBS-XML.xml
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).
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:
A command-line XSLT engine:
Follow the application's instructions to install on your computer.
To use MSXML on MS Windows download the MSXSL.exe application
To use Saxon download from SourceForge
To use libxslt, first check if it is already installed on your computer (this is very likely if you are using Mac OS X or Linux). Otherwise download from xmlsoft.org
The PBS XML Schedule, which may be emailed to you or downloaded from the website
The extract-dispensing-incentive.xsl XSL stylesheet
Perform the following steps:
Make sure all of the files mentioned above are in the same folder
Open a command-line interface:
On Windows, start a Command Prompt
On Linux (or Unix), start an xterm
On Mac OS X, start Terminal
Change directory to where the files are kept.
Windows:
cd \path\to\XML\filesLinux/Unix/Mac OS X:
cd /path/to/XML/filesInvoke the XSL engine:
MSXSL:
msxsl "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl -o disp-incentive.txtSaxon:
saxon -o disp-incentive.txt "G2B YYYYMM01.xml" extract-dispensing-incentive.xsllibxslt:
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.
The XSL stylesheet extract-dispensing-incentive.xsl accepts the following parameters:
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.
The URL for the previous schedule. This parameter is required for update mode, but is otherwise ignored.
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:
Make sure all of the files mentioned above are in the same folder
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=autoSaxon:
saxon -o update.txt "G2B YYYYMM01.xml" extract-dispensing-incentive.xsl mode=autolibxslt:
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.
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:
The Tkxsltproc application. Download from Sourceforge .
The PBS XML Schedule, which may be emailed to you or downloaded from the website
The extract-dispensing-incentive.xsl XSL stylesheet
Perform the following steps:
Make sure all of the files mentioned above are in the same folder
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.
Select the XSL stylesheet to use. Locate the extract-dispensing-incentive.xsl file.
Select the XML source document. Locate the PBS XML document.
Select where to save the result. In the dialog box, type "disp-incentive.txt".
Invoke the transformation - click on the "Transform" button. You will see the progress of the processing in the bottom feedback window.
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.
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:
Make sure all of the files mentioned above are in the same folder
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.
Invoke the transformation - click on the "Transform" button. You will see the progress of the processing in the bottom feedback window.
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.
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:
Microsoft's XML Notepad 2007.
The PBS XML Schedule, which may be emailed to you or downloaded from the website
The extract-dispensing-incentive.xsl XSL stylesheet
Perform the following steps:
Install XML Notepad 2007 on your Windows computer.
Make sure all of the files mentioned above are in the same folder
Open XML Notepad 2007
Open the PBS XML document, either by clicking on the "open document" icon or by dragging the file on to the application.
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.
Open the XSL stylesheet, extract-disensing-incentive.xsl, and click on the "Transform" button.
The "XSL Output" pane will then display the result.
Right-click in the "XSL Output" pane and select "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.
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:
Download the Packaged Press application to your computer.
Download the PBS XML Schema distribution from data.pbs.gov.au.
Download the PBS XML document from www.pbs.gov.au.
Launch Packaged Press Desktop Edition. A window will open that appears like this:
Open the PBS XML pipeline document by using the File->Open menu. Locate the xpl/pbs.xpl file.
When the pipeline has been loaded, it will appear like this:
Press the "power on" button:
The application will present a dialog box. Navigate to where the PBS XML document is located, select it and choose OK.
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.
We are always looking for ways to improve our website
© Commonwealth of Australia | Department of Health and Aged Care