Re: XML configuration

2001-08-25 Thread Jose Abilio Oliveira Matos

On Sun, Aug 05, 2001 at 03:57:21AM +0200, ben wrote:
 Jose Abilio Oliveira Matos a écrit :
 
  [...]
 
   I will try to see how to use it to detect where the NW's DocBook XSLs are for the
   db2lyx config (same as the java catalog classes use).
 
Good.
 
 I've written this small C program to resolve ids from catalogs. It shows that with
 xml2/xslt we don't need any java stuff, for the configuration and for the running 
time.

  Ok, I have installed libxslt, I'll try it. :-)
  
   And you, have you tried to use any XSLT on your machine?
 
My root partition was almost full so I didn't had any left space to
  install any new package.
 
 Glups... Reinstall is a nightmare for me.

  I have survived.
  Good to have you back... :-)
  
  
  Did you see the peek of interest that we see regarding docbook with lyx.
The stone is starting to roll. ;-)

  When you can please send me your list of bugs to reduce it. :-)
  
  --
  José
 
 BG

-- 
José



Re: XML configuration

2001-08-25 Thread ben

Jose Abilio Oliveira Matos a écrit :

  I've written this small C program to resolve ids from catalogs. It shows that with
  xml2/xslt we don't need any java stuff, for the configuration and for the running 
time.

   Ok, I have installed libxslt, I'll try it. :-)

This is the catresolve program added in db2lyx-0.1.3

And you, have you tried to use any XSLT on your machine?
  
 My root partition was almost full so I didn't had any left space to
   install any new package.
 
  Glups... Reinstall is a nightmare for me.

   I have survived.
   Good to have you back... :-)

:-)

   Did you see the peek of interest that we see regarding docbook with lyx.
 The stone is starting to roll. ;-)

Yes, that is really really good. Besides, if people from well known freeware projects 
(LDP)
start to use it, it's a good publicity. BTW, LyX is not listed in the DocBook tools 
page
http://www.oasis-open.org/docbook/tools/index.shtml. Maybe one should tell to the 
oasis org
that lyx exists...

   When you can please send me your list of bugs to reduce it. :-)

Here is the ball. I don't remember the current state of these files... The main list 
is in
problems.lyx, sgmltable.lyx is a workaround I sent once to have informaltable work,
textinfloat.lyx is something (I think) is missing. It should be merged with 
problems.lyx. I
hope it's clear enough.

BG

 dbproblems.tar.gz


Re: XML configuration

2001-08-25 Thread Jose Abilio Oliveira Matos

On Sun, Aug 05, 2001 at 03:57:21AM +0200, ben wrote:
> Jose Abilio Oliveira Matos a écrit :
> 
> > [...]
> >
> > > I will try to see how to use it to detect where the NW's DocBook XSLs are for the
> > > db2lyx config (same as the java catalog classes use).
> >
> >   Good.
> 
> I've written this small C program to resolve ids from catalogs. It shows that with
> xml2/xslt we don't need any java stuff, for the configuration and for the running 
>time.

  Ok, I have installed libxslt, I'll try it. :-)
  
> > > And you, have you tried to use any XSLT on your machine?
> >
> >   My root partition was almost full so I didn't had any left space to
> > install any new package.
> 
> Glups... Reinstall is a nightmare for me.

  I have survived.
  Good to have you back... :-)
  
  
  Did you see the peek of interest that we see regarding docbook with lyx.
The stone is starting to roll. ;-)

  When you can please send me your list of bugs to reduce it. :-)
  
> > --
> > José
> 
> BG

-- 
José



Re: XML configuration

2001-08-25 Thread ben

Jose Abilio Oliveira Matos a écrit :

> > I've written this small C program to resolve ids from catalogs. It shows that with
> > xml2/xslt we don't need any java stuff, for the configuration and for the running 
>time.
>
>   Ok, I have installed libxslt, I'll try it. :-)

This is the catresolve program added in db2lyx-0.1.3

