Home » Ruby XPath and XSLT

Ruby XPath and XSLT

by Online Tutorials Library

Ruby XPath and XSLT


Ruby XPath

Ruby XPath is a language to find information in an XML file. It is an alternative to view XML file. It is used to navigate through elements and attributes in an XML document, treating that document as a logical ordered tree.

Ruby XPath is very useful to get relevant information and attributes from XML file. It takes tree-based parsing.

Example:

Output:

Ruby Xpath and xslt 1


Ruby XSLT

Ruby XSLT is a simple class based on libxml and libxslt. There are two XSLT parsers available for Ruby.

  • Ruby-Sablotron
  • XSLT4R

It is freely distributable according to the terms of GNU. This program is distributed without any warranty.

Ruby-Sablotron

It is mainly written for Linux operating system and is written by Masayoshi Takahashi.

It requires the following libraries:

  • Sablot
  • Iconv
  • Expat

XSLT4R

It is written by Michael Neumann. It uses a simple command line interface and it can be alternatively used within a third-party application to transform an XML document.

XSLT4R needs XMLScan to operate, which is included within the XSLT4R archieve. These modules need to be installed using standard Ruby installation method.

Syntax:

To use XSLT4R within an application, you need to include XSLT and input the parameters you need.


You may also like