Reputation: 1164
I am a trying to pass the value of a shell variable to an xsltproc instance. The file text.xsl contains:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="file:/Users/robertramey/WorkingProjects/modular-boost/tools/boostbook/xsl/docbook.xsl"/>
<xsl:import href="file:$BOOST_ROOT/tools/boostbook/xsl/docbook.xsl"/>
</xsl:stylesheet>
#functions as expected
$echo $BOOST_ROOT
/Users/robertramey/WorkingProjects/modular-boost
#passes on first import as expected.
#but fails on the second as expect as BOOST_ROOT is not set
$xsltproc --maxdepth 6000 --xinclude --nonet test.xsl
warning: failed to load external entity
"file:$BOOST_ROOT/tools/boostbook/xsl/docbook.xsl"
#passes on the first import as expected
#fails on the second - NOT expected
$xsltproc --maxdepth 6000 --stringparam BOOST_ROOT "/Users/robertramey/WorkingProjects/modular-boost" --xinclude --nonet test.xsl
warning: failed to load external entity
"file:$BOOST_ROOT/tools/boostbook/xsl/docbook.xsl"
compilation error: file test.xsl line 4 element import
xsl:import : unable to load file:$BOOST_ROOT/tools/boostbook/xsl/docbook.xsl
Why is this? What do I have to do to make this work?
$cat bb2db.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="https://www.boost.org/tools/boostbook/xsl/docbook.xsl"/> </xsl:stylesheet>
which works. But it relies on a global URL to find the file to import. This makes my script dependent on having an internet connection which I'd prefer to avoid. I'd like to refer to a local directory:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href=file:"$BOOST_ROOT/tools/boostbook/xsl/docbook.xsl"/> </xsl:stylesheet>
Since the shell variable holds the base path of the desired xml stylysheet I want to import.
Upvotes: 0
Views: 83
Reputation: 1164
Looks like I may have it!!!!: xsltproc --maxdepth 6000 --path "$BOOST_ROOT/tools/boostbook/xsl" --xinclude --nonet test.xsl
test.xsl contains:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="xsl/docbook.xsl"/> </xsl:stylesheet>
Upvotes: 0