> > > > And you, have you tried to use any XSLT on your machine?
> > >
> > >   My root partition was almost full so I didn't had any left space to
> > > install any new package.
> >
> > Glups... Reinstall is a nightmare for me.
>
>   I have survived.
>   Good to have you back... :-)

:-)

>   Did you see the peek of interest that we see regarding docbook with lyx.
> The stone is starting to roll. ;-)

Yes, that is really really good. Besides, if people from well known freeware projects 
(LDP)
start to use it, it's a good publicity. BTW, LyX is not listed in the DocBook tools 
page
http://www.oasis-open.org/docbook/tools/index.shtml. Maybe one should tell to the 
oasis org
that lyx exists...

>   When you can please send me your list of bugs to reduce it. :-)

Here is the ball. I don't remember the current state of these files... The main list 
is in
problems.lyx, sgmltable.lyx is a workaround I sent once to have informaltable work,
textinfloat.lyx is something (I think) is missing. It should be merged with 
problems.lyx. I
hope it's clear enough.

BG

 dbproblems.tar.gz


Re: XML configuration

2001-08-04 Thread ben

Jose Abilio Oliveira Matos a écrit :

 [...]

  I will try to see how to use it to detect where the NW's DocBook XSLs are for the
  db2lyx config (same as the java catalog classes use).

   Good.

I've written this small C program to resolve ids from catalogs. It shows that with
xml2/xslt we don't need any java stuff, for the configuration and for the running time.

  And you, have you tried to use any XSLT on your machine?

   It took me most of this week to update my computer (I had to reorder the
 partition table, and so), I will test it as soon as I come from vacations. I
 will also add db2lyx to CVS repository. There is some work to be done to
 integrate the configure part, but not too much hopefully...

   My root partition was almost full so I didn't had any left space to
 install any new package.

Glups... Reinstall is a nightmare for me.

 --
 José

BG

 catresolve.tar.gz


Re: XML configuration

2001-08-04 Thread ben

Jose Abilio Oliveira Matos a écrit :

> [...]
>
> > I will try to see how to use it to detect where the NW's DocBook XSLs are for the
> > db2lyx config (same as the java catalog classes use).
>
>   Good.

I've written this small C program to resolve ids from catalogs. It shows that with
xml2/xslt we don't need any java stuff, for the configuration and for the running time.

> > And you, have you tried to use any XSLT on your machine?
>
>   It took me most of this week to update my computer (I had to reorder the
> partition table, and so), I will test it as soon as I come from vacations. I
> will also add db2lyx to CVS repository. There is some work to be done to
> integrate the configure part, but not too much hopefully...
>
>   My root partition was almost full so I didn't had any left space to
> install any new package.

Glups... Reinstall is a nightmare for me.

> --
> José

BG

 catresolve.tar.gz


Re: XML configuration

2001-07-30 Thread Jose Abilio Oliveira Matos

On Fri, Jul 27, 2001 at 06:12:41PM +0200, ben wrote:
 Jose Abilio Oliveira Matos a écrit :
 
  [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to
 
  keep java well installed and configured I will switch right now. :-)
 
 I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
 db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
 works now. I don't know whether the patch is ok in any case, but I've submitted
 it to the [EMAIL PROTECTED]

  Did they answered you?

 You asked for it because you don't want to use java based tools, or have I missed
 something?

  For sure. ;-) I don't like all those funny looking configuration options
that I must pass to java for the others solutions to work. :-)

 BG

-- 
José



Re: XML configuration

2001-07-30 Thread ben

Jose Abilio Oliveira Matos a écrit :

 On Fri, Jul 27, 2001 at 06:12:41PM +0200, ben wrote:
  Jose Abilio Oliveira Matos a écrit :
 
   [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to
  
   keep java well installed and configured I will switch right now. :-)
 
  I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
  db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
  works now. I don't know whether the patch is ok in any case, but I've submitted
  it to the [EMAIL PROTECTED]

   Did they answered you?

