in reply to Using environment variables in xi:include
When i try to invoke the xinclude parser, it is not able to access the file even though i initialize the variable with a pre-determined path.
You say that as if the XML parser has a concept of variables, and that it interpolates those variables into file names to include, and that it uses a perl-ish syntax for doing so. I doubt any of those are true.
To add that feature, you'd have to modify or hook into the parser's include mechanism to add
my %safe = map { $_ => 1 } qw( HOME_ROOT ); s/\$(\w+)/ $safe{$1} && exists($ENV{$1}) ? $ENV{$1} : "\$$1" /eg
Update: I took a look at XML::Filter::XInclude. My suspicions were correct. But it would be easy to subclass XML::Filter::XInclude and override _include_text_document and _include_xml_document to add the functionality you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using environment variables in xi:include
by joeperl (Acolyte) on Feb 19, 2010 at 14:18 UTC |