Tim,

Named buffers represent convenient and easy to use way how to handle multiple
xml or xslt files. Let me to give you a simple example, which should make it
clear.

use strict;
use XML::Sablotron qw (:all);

undef $/;

# Open and read (or generate) as much files as you wish.

open(FH,"<xslt_template_01.xsl");
my $template1 = <FH>;
close FH;

open(FH,"<xslt_template_02.xsl");
my $template2 = <FH>;
close FH;

open(FH,"<xml_data_01.xml");
my $data1 = <FH>;
close FH;

open(FH,"<xml_data_02.xml");
my $data2 = <FH>;
close FH;
...

# Create a new Sablot object and feed it with data.

my $sab = new XML::Sablotron();
$sab->RunProcessor("$template1", "$data1", 'arg:/result',
                   [], ['templ2', $template2, 'data2', $data2, ...]);

# You provide this method with the following parameters:
# template, data, name of result buffer, [parameters (none in this case)],
# [additional named buffers (2 in this case)]

# Run the transformation. Other documents can be referenced this way from
# xslt_template_01.xsl: select="document('arg:/data2')/root/child" or
# <xsl:include href="arg:/templ2"/>, for example.

my $result = $sab->GetResultArg('result');

-----
I hope this help.
Petr


Tim Watts wrote:

> I don't know much about this, although I just looked at the Sablotron
> documentation and found ...
>
> 6.4  Named buffers
> Sablotron introduces an URI scheme 'arg:' which enables one to use strings
> in named memory buffers. The buffer names can have a tree-like structure so
> that a relative reference from a document in a buffer can be resolved as
> pointing to another buffer.
> For instance, if we invoke Sablotron specifying that a buffer named /mybuf/1
> contains the string "&lt;a>contents&lt;/a>", then the expression
> document('arg:/mybuf/1')/a
> has string-value "contents". If the document in arg:/mybuf/1 contained a
> relative URI reference "../theirbuf/2" then this would be resolved as
> pointing to "arg:/theirbuf/2".
>
> Is there any other documentation that I could be pointed to.

--
Petr Cimprich
Ginger Alliance
www.gingerall.com


Reply via email to