No, not yet. But I think that the case in which the problem occurs is a bit special.

  You asked for it because you don't want to use java based tools, or have I missed
  something?

   For sure. ;-) I don't like all those funny looking configuration options
 that I must pass to java for the others solutions to work. :-)

I understand you :-). I find libxslt quite mature and consistent; it's fast and it
supports catalogs (xsltproc uses the SGML_CATALOG_FILES variable). Besides, such a C
library could be easily integrated as a LyX dependency (such as xform or any FE lib),
if it is seen something interesting (I can't decide for this :-). The other
interesting thing is that probably it is something provided in the default major
distributions (because it's a gnome project).
I will try to see how to use it to detect where the NW's DocBook XSLs are for the
db2lyx config (same as the java catalog classes use).
And you, have you tried to use any XSLT on your machine?

BG





Re: XML configuration

2001-07-30 Thread Jose Abilio Oliveira Matos

On Fri, Jul 27, 2001 at 06:12:41PM +0200, ben wrote:
> Jose Abilio Oliveira Matos a écrit :
> 
> > [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to
> >
> > keep java well installed and configured I will switch right now. :-)
> 
> I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
> db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
> works now. I don't know whether the patch is ok in any case, but I've submitted
> it to the [EMAIL PROTECTED]

  Did they answered you?

> You asked for it because you don't want to use java based tools, or have I missed
> something?

  For sure. ;-) I don't like all those funny looking configuration options
that I must pass to java for the others solutions to work. :-)

> BG

-- 
José



Re: XML configuration

2001-07-30 Thread ben

Jose Abilio Oliveira Matos a écrit :

> On Fri, Jul 27, 2001 at 06:12:41PM +0200, ben wrote:
> > Jose Abilio Oliveira Matos a écrit :
> >
> > > [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to
> > >
> > > keep java well installed and configured I will switch right now. :-)
> >
> > I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
> > db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
> > works now. I don't know whether the patch is ok in any case, but I've submitted
> > it to the [EMAIL PROTECTED]
>
>   Did they answered you?

No, not yet. But I think that the case in which the problem occurs is a bit special.

> > You asked for it because you don't want to use java based tools, or have I missed
> > something?
>
>   For sure. ;-) I don't like all those funny looking configuration options
> that I must pass to java for the others solutions to work. :-)

I understand you :-). I find libxslt quite mature and consistent; it's fast and it
supports catalogs (xsltproc uses the SGML_CATALOG_FILES variable). Besides, such a C
library could be easily integrated as a LyX dependency (such as xform or any FE lib),
if it is seen something interesting (I can't decide for this :-). The other
interesting thing is that probably it is something provided in the default major
distributions (because it's a gnome project).
I will try to see how to use it to detect where the NW's DocBook XSLs are for the
db2lyx config (same as the java catalog classes use).
And you, have you tried to use any XSLT on your machine?

BG





Re: XML configuration

2001-07-27 Thread ben

Jose Abilio Oliveira Matos a écrit :

 [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to

 keep java well installed and configured I will switch right now. :-)

I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
works now. I don't know whether the patch is ok in any case, but I've submitted
it to the [EMAIL PROTECTED]

You asked for it because you don't want to use java based tools, or have I missed
something?

BG





Re: XML configuration

2001-07-27 Thread ben

Jose Abilio Oliveira Matos a écrit :

> [...]  Did you try db2lyx with xlst from gnome. If that takes me the trouble to
>
> keep java well installed and configured I will switch right now. :-)

I've tried xsltproc (linked with libxslt-0.14.0 and libxml2-2.4.1) running on the
db2lyx stylesheets and... it plants. I've patched the libxslt code so that it
works now. I don't know whether the patch is ok in any case, but I've submitted
it to the [EMAIL PROTECTED]

You asked for it because you don't want to use java based tools, or have I missed
something?

BG





Re: XML configuration

2001-07-26 Thread ben

Jose Abilio Oliveira Matos a écrit :

 On Wed, Jul 25, 2001 at 07:13:04PM +0200, ben wrote:

 Ok, I'll have a look into it.
 
  Fine! I will soon release db2lyx that contains the script. Don't hesitate to
  make any remark.

   I have been looking to reLyX, that is the older brother of db2lyx, and it
 has a configure level that is very similar to what your script is doing.
   So I should have some suggestions soon.

Ok.

 [...]
  At least some code from the script will be removed when it is integrated
  enough with the current configure script, such that the code that patches
  the configure file!

   Yes. I agree here.
   Did you try db2lyx with xlst from gnome. If that takes me the trouble to
 keep java well installed and configured I will switch right now. :-)

