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)

#!/usr/bin/perl

# This script creates an HTML documentation for loncapa.xsd

use XML::LibXSLT;
use XML::LibXML;
use Cwd 'abs_path';

my $script_dir = abs_path($0);
my ($current_dir) = $script_dir =~ /^(.*\/).*$/;
my $xsl_path = $current_dir . 'XMLSchema.xsl';
my $schema_path = $current_dir.'../graphical_editor/loncapa_daxe/web/config/loncapa.xsd';
my $html_path = $current_dir.'loncapa.html';

my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();

my $source = $parser->parse_file($schema_path);
my $style_doc = $parser->parse_file('XMLSchema.xsl');

my $stylesheet = $xslt->parse_stylesheet($style_doc);

my $result = $stylesheet->transform($source, 'jaxe-uri-xsl' => "'".$xsl_path."'");

print $stylesheet->output_file($result, $html_path);

print "loncapa.html has been updated.\n";


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