File:  [LON-CAPA] / modules / damieng / schema_documentation / update_documentation.pl
Revision 1.1: download - view: text, annotated - select for diffs
Thu Jan 5 19:37:43 2017 UTC (7 years, 3 months ago) by damieng
Branches: MAIN
CVS tags: HEAD
added a Perl script to generate the HTML documentation from the schema (the XSLT comes from Jaxe)

    1: #!/usr/bin/perl
    2: 
    3: # This script creates an HTML documentation for loncapa.xsd
    4: 
    5: use XML::LibXSLT;
    6: use XML::LibXML;
    7: use Cwd 'abs_path';
    8: 
    9: my $script_dir = abs_path($0);
   10: my ($current_dir) = $script_dir =~ /^(.*\/).*$/;
   11: my $xsl_path = $current_dir . 'XMLSchema.xsl';
   12: my $schema_path = $current_dir.'../graphical_editor/loncapa_daxe/web/config/loncapa.xsd';
   13: my $html_path = $current_dir.'loncapa.html';
   14: 
   15: my $parser = XML::LibXML->new();
   16: my $xslt = XML::LibXSLT->new();
   17: 
   18: my $source = $parser->parse_file($schema_path);
   19: my $style_doc = $parser->parse_file('XMLSchema.xsl');
   20: 
   21: my $stylesheet = $xslt->parse_stylesheet($style_doc);
   22: 
   23: my $result = $stylesheet->transform($source, 'jaxe-uri-xsl' => "'".$xsl_path."'");
   24: 
   25: print $stylesheet->output_file($result, $html_path);
   26: 
   27: print "loncapa.html has been updated.\n";
   28: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>