No, I haven't tried it. I will try it ASAP.

   OT did you read the discussion of the future of typesetting in the
 docbook-apps mailling list. Funny to see Sebastian Rahtz opinion, basically
 he thinks that latex is a dead end, since the latex expertise is shrinking
 ever year. Also interesting was Michel Goossens reply.

Yes, quite interesting; I think that theorically S. Rahtz is right, since his
opinion is consistent with a full integrated XML/SGML solution, but practically
it seems not so easy to have a good PDF output (non-mature FO tools, difficult to
use and customize, no documentation available, etc.). That's why I appreciate the
M. Goossens reply that is more pragmatic, since he wants to have things working
now.

   My question is if we will ever see a latex 3? 

Good question!

 --
 José

BG




Re: XML configuration

2001-07-26 Thread ben

Jose Abilio Oliveira Matos a écrit :

> On Wed, Jul 25, 2001 at 07:13:04PM +0200, ben wrote:
>
> > >   Ok, I'll have a look into it.
> >
> > Fine! I will soon release db2lyx that contains the script. Don't hesitate to
> > make any remark.
>
>   I have been looking to reLyX, that is the older brother of db2lyx, and it
> has a configure level that is very similar to what your script is doing.
>   So I should have some suggestions soon.

Ok.

> [...]
> > At least some code from the script will be removed when it is integrated
> > enough with the current configure script, such that the code that patches
> > the configure file!
>
>   Yes. I agree here.
>   Did you try db2lyx with xlst from gnome. If that takes me the trouble to
> keep java well installed and configured I will switch right now. :-)

No, I haven't tried it. I will try it ASAP.

>   OT did you read the discussion of the future of typesetting in the
> docbook-apps mailling list. Funny to see Sebastian Rahtz opinion, basically
> he thinks that latex is a dead end, since the latex expertise is shrinking
> ever year. Also interesting was Michel Goossens reply.

Yes, quite interesting; I think that theorically S. Rahtz is right, since his
opinion is consistent with a full integrated XML/SGML solution, but practically
it seems not so easy to have a good PDF output (non-mature FO tools, difficult to
use and customize, no documentation available, etc.). That's why I appreciate the
M. Goossens reply that is more pragmatic, since he wants to have things working
now.

>   My question is if we will ever see a latex 3? 

Good question!

> --
> José

BG




Re: XML configuration

2001-07-25 Thread ben

Jose Abilio Oliveira Matos a écrit :

 On Thu, Jul 05, 2001 at 01:05:04AM +0200, ben wrote:
  Hi,
 
  Jose, here is the config_xml script updated, that detects the available
  and needed things by using the catalog mechanisms. The constraint is
  that it needs an extra java archive, the advantage is that this method
  is 100% xml :-). The script is expected to be in the db2lyx package. I
  attach the db2lyx doc updated, that explains how to use it

   Ok, I'll have a look into it.

Fine! I will soon release db2lyx that contains the script. Don't hesitate to
make any remark.

  It is still in perl, since I'm not sure it's so easy to do the same
  thing in bash. Besides, it can always be translated later (maybe in
  python ;-), when the configuration steps are fixed.

   I'll have another look.

At least some code from the script will be removed when it is integrated
enough with the current configure script, such that the code that patches
the configure file!

  Please give me your comments.
 
  BG

   PS: Jean-Marc have seen the licence of db2lyx, if you don't have any
 problem with it, I will include db2lyx in cvs.

Great! I encourage you to do so :-)

