forked from SWI-Prolog/packages-sgml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jan Wielemaker
committed
Dec 18, 2000
1 parent
acd29dc
commit ab759a7
Showing
39 changed files
with
456 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE bar [ | ||
<!ELEMENT bar - O EMPTY> | ||
<!ATTLIST bar a CDATA #REQUIRED b NAME #REQUIRED c NUMBER #REQUIRED | ||
d CDATA #REQUIRED> | ||
]> | ||
|
||
<bar a="Major Mynah" b="ABC" c="12" d="foo | ||
bar ugh"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE test [ | ||
<!ELEMENT test - - (#PCDATA)> | ||
]> | ||
|
||
<test> | ||
Test for handling character entities: A &#RS; | ||
</test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE a | ||
[ <!ENTITY %attrs | ||
"id ID #implied -- document-wide unique id -- | ||
class CDATA #IMPLIED -- comment --"> | ||
|
||
<!ELEMENT a - - (#PCDATA) -- foo-bar --> | ||
<!ATTLIST a %attrs;> | ||
] | ||
> | ||
|
||
<!-- x --> | ||
|
||
<a></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE con [ | ||
<!ELEMENT con - - (foo,bar)> | ||
<!ATTLIST con missing (missing) #CONREF> | ||
<!ELEMENT (foo|bar) - O (#PCDATA)> | ||
]> | ||
|
||
<con missing> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE def [ | ||
<!ENTITY #DEFAULT SDATA "?"> | ||
<!ELEMENT def - - RCDATA> | ||
]> | ||
|
||
<def>A | ||
B C | ||
&b | ||
B | ||
&c</def> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE foo [ | ||
<!ELEMENT foo O O (name+)> | ||
<!ELEMENT name - O (#PCDATA)> | ||
<!ATTLIST name title cdata #implied sex cdata #implied> | ||
]> | ||
<name title=Dr sex=M>Neddie Seagoon | ||
<name title=Miss sex=F>Minnie Bannister |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE test [ | ||
<!ENTITY QS "<q>"> | ||
<!ENTITY QE ENDTAG "q"> | ||
<!ENTITY Q2 CDATA "<q>"> | ||
<!ENTITY S SDATA "special"> | ||
<!ELEMENT test - - (#PCDATA|q)*> | ||
<!ELEMENT q - - (#PCDATA)> | ||
]> | ||
|
||
<test> | ||
&Q2;! Hello &QS;you there&QE;, I'm &S; | ||
</test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE not [ | ||
<!ELEMENT not - - (Formula*)> | ||
<!NOTATION TeX SYSTEM ""> | ||
<!NOTATION Eqn SYSTEM ""> | ||
<!ELEMENT formula - O CDATA> | ||
<!ATTLIST formula notation NOTATION (TeX|Eqn) #CURRENT> | ||
]> | ||
|
||
<not> | ||
<formula notation=TeX> | ||
$$E = MC^2$$ | ||
</formula> | ||
</not> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(bar, [a='Major Mynah', b=abc, c='12', d='foo bar ugh'], [])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(test, [], ['Test for handling character entities: A \n'])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(a, [], [])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(con, [missing=missing], [])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(def, [], ['AB C', sdata(?), 'B', sdata(?)])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(foo, [], [element(name, [title='Dr', sex='M'], ['Neddie Seagoon']), element(name, [title='Miss', sex='F'], ['Minnie Bannister'])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(test, [], ['<q>! Hello ', element(q, [], ['you there']), ', I\'m ', sdata(special)])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(not, [], [element(formula, [notation=tex], ['$$E = MC^2$$'])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(bar, [], [element(foo, [], [element(a, [], [element(b, [], [x]), element(c, [], [y])]), element(a, [], [element(b, [], [x]), element(c, [], [y])]), element(a, [], [element(b, [], [x]), element(c, [], [y])]), element(a, [], [element(b, [], [x]), element(c, [], [y])])])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(per, [], [element(jim, [], [snark])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(doc, [], [element(t, [], ['This is rcdata Hello & World Hello']), element(a, [], ['This is an a'])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(text, [], ['Van Alpha tot ', sdata('\\Omega')])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(num, [val='2'], [])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(test, [], [element(p, [], ['Peter said: ', element(q, [], ['He, this is a nice program']), '.']), element(p, [], ['Bob said: ', element(q, [], ['Yes, it is'])])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(test, [], [element(t, [], [element(name, [], [n]), element(arg, [], [a])])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[element(ugh, [], [element(extension, [missing=missing, exchange='479'], []), element(extension, [exchange='479'], ['8494']), element(extension, [exchange='555'], ['1234']), element(extension, [exchange='03-555'], ['1234'])])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE bar [ | ||
<!ELEMENT bar - - (foo)> | ||
<!ELEMENT foo O O (a+)> | ||
<!ELEMENT a O O (b,c)> | ||
<!ELEMENT b - O (#PCDATA)> | ||
<!ELEMENT c - O (#PCDATA)> | ||
]> | ||
|
||
<bar> | ||
<b>x<c>y | ||
<b>x<c>y | ||
<b>x<c>y | ||
<b>x<c>y | ||
</bar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE per [ | ||
<!ENTITY % fred "jim"> | ||
<!ELEMENT per - - (%fred;)> | ||
<!ELEMENT %fred - - (#PCDATA)> | ||
<!ATTLIST %fred tom (dick|harry) #IMPLIED> | ||
<!USEMAP #EMPTY %fred> | ||
]> | ||
|
||
<per><jim>snark</jim></per> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE doc | ||
[ <!ELEMENT doc - - (t|a)*> | ||
<!ELEMENT a - - (#PCDATA)> | ||
<!ELEMENT t - - rcdata> | ||
<!ENTITY hello "Hello"> | ||
<!ENTITY world "World &hello;"> | ||
] | ||
> | ||
|
||
<!-- coment --> | ||
|
||
<doc> | ||
<t> | ||
This is rcdata &hello; & &world | ||
</t> | ||
|
||
<a>This is an a</a> | ||
|
||
</doc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE text [ | ||
<!ENTITY Omega SDATA "\Omega"> | ||
<!ELEMENT text - - (#PCDATA)> | ||
]> | ||
|
||
<text> | ||
Van Alpha tot Ω | ||
</text> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE num [ | ||
<!ELEMENT num - O EMPTY> | ||
<!ATTLIST num val (1|2|3) #REQUIRED> | ||
]> | ||
|
||
<num 2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE test [ | ||
<!ELEMENT test - - p*> | ||
<!ELEMENT p o o (#PCDATA|q)*> | ||
<!ELEMENT q - - (#PCDATA)> | ||
|
||
<!ENTITY beg..q "<q><!USEMAP in..q>"> | ||
<!ENTITY end..q ENDTAG "q"> | ||
<!ENTITY beg..p STARTTAG "p"> | ||
|
||
<!SHORTREF in..p '"' beg..q | ||
'&#RS;B&#RE' beg..p> | ||
<!SHORTREF in..q '"' end..q> | ||
<!USEMAP in..p p> | ||
]> | ||
|
||
<test> | ||
Peter said: "He, this is a nice program". | ||
|
||
Bob said: "Yes, it is" | ||
</test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE test | ||
[ <!ELEMENT test - - (t*)> | ||
<!ELEMENT t - - ((name|op),arg)> | ||
<!ELEMENT name o o (#PCDATA)> | ||
<!ELEMENT op - - (#PCDATA)> | ||
<!ELEMENT arg - - (#PCDATA)> | ||
<!ELEMENT desc o o (#PCDATA)> | ||
|
||
<!ENTITY end-t ENDTAG "t"> | ||
<!ENTITY beg-arg STARTTAG "arg"> | ||
<!ENTITY end-arg ENDTAG "arg"> | ||
|
||
<!SHORTREF in.t | ||
'&#RE' end-t | ||
'(' beg-arg> | ||
<!SHORTREF in.arg | ||
')' end-arg> | ||
|
||
<!USEMAP in.t t> | ||
<!USEMAP in.arg arg> | ||
]> | ||
|
||
<test> | ||
<t>n(a) | ||
</test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* $Id$ | ||
Part of SWI-Prolog SGML/XML parser | ||
Author: Jan Wielemaker | ||
E-mail: [email protected] | ||
WWW: http://www.swi.psy.uva.nl/projects/SWI-Prolog/ | ||
Copying: LGPL-2. See the file COPYING or http://www.gnu.org | ||
Copyright (C) 1990-2000 SWI, University of Amsterdam. All rights reserved. | ||
*/ | ||
|
||
:- module(sgml_test, | ||
[ test/1, % +File | ||
testdir/1, % +Dir | ||
pass/1, % +File | ||
show/1, % +File | ||
test/0 | ||
]). | ||
|
||
test :- | ||
testdir(.). | ||
|
||
testdir(Dir) :- | ||
atom_concat(Dir, '/*', Pattern), | ||
expand_file_name(Pattern, Files), | ||
checklist(dotest, Files). | ||
|
||
dotest(File) :- | ||
file_name_extension(_, Ext, File), | ||
memberchk(Ext, [sgml, xml, html]), !, | ||
test(File). | ||
dotest(_). | ||
|
||
test(File) :- | ||
format('Test ~w ... ', [File]), | ||
flush_output, | ||
load_file(File, Term), | ||
ground(Term), % make sure | ||
okfile(File, OkFile), | ||
( exists_file(OkFile) | ||
-> load_prolog_file(OkFile, TermOk), | ||
( compare_dom(Term, TermOk) | ||
-> format('ok~n') | ||
; format('WRONG~n') | ||
) | ||
; format('Loaded, no validating data~n'), | ||
pp(Term) | ||
). | ||
|
||
show(File) :- | ||
load_file(File, Term), | ||
pp(Term). | ||
|
||
pass(File) :- | ||
load_file(File, Term), | ||
okfile(File, OkFile), | ||
open(OkFile, write, Fd), | ||
format(Fd, '~q.~n', [Term]), | ||
close(Fd). | ||
|
||
load_file(File, Term) :- | ||
load_pred(Ext, Pred), | ||
file_name_extension(_, Ext, File), !, | ||
call(Pred, File, Term). | ||
load_file(Base, Term) :- | ||
load_pred(Ext, Pred), | ||
file_name_extension(Base, Ext, File), | ||
exists_file(File), !, | ||
call(Pred, File, Term). | ||
|
||
|
||
load_pred(sgml, load_sgml_file). | ||
load_pred(xml, load_xml_file). | ||
load_pred(html, load_html_file). | ||
|
||
okfile(File, OkFile) :- | ||
file_name_extension(Base, _, File), | ||
file_directory_name(Base, Dir), | ||
concat_atom([Dir, '/ok/', Base, '.ok'], OkFile). | ||
|
||
load_prolog_file(File, Term) :- | ||
open(File, read, Fd), | ||
read(Fd, Term), | ||
close(Fd). | ||
|
||
compare_dom([], []) :- !. | ||
compare_dom([H1|T1], [H2|T2]) :- !, | ||
compare_dom(H1, H2), | ||
compare_dom(T1, T2). | ||
compare_dom(X, X) :- !. | ||
compare_dom(element(Name, A1, Content1), | ||
element(Name, A2, Content2)) :- | ||
compare_attributes(A1, A2), | ||
compare_dom(Content1, Content2). | ||
|
||
compare_attributes(A1, A2) :- | ||
sort(A1, L1), | ||
sort(A2, L2), | ||
L1 == L2. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE ugh [ | ||
<!ELEMENT ugh O O (extension+)> | ||
<!ELEMENT extension - O (#PCDATA)> | ||
<!ATTLIST extension exchange NUTOKEN 479 missing (missing) #CONREF> | ||
]> | ||
<extension missing> | ||
<extension>8494 | ||
<extension exchange=555>1234 | ||
<extension exchange=03-555>1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.