Virtual Filesystems Are Virtual Office Documents
Listing 4. Exploring Our New XSLT Filesystem
$ bash
$ URL='xsltfs://context/file/tmp/example/
↪example.xml?stylesheet=example.xsl'
$ cd /tmp/example
$ ls
example-rev.xsl example.xml example.xsl
$ export LIBFERRIS_XSLTFS_SHEETS_URL=`pwd`
$ ferrisls -l $URL
0 root
$ ferrisls -l $URL/root
23 file3
3 file7
$ fcat $URL
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<root>
<context name="file3"
original-url="file:///tmp/example/example.xml/root/file3"
>filesystems inside XML?</context>
<context name="file7"
original-url="file:///tmp/example/example.xml/root/file7"
>foo</context>
</root>
$ fcat $URL/root/file3
filesystems inside XML?Things become more interesting when we provide a reverse stylesheet, as shown in Listing 5. In this case, we are mapping things back fairly plainly to where they originated in the input filesystem. The file7 content is placed back into the myattr XML attribute of the input document. Having an explicit reverse XSL transform provides you with the freedom to update only part of the original filesystem as you see fit. You also can use functions from the stylesheet to modify the data on its way back to the input filesystem.
Listing 5. example-rev.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
exclude-result-prefixes="ferris"
>
<xsl:output method="xml"/>
<xsl:template match="/">
<explicit-updates>
<xsl:apply-templates/>
</explicit-updates>
</xsl:template>
<xsl:template match="context[@name='file3']">
<context url="{@original-url}">
<xsl:value-of select="."/>
</context>
</xsl:template>
<xsl:template match="context[@name='file7']">
<attribute url="{@original-url}"
name="myattr"><xsl:value-of select="."/></attribute>
</xsl:template>
</xsl:stylesheet>Now that we have the forward and reverse XSL, we can happily modify the contents of the original example.xml file by interacting with the virtual file(s) in our xslfs://, as shown in Listing 6.
Listing 6. Changing the XML File through our New XSLT Filesystem
$ bash $ URL='xsltfs://context/file/tmp/example/ ↪example.xml?stylesheet=example.xsl& ↪reverse-stylesheet=example-rev.xsl' # Change the file3 element to have new content $ echo foo | ferris-redirect -T $URL/root/file3 $ cat example.xml <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <root> <file1 size="200"/> <file3>foo </file3> <file7 myattr="foo">Something blue</file7> </root> # Update everything based on a new XML file $ cat example-update1.xml <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <root> <context name="file3" original-url= ↪"file:///tmp/example/example.xml/root/file3" >A new file3 text node </context> <context name="file7" original-url= ↪"file:///tmp/example/example.xml/root/file7" >A new file7 myattr</context> </root> $ cat example-update1.xml | ferris-redirect -T $URL $ cat example.xml <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <root> <file1 size="200"/> <file3>A new file3 text node </file3> <file7 myattr="A new file7 myattr" >Something blue</file7> </root>
The example in Listing 6 shows two options for updating your filesystem: either by changing individual virtual files or by updating the virtual XML document (the translated filesystem) in a single shot. The first method of updating individual files maintains the filesystem metaphor in the xsltfs. The second method of updating via rewriting the main virtual XML document provides support for XML editing applications, such as OpenOffice.org where a document is read, manipulated and rewritten.
The URLs can be quite ugly and rather long. If you are editing such filesystems frequently, you might want to expose the xsltfs using FUSE. Editing virtual XML files with OpenOffice.org requires the use of FUSE to expose the virtual XML file through the Linux kernel.
If the format of the output of xsltfs:// is well known, such as an OpenOffice.org document, you can create file format automatically from the XSL files.
The ferris-filesystem-to-xsltfs-sheets client is used to set up stylesheets automatically. A plugin system is used to allow new file formats to be supported in the future. To see which plugins are available, use the --plugin=help command-line option.
You need to use a FUSE filesystem in order to read and write virtual office documents directly. This also can be set up automatically by the ferris-filesystem-to-xsltfs-sheets client using the --fuse=foo command-line option.
Some distributions require additional setup for a user in order to use FUSE mounts. On Fedora Core, you have to add the user to the fuse group, which can be done as shown in Listing 7.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- Designing Electronics with Linux
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Dynamic DNS—an Object Lesson in Problem Solving
- Linux Systems Administrator
- Using Salt Stack and Vagrant for Drupal Development
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Reply to comment | Linux Journal
1 hour 6 min ago - Dynamic DNS
1 hour 40 min ago - Reply to comment | Linux Journal
2 hours 39 min ago - Reply to comment | Linux Journal
3 hours 29 min ago - Not free anymore
7 hours 31 min ago - Great
11 hours 18 min ago - Reply to comment | Linux Journal
11 hours 26 min ago - Understanding the Linux Kernel
13 hours 41 min ago - General
16 hours 11 min ago - Kernel Problem
1 day 2 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Reverse stylesheet
Interesting, a great read Ben!
Using an explicit reverse makes updating a breeze! I like how you are able to modify the data on it's way back.
Just wondering, how do you find OpenOffice compared to other open source virtual office apps?
Dave