BG




Re: XML configuration

2001-07-25 Thread ben

Jose Abilio Oliveira Matos a écrit :

> On Thu, Jul 05, 2001 at 01:05:04AM +0200, ben wrote:
> > Hi,
> >
> > Jose, here is the config_xml script updated, that detects the available
> > and needed things by using the catalog mechanisms. The constraint is
> > that it needs an extra java archive, the advantage is that this method
> > is 100% xml :-). The script is expected to be in the db2lyx package. I
> > attach the db2lyx doc updated, that explains how to use it
>
>   Ok, I'll have a look into it.

Fine! I will soon release db2lyx that contains the script. Don't hesitate to
make any remark.

> > It is still in perl, since I'm not sure it's so easy to do the same
> > thing in bash. Besides, it can always be translated later (maybe in
> > python ;-), when the configuration steps are fixed.
>
>   I'll have another look.

At least some code from the script will be removed when it is integrated
enough with the current configure script, such that the code that patches
the configure file!

> > Please give me your comments.
> >
> > BG
>
>   PS: Jean-Marc have seen the licence of db2lyx, if you don't have any
> problem with it, I will include db2lyx in cvs.

Great! I encourage you to do so :-)

BG




Re: XML configuration

2001-07-24 Thread Jose Abilio Oliveira Matos

On Thu, Jul 05, 2001 at 01:05:04AM +0200, ben wrote:
 Hi,
 
 Jose, here is the config_xml script updated, that detects the available
 and needed things by using the catalog mechanisms. The constraint is
 that it needs an extra java archive, the advantage is that this method
 is 100% xml :-). The script is expected to be in the db2lyx package. I
 attach the db2lyx doc updated, that explains how to use it

  Ok, I'll have a look into it.

 It is still in perl, since I'm not sure it's so easy to do the same
 thing in bash. Besides, it can always be translated later (maybe in
 python ;-), when the configuration steps are fixed.

  I'll have another look.

 Please give me your comments.
 
 BG

  PS: Jean-Marc have seen the licence of db2lyx, if you don't have any
problem with it, I will include db2lyx in cvs.

-- 
José



Re: XML configuration

2001-07-24 Thread Jose Abilio Oliveira Matos

On Thu, Jul 05, 2001 at 01:05:04AM +0200, ben wrote:
> Hi,
> 
> Jose, here is the config_xml script updated, that detects the available
> and needed things by using the catalog mechanisms. The constraint is
> that it needs an extra java archive, the advantage is that this method
> is 100% xml :-). The script is expected to be in the db2lyx package. I
> attach the db2lyx doc updated, that explains how to use it

  Ok, I'll have a look into it.

> It is still in perl, since I'm not sure it's so easy to do the same
> thing in bash. Besides, it can always be translated later (maybe in
> python ;-), when the configuration steps are fixed.

  I'll have another look.

> Please give me your comments.
> 
> BG

  PS: Jean-Marc have seen the licence of db2lyx, if you don't have any
problem with it, I will include db2lyx in cvs.

-- 
José



XML configuration

2001-07-04 Thread ben

Hi,

Jose, here is the config_xml script updated, that detects the available
and needed things by using the catalog mechanisms. The constraint is
that it needs an extra java archive, the advantage is that this method
is 100% xml :-). The script is expected to be in the db2lyx package. I
attach the db2lyx doc updated, that explains how to use it

It is still in perl, since I'm not sure it's so easy to do the same
thing in bash. Besides, it can always be translated later (maybe in
python ;-), when the configuration steps are fixed.

Please give me your comments.

BG



#!/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' ,
);

%public_id = (
  'base-nwalsh'   = -//DB2LyX//Norman Walsh's XSL Stylesheet Directory//EN,
  'base-mmlents'  = -//DB2LyX//MathML ISO Entities Directory//EN,
  'dbxdtd-4.1.2'  = -//OASIS//DTD DocBook XML V4.1.2//EN,
  'dbxdtd-4.0'= -//OASIS//DTD DocBook XML V4.0//EN
);

