File: xmlfiletohtml.sci.in

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (74 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function xmlfiletohtml(path,xsl)

	// Copyright Enpc (Jean-Philippe Chancelier)
	//given a path on a Scilab help xml file  (assumed to respect 
	//SCI/man/man-rev.dtd ) this function generates the corresponding htm
	//file using the /man/<LANGUAGE>/html-rev.xsl xsl file
	
	generate_cmd='@MANGENERATOR@';
	
	[lhs,rhs]=argn(0);
	if rhs < 2 then xsl= 'html-rev.xsl';end //the xsl file name;
	global LANGUAGE %helps
	path=pathconvert(path,%f,%t) // convert path to host convention
  
	//proceed if xml file is newest than htm file
	if newest(path,strsubst(path,".xml",".htm"))==1 then
	
		mprintf('  Processing file %s.xml\n',basename(path));

		// build .xml2 file where LINK tags references are solved
		find_links(path,path+"2")
		update_date(path,path+"2")
		in=path+"2"
		out=strsubst(path,'.xml','.htm')
    
		// form the html generatorc command line instruction
		if  MSDOS then 
			// sabcmd does not like c:/.. path replace it by file://c:/..
			xsl='file://'+pathconvert(SCI+'/man/'+LANGUAGE)+xsl;
			generate_cmd='""'+WSCI+'\Win-util\sablotron\sabcmd'+'""'
			instr=generate_cmd+' '+xsl+' '+in+' '+out
			RM='del /s '
		else
			xsl=pathconvert(SCI+'/man/'+LANGUAGE)+xsl;
			if generate_cmd=='xsltproc' then 
				instr=generate_cmd+' -o '+out+' '+xsl+' '+in
			else
				instr=generate_cmd+' '+xsl+' '+in+' '+out
			end
			RM='rm -f '
		end

		//run html generator
		if execstr('unix_s('+sci2exp(instr)+')','errcatch')<>0 then 
			write(%io(2),'     Warning '+path+' does not follow the dtd','(a)')
		end
		
		unix_s(RM+path+"2")
	end
endfunction

function update_date(xmlfile,xmlfile2)

	//-------------------------------------
	// Author : Pierre MARECHAL
	// Scilab Team
	// Copyright INRIA
	// Date : 09/05/2005
	//-------------------------------------
	
	//-------------------------------------
	// Add the date of the last modification of the xml file
	//--------------------------------------

	txt=mgetl(xmlfile2);
	d=grep(txt,"<DATE>");
	if d==[] then mputl(txt,xmlfile2); return; end
	[x,ierr]=fileinfo(xmlfile);
	if x(6)<1064550000 then mputl(txt,xmlfile2); return; end
	modification_date = getdate(x(6));
	txt(d)="<DATE>"+string(modification_date(6))+"/"+string(modification_date(2))+"/"+string(modification_date(1))+"</DATE>";
	mputl(txt,xmlfile2);
	
endfunction