Now we only need to add a configure magic and we'll have DocBook XML
output. (Obviously, we also need to commit this to CVS :)

----- Forwarded message from ben <[EMAIL PROTECTED]> -----

Date: Sat, 26 May 2001 01:34:09 +0200
From: ben <[EMAIL PROTECTED]>
To: List Lyx users <[EMAIL PROTECTED]>
Subject: Re: Looking for an XML ouput from Lyx/Latex
X-Accept-Language: en

Baruch Even a écrit :

> * Adolfo Pachón <[EMAIL PROTECTED]> [010525 18:05]:
> > hi all
> >
> > I'm looking for the manner of generate XML output from Lyx/Latex. I love Lyx,
> > and i won't prescind it to write documents.
>
> LyX cannot export to XML right now, it probably is possible to add such
> support but none is currently being worked on.
>

Yes, there is no direct XML output available, but it is really easy to have XML
from DocBook SGML.

With the attached file, you can have direct XML export format from lyx by adding
the following in the preference file:

\format "xml" "xml" "XML" ""
...
\converter "docbook" "xml" "/(full path)/sgml2xml.pl $$i" ""

To use it, you must change the $system path to your XML DocBook DTD.

BG




   #!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if
   $running_under_some_shell; use File::Basename; # To fix: how to
   retrieve this information? $system = ' SYSTEM
   "file:///home/ben/share/archives/docbook/docbkx412/docbookx.dtd"'; sub
   parse_sgml { local($sgmlfile) = $_[0]; local($xmlfile) = $_[1];
   local($noheader) = $_[2]; my $line = ""; my $file = ""; my $SGML =
   "f$sgmlfile"; my $XML = "f$xmlfile"; print "$sgmlfile -> $xmlfile\n";
   if (-f $xmlfile) { print "***Warning: $xmlfile already exists\n";
   system("mv $xmlfile $xmlfile~"); } open($SGML, "<$sgmlfile") || die
   "Cannot open $sgmlfile\n"; open($XML, ">$xmlfile") || die "Cannot open
   $xmlfile\n"; while (<$SGML>) { $line = $_; if ((/doctype/ ||
   /DOCTYPE/) && $noheader == 0) { # Change the file header $line =~
   s/doctype ([a-z]*) .*\"/DOCTYPE $1 $system/; $line =~ s/DOCTYPE
   ([a-z]*) .*\"/DOCTYPE $1 $system/; # Print first the XML head print
   $XML ''; print $XML "\n$line"; $noheader++; } else { $line =~
   s/`a/\`a/g; $line =~ s/e/\e/g; $line =~ s/e/\e/g; $line =~ s/e/\e/g;
   $line =~ s/i/\i/g; $line =~ s/o/\o/g; $line =~ s/u/\u/g; $line =~
   s/u/\u/g; $line =~ s/u:/\u:/g; $line =~ s/c,/\c,/g; # Case of included
   files if (/ENTITY.*\.sgml/) { # Get the included file name ($file =
   $line) =~ s/.*\"(.*)\.sgml\".*\n/$1/; # Output follow the main output
   path $outfile = dirname($xmlfile) . "/$file"; # Now the included file
   is the XML one $line =~ s/(.*)\"(.*)\.sgml\"/$1\"$outfile.xml\"/; #
   Relative or absolute path? if (not($file =~ /^\//)) { $file =
   dirname($sgmlfile) . "/$file"; } # The included files need not header
   parse_sgml("$file.sgml", "$outfile.xml", 1); } print $XML $line; } }
   close($SGML); close($XML); } # # Script start # if (not(@ARGV)) {
   print "$0 input.sgml [output.xml]\n"; exit 1; } $sgmlfile = $ARGV[0];
   $xmlfile = basename($sgmlfile, '.sgml'); $xmlfile =
   dirname($sgmlfile). "/$xmlfile.xml"; shift; if (@ARGV) { $xmlfile =
   $ARGV[0]; } parse_sgml($sgmlfile, $xmlfile, 0);


----- End forwarded message -----

-- 
Baruch Even
http://baruch.ev-en.org/

Reply via email to