@xmldtd_version = (
  4.1.2,
  4.0
);
}

#
# Resolves the file paths with the catalog jar, with the SGML_CATALOG_FILES
# variable that lists the catalogs available.
#
sub resolve
{
  local($pubid_name) = $_[0];

  if (not(exists($public_id{$pubid_name}))) {
return ;
  }

  $pubid = $public_id{$pubid_name};


  $cmd = java -Dxml.catalog.files=$user_catalog\$SGML_CATALOG_FILES;
  $cmd = $cmd catalog -s public \$pubid\ | grep Resolved;

  $path = `$cmd`;

  $path =~ s/Resolved: *//g;
  $path =~ s/file://g;
  $path =~ s/^null//g;
  chomp $path;

#  print path resolved = $path\n;
  return $path;
}

#
# 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];
  local($sgml_to_xml) = $_[2];

  open(IN, $lyxrc) || die Cannot open $lyxrc\n;
  open(OUT, $lyxrc.new) || die Cannot open $lyxrc.new\n;

  my $done_format = 0;
  my $done_conv = 0;
  my $done_stox = 0;

  # The 

  while (IN) {
# Copy of the original file, unless it is the previous XML config.
if (not(/\\Format xml/ || 
/\\converter xml/ ||
/\\converter docbook 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++;
}
if (/\\converter docbook/  $done_stox == 0) {
  # Add the SGML-XML converter
  print OUT \\converter docbook xml \$sgml_to_xml\ \\\n;
  $done_stox++;
}
  }

  close(IN);
  close(OUT);
  system(mv $lyxrc.new $lyxrc);
}

#
# Patch the configure script, so that reconfiguring will call this script too.
#
sub patch_configure
{
  local($xml_config) = $_[0];

  $ispatched = `grep $xml_config $base_db2lyx/../configure`;

  if ($ispatched eq '') {
system(cat eof  $base_db2lyx/../configure
 
# Specific XML config
if test -d \\\$srcdir/db2lyx ; then
  \\\$srcdir/db2lyx/$xml_config
fi
eof);
  }
}

# Get the DB2LyX path
$base_db2lyx = dirname($0);

# We want an absolute path
$pwd = getcwd();
if (not($base_db2lyx =~ /^\//)) {
  $base_db2lyx = $pwd/$base_db2lyx;
}

# Get the script name, and include it in the configure script
patch_configure(basename($0));

#
# We look for the available XSLT, hoping that they are declared in the
# java CLASSPATH. Besides, catalog.jar is expected too.
#
$classpath = $ENV{'CLASSPATH'};

print +checking for catalog.jar... ;
if (not($classpath =~ /catalog.jar/)) {
  print no\n;
  print *** Cannot configure: missing catalog.jar in CLASSPATH\n;
  exit 1;
} else {
  print yes\n;
}

# Let's try the user directory
$user_catalog=$pwd/db2lyx/catalog;
print +checking for $user_catalog... ;
if (-f $user_catalog) {
  print yes\n;
  $user_catalog .= :;
} else {
  print no\n;
  $user_catalog = ;
}

@jar = split(':', $classpath);

foreach $file (@jar) {
  $f = basename($file);
  if (exists $xslt_command{$f}) {
@xslt = (@xslt, $f);
  }
}

if ($#xslt  0) {
  print +checking for XSLT... (@xslt)\n;

  # We take the first available XSLT
  $xslt_cmd = java $xslt_command{$xslt[0]};

  # File path resolution
  $base_nwalsh = 

XML configuration

2001-07-04 Thread ben

Hi,

Jose, here is the config_xml script updated, that detects the available
and needed things by using the catalog mechanisms. The constraint is
that it needs an extra java archive, the advantage is that this method
is 100% xml :-). The script is expected to be in the db2lyx package. I
attach the db2lyx doc updated, that explains how to use it

It is still in perl, since I'm not sure it's so easy to do the same
thing in bash. Besides, it can always be translated later (maybe in
python ;-), when the configuration steps are fixed.

Please give me your comments.

BG



#!/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' ,
);

