LNS Home
XSLT Tools 2.1
XSLT Tools Home
Products
Affrus 1.0
x FaceSpan 4.3
Script Debugger 4.0
Freeware
XML Tools
XSLT Tools
List & Record Tools
Property List Tools
JavaScript OSA
Sample XML-RPC Server
OSAXen Fixer
CodeWarrior Tools
Site Contents
Home Page
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us
Universal

XSLT Tools 2.1

Download Version 2.1 (2.7MB)

The XSLT Tools Scripting Addition allows AppleScript to apply XSLT transformations to XML data and to use XPath expressions to extract information from XML data. XSLT Tools also allows you to extend the XSLT processor using AppleScript functions.

If you would like to support the ongoing development of XSLT Tools, please consider a US$20 donation.

NOTE: If you are looking for a tool to simply parse XML data, please go to the XML Tools web page.

Credits/Legal

The XSLT Tools Scripting Addition uses the Apache Software Foundation's Xerces-C 2.3.0 XML parser and Xalan-C 1.6 XSLT processor. The Apache software license is available here. The XSLT Tools Scripting Addition also uses IBM's International Components for Unicode (ICU) 2.6. The ICU license is available here.

THIS SOFTWARE IS PROVIDED AS-IS, WITHOUT WARRANTY OF ANY KIND. THE AUTHOR DISCLAIMS ANY DAMAGES RESULTING FROM THE USE OR MISUSE OF THIS SOFTWARE.

THIS SOFTWARE IS COPYRIGHT © 1998-2006 LATE NIGHT SOFTWARE LTD. & MARK ALLDRITT. YOU MAY USE AND/OR DISTRIBUTE THE SOFTWARE WITHOUT RESTRICTION. IF YOU BUNDLE THE SOFTWARE WITH ANY COMMERCIAL OFFERING, YOU MUST DISPLAY THIS COPYRIGHT NOTICE IN THE SOFTWARE'S DOCUMENTATION AND/OR ABOUT BOX. YOU MUST ALSO COMPLY WITH ANY DISTRIBUTION RESTRICTIONS SET OUT IN THE APACHE SOFTWARE FOUNDATION AND THE ICU LICENSES THAT MAY APPLY TO YOU.

System Requirements

The XSLT Tools scripting addition requires Mac OS X 10.4 or later.

Installation Instructions

Please follow these steps to install the XSLT Tools scripting addition on Mac OS X systems:

  1. Create a folder named ScriptingAdditions in your user account's Library folder (known as ~/Library) if one does not already exist.
  2. Copy the XSLT Tools.osax into the ~/Library/ScriptingAdditions folder.

Getting Started

The XSLT Tools package contains a series of simple example scripts that illustrate how to perform XSLT transformations and use XPath expressions to extract information from XML data. These examples show all the ways XSLT Tools can be used to process XML data.

To view the XSLT Tools dictionary which lists all the commands and their options, just drop the XSLT Tools.osax file onto your favorite script editor.

NOTE: the example scripts provided with XSLT Tools use the AppleScript path to me command. The path to me command does no operate correctly when scripts are executed from within Apple's Script Editor. The examples were developed using our Script Debugger product which does not have this limitation.

Here is a brief example showing how XSL transformations can be applied:

set theXML to "<?xml version=\"1.0\"?>
<doc>Hello</doc>"

set theStylesheet to "<?xml version=\"1.0\"?>
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">
  <xsl:template match=\"doc\">
    <out><xsl:value-of select=\".\"/></out>
  </xsl:template>
</xsl:stylesheet>"

transform XML theXML using theStylesheet
--   Result:
--
   <?xml version="1.0" encoding="UTF-8"?>
--
   <out>Hello</out>

This example transforms using XML and a Stylesheet stored in files:

tell application "Finder" to set myFolder to container of (path to me) as string

set outFile to transform XML file (myFolder & "foo.xml") ¬
   
using file (myFolder & "foo.xsl") ¬
   
saving as file (myFolder & "output.xml")
--
   Result:
--
   alias "Macintosh HD:Users:mall:Desktop:output.xml"

This example illustrates how to use the extract XML command to pick data out of a larger XML document:

set theXML to "<?xml version=\"1.0\"?>
<doc>
  <name first=\"David\" last=\"Marston\"/>
  <name first=\"David\" last=\"Bertoni\"/>
  <name first=\"Donald\" last=\"Leslie\"/>
  <name first=\"Emily\" last=\"Farmer\"/>
  <name first=\"Myriam\" last=\"Midy\"/>
  <name first=\"Paul\" last=\"Dick\"/>
  <name first=\"Scott\" last=\"Boag\"/>
  <name first=\"Shane\" last=\"Curcuru\"/>
  <name first=\"Joseph\" last=\"Kesselman\"/>
  <name first=\"Stephen\" last=\"Auriemma\"/>
</doc>"

--
   Extract an element from the larger XML file, creating a new XML stream that can be further processed (e.g. parsed)
--
--
      get the 3rd name element
--
set r1 to extract from XML theXML matching "doc/name[3]"
--
   Result:
--
   <output>
--
   <name last="Leslie" first="Donald"/>
--
   </output>

--
   Use an XPath expression to get specific values from an XML stream
--
--
      get the first and last attribute value of the 5th name element
--
set r2 to extract from XML theXML matching "doc/name[5]" expression {"@first", "@last"}
--
   Result:
--
   {
--
      {"Myriam"},
--
      {"Midy"}
--   }

Release Notes

2.1 June 7, 2006

  • Native Intel Macintosh support (distributed as a Universal binary).
  • Updated to Xerces-C 2.7 and Xalan-C 1.10.
  • New sdef based dictionary includes example code.
  • The extract from XML command now accepts multiple matching strings allowing for more complex XPath matching logic.
  • Addressed a problem when long file names are used in HFS file specifications.

2.0.1 April 15, 2004

  • The base folder parameter is now fully functional
  • The transfor XML command now correctly returns UTF-8 and UTF-16 strings when the saving as parameter is not specified
  • Added the including output element parameter ot the extract XML command to allow the supression of the enclosing <output>...</output> element when returning extracted XML data.

2.0 February 2, 2004

  • Updated Xerces XML parser to version 2.3.0
  • Updated Xalan XSLT processor to version 1.6
  • Integrated IBM's ICU 2.6
  • Implemented the XSL format-number and sorting functions missing in XSLT Tools 1.0
  • Added support for typeUTF8Text strings in AppleEvents
  • Parser upgrades have corrected problems processing XML data with explicit encodings
  • Parser upgrades have corrected problems with DOCTYPE declarations in style sheets
  • Revised the XSLT Tester AppleScript Studio example code
  • Switched from dual-fork CFM to bundled Mach-O packaging

Previous Releases

Version 1.0 | Version 2.0.1

 


Copyright © 1998-2007 Late Night Software Ltd. - All Rights Reserved.