function html2xml(filein,fileout)
disp(fileout)
//copyfile('C:\Documents and Settings\grocer\Mes documents\eric\grocer\documentation\dtd.xml',fileout)
v=read(filein,-1,1,'(a)')
sl=strindex(filein,'/')
name=part(filein,sl+1:length(filein)-4)
nlines=size(v,1)
d=date()
// replacements to keep the paragraphs when defined by
and to have clean blanks
v=strsubst(v,'
','
')
v=strsubst(v,' ',' ')
v=strsubst(v,' ',' ')
v=strsubst(v,ascii(9),' ')
// eliminate all unnecessary commands
v=strsubst(v,'
','')
v=strsubst(v,'','')
v=strsubst(v,'','')
v=strsubst(v,'','')
v=strsubst(v,'','')
// replace specific chars with their xml code
v=strsubst(v,'<','<')
v=strsubst(v,'>','>')
v=strsubst(v,'²','ª')
v=strsubst(v,'°','°')
v=strsubst(v,'°','º')
v=strsubst(v,'& ','and ')
v=strsubst(v,'...','
')
v=strsubst(v,',..,',',
,')
v=strsubst(v,'ï','ï')
v=strsubst(v,'ü','ü')
v=strsubst(v,'·','.')
v=strsubst(v,' ','
')
v=strsubst(v,'
','
')
v=strsubst(v,'
','
')
v=strsubst(v,'
','
')
v=strsubst(v,'
','
')
indexample=[]
indname=[]
indinput=[]
indoutput=[]
for i=1:nlines
vi=v(i)
if ~isempty(strindex(vi,'<li>')) then
v(i)=strsubst(vi,'<li>','')+''
end
end
for i=nlines:-1:1
vi=v(i)
if v(i) == '' then
v(i) = ''+v(i+1)+''
v(i+1)=[]
end
end
nlines=size(v,1)
for i=1:nlines
vi=v(i)
v(i)=strsubst(vi,'</u>','')
v(i)=strsubst(vi,'<u>','')
if ~isempty(strindex(vi,'<p>')) then
v(i)=strsubst(v(i),'<p>','')+' '
end
if ~isempty(strindex(convstr(vi),'name')) then
indname=[indname i]
end
if ~isempty(strindex(convstr(vi),'calling')) then
indcalling=i+1
end
if ~isempty(strindex(convstr(vi),'input')) then
indinput=[indinput ;i]
end
if ~isempty(strindex(convstr(vi),'output')) then
indoutput=[indoutput ;i]
end
if ~isempty(strindex(convstr(vi),'parameters')) then
indparameters=i
end
if ~isempty(strindex(convstr(vi),'description')) then
inddes=i
end
if ~isempty(strindex(convstr(vi),'example')) then
indexample=[indexample i]
end
if ~isempty(strindex(convstr(vi),'author')) then
indauthor=i
end
while strindex(v(i),'<p>') == 1 then
v(i)=part(v(i),10:length(vi))
end
end
if ~isempty(indname) then
i=find(convstr(v) == 'name')
vj_clean = strsubst(v(i+1),'<br>','')
ind_dash=strindex(vj_clean,'-')
name_foo=strsubst(part(vj_clean,1:ind_dash(1)-1),' ','')
shortdes_foo=stripblanks(part(v(i+1),ind_dash(1)+1:length(vj_clean)))
end
ind = find(indexample>inddes)
indexample=indexample(ind(1))
v=strsubst(v,'<br>','')
vparam_in=v(indinput(1)+1:indoutput(1)-1)
vparam_out=v(indoutput(1)+1:inddes-1)
for i=1:size(vparam_in,1)
if isempty(strindex(vparam_in(i),'')) then
vparam_in(i)=''+vparam_in(i)
end
if isempty(strindex(vparam_in(i),'')) then
vparam_in(i)=vparam_in(i)+''
end
if isempty(strindex(vparam_in(i),'')) then
vparam_in(i)=''+vparam_in(i)
end
if isempty(strindex(vparam_in(i),'')) then
vparam_in(i)=vparam_in(i)+''
end
// end
end
for i=1:size(vparam_out,1)
if isempty(strindex(vparam_out(i),'')) then
vparam_out(i)=''+vparam_out(i)
end
if isempty(strindex(vparam_out(i),'')) then
vparam_out(i)=vparam_out(i)+''
end
if isempty(strindex(vparam_out(i),'')) then
vparam_out(i)=''+vparam_out(i)
end
if isempty(strindex(vparam_out(i),'')) then
vparam_out(i)=vparam_out(i)+''
end
end
vparam_in=strsubst(vparam_in,'',' ')
vparam_in=strsubst(vparam_in,' ',' ')
vparam_out=strsubst(vparam_out,'',' ')
vparam_out=strsubst(vparam_out,'',' ')
for i=1:size(vparam_in,1)
vparam_aux=strsubst(vparam_in(i),' ','')
if ~isempty(strindex(vparam_aux,'.')) then
vparam_in(i)=strsubst(vparam_in(i),'','')
vparam_in(i)=strsubst(vparam_in(i),' .',' *')
vparam_in(i)=strsubst(vparam_in(i),' ',' ')
end
if strindex(vparam_aux,'*') == 1 ...
| strindex(vparam_aux,'-') == 1 then
vparam_in(i)=strsubst(vparam_in(i),' ',' ')
vparam_in(i)=strsubst(vparam_in(i),'','')
end
if vparam_aux == '' then
vparam_in(i)=' '
end
// deal with specific cases
if ~isempty(strindex(vparam_in(i),'e.g. 1 (first 2 observations for individual # 1)')) |...
~isempty(strindex(vparam_in(i),'      1')) |...
~isempty(strindex(vparam_in(i),' 2')) |...
~isempty(strindex(vparam_in(i),' 3')) |...
~isempty(strindex(vparam_in(i),'the names of FR, FS, AR and AS represent')) |...
~isempty(strindex(vparam_in(i),'(default: thet=1)')) |...
~isempty(strindex(vparam_in(i),'WARNING:')) |...
vparam_aux == 'where:' |...
vparam_aux == 'or:' |...
vparam_aux == '&133;' |...
vparam_aux == 'withk%lt;=p'|...
~isempty(strindex(vparam_in(i),'Ex: If y(t)')) |...
~isempty(strindex(vparam_in(i),'or, and only if y ')) |...
~isempty(strindex(vparam_in(i),'(default = chol1)')) |...
~isempty(strindex(vparam_in(i),'(default = asym)')) then
vparam_in(i)=strsubst(vparam_in(i),'','')
end
end
for i=1:size(vparam_out,1)
vparam_aux=strsubst(vparam_out(i),' ','')
if ~isempty(strindex(vparam_aux,'.')) then
vparam_out(i)=strsubst(vparam_out(i),'','')
vparam_out(i)=strsubst(vparam_out(i),' ',' ')
vparam_out(i)=strsubst(vparam_out(i),'. ','* ')
end
if strindex(vparam_aux,'*') == 1 ...
| strindex(vparam_aux,'-') == 1 then
vparam_out(i)=strsubst(vparam_out(i),'',' ')
vparam_out(i)=strsubst(vparam_out(i),'','')
end
if vparam_aux == '' then
vparam_out(i)=' '
end
if vparam_aux == 'nothing' then
vparam_out(i)=strsubst(vparam_out(i),'nothing','nothing')
end
// deal with specific cases
if ~isempty(strindex(vparam_out(i),'(I + AR1.B +')) |...
~isempty(strindex(vparam_out(i),'= (G0 + G1.B +')) |...
~isempty(strindex(vparam_out(i),'(I + MA1.B +')) |...
(~isempty(strindex(vparam_out(i),'(''overallf'')')) &...
~isempty(strindex(vparam_out(i),'with:')) ) | ...
~isempty(strindex(vparam_out(i),' = ''dfp'', ''bfgs'', ''gn'', ')) | ...
vparam_out(i) == 'and' |...
vparam_out(i) == '
' |...
~isempty(strindex(vparam_out(i),'with Var(a(t)) = V')) then
vparam_out(i)=strsubst(vparam_out(i),'','')
end
end
vout=[
'';
'';
' ';
' $LastChangedDate:'+d+'$' ;
' ';
' ';
' '+name_foo+'' ;
' '+shortdes_foo+' ';
' ';
' ' ;
' ';
' CALLING SEQUENCE';
' '+v(indcalling)+'';
' ';
' ' ;
' ';
' PARAMETERS' ;
' ' ;
' ' ;
' ' ;
' Input' ;
vparam_in ;
' '
' ' ;
' '
' ' ;
' Output' ;
vparam_out ;
' ' ;
' ' ;
' ';
' '
]
if ~isempty(indexample) then
vdesc=v(inddes+1:indexample(1)-1)
vdesc=strsubst(vdesc,'','')
vdesc=strsubst(vdesc,'','')
vexample=v(indexample(1)+1:indauthor-1)
vexample=strsubst(vexample,'','')
vexample=strsubst(vexample,'','')
vexample=strsubst(vexample,'','')
for i=size(vexample,1):-1:1
if ~isempty(strindex(vexample(i),'')) then
vexample=[vexample(1:i-1) ; ' '; strsubst(vexample(i),'','') ; vexample(i+1:$)]
end
end
vout=[vout;
' ';
' DESCRIPTION';
vdesc ;
' ';
' ';
' ';
' EXAMPLE';
' '
' ';
' ' ]
else
vdesc=v(inddes+1:indauthor-1)
vdesc=strsubst(vdesc,'','')
vdesc=strsubst(vdesc,'','')
vout=[vout;
' ';
' DESCRIPTION';
vdesc ;
' ';
' ' ]
end
vauthor=v(indauthor+1)
vout=[vout;
' ';
' AUTHOR';
vauthor ;
' ';
''
]
[fd,err]=mopen(fileout,'w')
mputl(vout,fd)
mclose(fd)
endfunction