This example demonstrates automatic conversion of data from XML to the SXML format. Additionally, it's a way to convert an XML file to the SXML format.
Example 11. XML to SXML stylesheet
<x:stylesheet xmlns:x = "http://www.w3.org/1999/XSL/Transform" xmlns:s = "http://xsieve.sourceforge.net" extension-element-prefixes="s" version = "1.0"> <!-- --> <s:init> (use-modules (ice-9 pretty-print)) </s:init> <x:template match="/"> <s:scheme> (pretty-print (x:current)) </s:scheme> </x:template> </x:stylesheet>
The pretty-print
function puts the pretty printed SXML result into the standard output. SXML is the only point of interest in this example, so the result of the XML transformation can be ignored. Thereby, one can execute the stylesheet the following way.
$ xsieve -o /dev/null hello2.xsl XML-file
Let XML-file
be the following file.
Example 12. XML file for the XML to SXML example
<?xml version="1.0"?> <article id="hw"> <title>Hello</title> <para>Hello, <object>World</object>!</para> </article>
The output of the stylesheet for the XML file is the following.