Jose Abilio Oliveira Matos a écrit :

>   I should also look to the configuration schemes used by sgmltools and
> db2xxx, since they use the entities that are usually packaged in a different
> way.
>
>   I think I should go this road: if the user has installed sgmltools or
> db2xxx then lyx should find the correct configuration. If not, then it means
> it is capable to fiddle with the configuration...

Jose, I've looked at the configuration file (lib/configure) and I hardly understand how
it works (even if it seems to be a list of tests about existing programs + the
lyxrc.defaults writing according to what was found...), especially the interaction with
other configuration parts (reLyX for instance).

So, I've started a dedicated script for the db2lyx configuration, that is destinated to
be integrated into the main configuration file. The purpose of this script is to start
a discussion about the configuration aspect. The script works only with db2lyx-0.1.2.

It works with the following hypothesis:

* db2lyx is located at the same level than reLyX, let's say:
/usr/local/share/lyx-1.1.6/db2lyx/.
* the configuration script is under /usr/local/share/lyx-1.1.6/db2lyx/.
* the jar files paths of the available XSLTs are listed in the CLASSPATH environment
variable.
* the two paths hardcoded in the config file (base_dbcommon, base_mmlents) must be
valid.

Jose, what do you think of it?

Here are some pending questions:

* Should the db2lyx directory be under the LyX lib directory (the hypothesis of the
script), or should it be located somewhere else?
* Which mechanisms do you suggest to get the two paths (removing the hardcoded values)?
About this, I don't see how catalogs could give a (simple) solution...
* By itself, the package needn't to know the XML DocBook DTD path, but anyway it is
needed when exporting to XML. How do you get this information?

That's all... for the moment ;-)

> --
> José

BG

p. s.: db2lyx-0.1.2 is available at my page, but if you prefer a diff file (it seems to
be the way) tell me how to do it since I don't know the command (shame on me).

#!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if $running_under_some_shell; use File::Basename; use Cwd; BEGIN { %xslt_command = ( 'xt.jar' => 'com.jclark.xsl.sax.Driver $i $sheet > $o' , 'xalan.jar' => 'org.apache.xalan.xslt.Process -in $i -xsl $sheet -out $o' , ); } # # Changes the command template with the specified XML file, stylesheet, # and output. # sub set_xslt { local($command) = $_[0]; local($xml) = $_[1]; local($xsl) = $_[2]; local($out) = $_[3]; $command =~ s/\$i/$xml/; $command =~ s/\$o/$out/; $command =~ s/\$sheet/$xsl/; return $command; } # # Run the XSLT, for a specified XML file, stylesheet, etc. # sub run_xslt { local($command) = $_[0]; local($xml) = $_[1]; local($xsl) = $_[2]; local($out) = $_[3]; $command = set_xslt($command, $xml, $xsl, $out); print "$command\n"; system($command); } # # Updates the lyxrc file with the XML information. # sub add_xml_info { local($lyxrc) = $_[0]; local($xml_to_lyx_cmd) = $_[1]; open(IN, "<$lyxrc"); open(OUT, ">$lyxrc.new"); $done_format = 0; $done_conv = 0; while () { # Copy of the original file, unless it is the previous XML config. if (not(/\\Format xml/ || /\\converter xml/)) { print OUT ; } if (/\\Format docbook/ && $done_format == 0) { # Add the XML format print OUT "\\Format xml xml XML \"\"\n"; $done_format++; } if (/\\converter docbook/ && $done_conv == 0) { # Add the XML->LyX converter print OUT "\\converter xml lyx \"$xml_to_lyx_cmd\" \"\"\n"; $done_conv++; } } close(IN); close(OUT); system("mv $lyxrc.new $lyxrc"); } # To fix: how to pass these parameters? # $base_dbcommon = "/usr/local/share/xml/docbook/common"; # $base_mmlents = "/usr/local/share/xml/mathml/mmlents"; $base_dbcommon = "/home/ben/nwalsh/docbook/common"; $base_mmlents = "/home/ben/nwalsh/docbook/mmlents"; # Get the DB2LyX path $base_db2lyx = dirname($0); # We want an absolute path if (not($base_db2lyx =~ /^\//)) { $pwd = getcwd(); $base_db2lyx = "$pwd/$base_db2lyx"; } # # We look for the available XSLT, hoping that they are declared in the # java CLASSPATH. # $classpath = $ENV{'CLASSPATH'}; @jar = split(':', $classpath); foreach $file (@jar) { $f = basename($file); if (exists $xslt_command{$f}) { @xslt = (@xslt, $f); } } if ($#xslt > 0) { print "Installed XSLT: (@xslt)\n"; # We take the first available XSLT $xslt_cmd = "java $xslt_command{$xslt[0]}"; # Now, configure the package $params = "base-dbcommon=$base_dbcommon base-mmlents=$base_mmlents"; run_xslt($xslt_cmd, "$base_db2lyx/template/xslpath.xml", "$base_db2lyx/template/xslpath.xsl $params", "$base_db2lyx/xslpath.ent"); # Set the converter command $xml_to_lyx_cmd = set_xslt($xslt_cmd, "\$\$i", "$base_db2lyx/docbook.xsl", "\$\$o"); } else { print "No XSLT installed\n"; $xml_to_lyx_cmd = 'none'; } # Patch the lyxrc.default file add_xml_info("$base_db2lyx/../lyxrc.defaults", $xml_to_lyx_cmd);

Reply via email to