%public_id = (
  'base-nwalsh'   => "-//DB2LyX//Norman Walsh's XSL Stylesheet Directory//EN",
  'base-mmlents'  => "-//DB2LyX//MathML ISO Entities Directory//EN",
  'dbxdtd-4.1.2'  => "-//OASIS//DTD DocBook XML V4.1.2//EN",
  'dbxdtd-4.0'=> "-//OASIS//DTD DocBook XML V4.0//EN"
);

@xmldtd_version = (
  "4.1.2",
  "4.0"
);
}

#
# Resolves the file paths with the catalog jar, with the SGML_CATALOG_FILES
# variable that lists the catalogs available.
#
sub resolve
{
  local($pubid_name) = $_[0];

  if (not(exists($public_id{$pubid_name}))) {
return "";
  }

  $pubid = $public_id{$pubid_name};


  $cmd = "java -Dxml.catalog.files=$user_catalog\$SGML_CATALOG_FILES";
  $cmd = "$cmd catalog -s public \"$pubid\" | grep Resolved";

  $path = `$cmd`;

  $path =~ s/Resolved: *//g;
  $path =~ s/file://g;
  $path =~ s/^null//g;
  chomp $path;

#  print "path resolved = $path\n";
  return $path;
}

#
# 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];
  local($sgml_to_xml) = $_[2];

  open(IN, "<$lyxrc") || die "Cannot open $lyxrc\n";
  open(OUT, ">$lyxrc.new") || die "Cannot open $lyxrc.new\n";

  my $done_format = 0;
  my $done_conv = 0;
  my $done_stox = 0;

  # The 

  while () {
# Copy of the original file, unless it is the previous XML config.
if (not(/\\Format xml/ || 
/\\converter xml/ ||
/\\converter docbook 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++;
}
if (/\\converter docbook/ && $done_stox == 0) {
  # Add the SGML->XML converter
  print OUT "\\converter docbook xml \"$sgml_to_xml\" \"\"\n";
  $done_stox++;
}
  }

  close(IN);
  close(OUT);
  system("mv $lyxrc.new $lyxrc");
}

#
# Patch the configure script, so that reconfiguring will call this script too.
#
sub patch_configure
{
  local($xml_config) = $_[0];

  $ispatched = `grep $xml_config $base_db2lyx/../configure`;

  if ($ispatched eq '') {
system("cat <> $base_db2lyx/../configure
 
# Specific XML config
if test -d \\\$srcdir/db2lyx ; then
  \\\$srcdir/db2lyx/$xml_config
fi
eof");
  }
}

# Get the DB2LyX path
$base_db2lyx = dirname($0);

# We want an absolute path
$pwd = getcwd();
if (not($base_db2lyx =~ /^\//)) {
  $base_db2lyx = "$pwd/$base_db2lyx";
}

# Get the script name, and include it in the configure script
patch_configure(basename($0));

#
# We look for the available XSLT, hoping that they are declared in the
# java CLASSPATH. Besides, catalog.jar is expected too.
#
$classpath = $ENV{'CLASSPATH'};

print "+checking for catalog.jar... ";
if (not($classpath =~ /catalog.jar/)) {
  print "no\n";
  print "*** Cannot configure: missing catalog.jar in CLASSPATH\n";
  exit 1;
} else {
  print "yes\n";
}

# Let's try the user directory
$user_catalog="$pwd/db2lyx/catalog";
print "+checking for $user_catalog... ";
if (-f "$user_catalog") {
  print "yes\n";
  $user_catalog .= ":";
} else {
  print "no\n";
  $user_catalog = "";
}

@jar = split(':', $classpath);

foreach $file (@jar) {
  $f = basename($file);
  if (exists $xslt_command{$f}) {
@xslt = (@xslt, $f);
  }
}

if ($#xslt > 0) {
  print "+checking for XSLT... (@xslt)\n";

  # We take the first available XSLT