Anthony Gaudio wrote:
> It doesn't make a difference ... it seems that it will only work if
> the processor loads the actual file. I have it where it reads in the
> file as a string and then passes it to the processor. I don't pass
> the file URI to the processor. That is why the include directive
> hasn't been working for me. Is there any
>
Well, I see what's the problem finaly :)
Sablotron resolves relative paths of included stylesheets using the path
of the main stylesheet. If you pass the main stylesheet as
file:/something, Sablot resolves the paths of the included file as
file:/something_else, this paths exists and everything is fine. However,
if the main stylesheet is passed as arg:/something, Sablot tries to read
the included one as arg:/something_else, but this buffer does NOT exist
in memory and Sablot complains about it.
The only workaround is to specify the include with an absolute path to
prevent Sablot from the path resolution.
The attached files should work the way you want (you will probably want
to change /home/petr/work/test to something else).
Petr
--
Petr Cimprich
Ginger Alliance Ltd.
www.gingerall.com
#!/usr/bin/perl
use strict;
use XML::Sablotron qw (:all);
my $template = shift @ARGV;
my $data = shift @ARGV;
undef $/;
open(TEMPL,"<$template");
my $templ_string = <TEMPL>;
close TEMPL;
my $sab = new XML::Sablotron();
$sab->RunProcessor("arg:/templ", "$data", 'arg:/result',
[], ['templ',$templ_string]);
my $result = $sab->GetResultArg('result');
print "$result\n";
exit;
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:include href="file:/home/petr/work/test/included.xsl"/>
<xsl:template match="/data">
<xsl:call-template name="included-template"/>
</xsl:template>
</xsl:stylesheet>