Experiment with porting SGML to YAP, and trying to preserve SWI code as much
as possible.
This commit is contained in:
parent
754f00d311
commit
d6a06fe092
6
packages/sgml/COPYING
Normal file
6
packages/sgml/COPYING
Normal file
@ -0,0 +1,6 @@
|
||||
This library is distributed under the LGPL licence terms. For details
|
||||
visit http://www.gnu.org/copyleft/lesser.html.
|
||||
|
||||
Holders of the SWI-Prolog commercial license (see
|
||||
http://www.swi.psy.uva.nl/projects/SWI-Prolog/) may use this software
|
||||
under the same conditions as SWI-Prolog.
|
716
packages/sgml/ChangeLog
Normal file
716
packages/sgml/ChangeLog
Normal file
@ -0,0 +1,716 @@
|
||||
[Feb 16 2009]
|
||||
|
||||
* FIXED: Release HTML DTDs when using load_html_file/2 in a thread.
|
||||
|
||||
[Feb 15 2009]
|
||||
|
||||
* FIXED: Memory leak in SGML parser.
|
||||
|
||||
[Jan 21 2009]
|
||||
|
||||
* FIXED: RDF writer: write valid XML if the namespace entity contains characters
|
||||
that must be %-escaped. Jacopo Urbani.
|
||||
|
||||
[Jan 13 2009]
|
||||
|
||||
* FIXED: RDF/XML could save illegal XML if multiple namespaces are used
|
||||
for predicates where one namespace is a prefix of another one. Jacopo Urbani.
|
||||
[Dec 19 2008]
|
||||
|
||||
* FIXED: Correct usage of content_length option in sgml_parse/3 when using callbacks. Needed to deal with streaming input for parsing RDF.
|
||||
|
||||
* ADDED: Pass content_length through process_rdf/3
|
||||
[Oct 13 2008]
|
||||
|
||||
* CLEANUP: Avoid repetition and warnings on option processing predicates. Matt Lilley.
|
||||
[Sep 11 2008]
|
||||
|
||||
* PORT: Add AC_PREREQ to configure.h for systems that auto-select autoconf
|
||||
versions. After tip by Ulrich Neumerkel.
|
||||
|
||||
[Aug 11 2008]
|
||||
|
||||
* INSTALL: Remove all configure files from the git repository
|
||||
[May 20 2008]
|
||||
|
||||
* MODIFIED: Streams in socket.pl and ssl.pl appeared unbuffered. They
|
||||
are now fully buffered.
|
||||
|
||||
[Apr 18 2008]
|
||||
|
||||
* MODIFIED: Renamed hash_term/2 to term_hash/2. Added hash_term/2 to
|
||||
library(backcomp), so most code should not notice this.
|
||||
[Mar 1 2008]
|
||||
|
||||
* ENHANCED: Allow for GC from PL_handle_signals(), providing GC for foreign
|
||||
code building large structures. This is now used by the SGML/XML parser
|
||||
to avoid running unnecessarily out of stack.
|
||||
|
||||
[Feb 28 2008]
|
||||
|
||||
* FIXED: rdf_write_xml/2 loops if it encounters an rdf:Bag.
|
||||
|
||||
[Feb 18 2008]
|
||||
|
||||
* FIXED: More fixes for proper handling of rdf:Bag
|
||||
|
||||
[Feb 13 2008]
|
||||
|
||||
* FIXED: Emit rdf:Bag attributes (etc.) as rdf:li
|
||||
|
||||
* FIXED: possible failure in rdf_write_xml with http://t-d-b.org?
|
||||
|
||||
[Jan 23 2008]
|
||||
|
||||
* PORT: Bug#346: Allow overriding COFLAGS and CWFLAGS in package
|
||||
configuration. Keri Harris.
|
||||
[Jan 14 2008]
|
||||
|
||||
* FIXED: Bug#343: Handling bnodes in rdf_write_xml. Yver Raimond.
|
||||
|
||||
* FIXED: Added support for rdf:NodeID to rdf_write_xml/2. Yves Raimond.
|
||||
|
||||
[Dec 13 2007]
|
||||
|
||||
* FIXED: library(rdf_write) to deal with operators. Related to Bug#332
|
||||
|
||||
[Nov 12 2007]
|
||||
|
||||
* FIXED: Bug#320: Memory leak when parsing SGML NOTATIONs. Keri Harris.
|
||||
|
||||
Oct 30, 2007
|
||||
|
||||
* FIXED: xml_write/3 quoting of < in attributes. Dmitry Kuzmin.
|
||||
|
||||
Sep 11, 2007
|
||||
|
||||
* FIXED: xml_write/3 for multi-valued attributes such as IDREFS, NAMES,
|
||||
etc. Victor de Boer and Anjo Anjewierden.
|
||||
|
||||
Jun 6, 2007
|
||||
|
||||
* MODIFIED: Avoid recursive expansion of entities, unless marked as
|
||||
SGML content.
|
||||
* FIXED: Strict XML comment syntax. Jacco van Ossenbruggen.
|
||||
* FIXED: give error on bad entities in XML mode. Jacco van Ossenbruggen.
|
||||
|
||||
Feb 6, 2007
|
||||
|
||||
* MODIFIED: xml_quote_attribute no longer maps ' to ' See note in
|
||||
quote.c
|
||||
|
||||
Nov 15, 2006
|
||||
|
||||
* FIXED: properly pass <?pi> instructions.
|
||||
|
||||
Oct 27, 2006
|
||||
|
||||
* ENHANCEMENT: Started branch XML_UNICODE to provide support for Unicode
|
||||
filenames, tags and elements.
|
||||
|
||||
Aug 28, 2006
|
||||
|
||||
* DOCUMENTATION: Moved to sgml.doc, using the same system as the
|
||||
remainder of the system.
|
||||
|
||||
Jul 25, 2006
|
||||
|
||||
* FIXED: space(default) handling. Juho Östman.
|
||||
|
||||
Jun 20, 2006
|
||||
|
||||
* FIXED: illegal read. Can cause wrong data and/or crashes.
|
||||
|
||||
Feb 16, 2006
|
||||
|
||||
* ENHANCED: various improvements of the sgml_write.pl library by Richard
|
||||
O'Keefe.
|
||||
|
||||
Feb 12, 2006
|
||||
|
||||
* ENHANCED: xml_write/3: if encoding is `text', write the data as UTF-8
|
||||
|
||||
Feb 9, 2006
|
||||
|
||||
* FIXED: valgrind detected memory error. Not sure whether or not it was
|
||||
a real error.
|
||||
|
||||
Feb 1, 2006
|
||||
|
||||
* PORT: Detect inline behaviour of compiler in configure
|
||||
|
||||
Jan 19, 2006
|
||||
|
||||
* FIXED: Allow for different deparators in in/excluded namegroup.
|
||||
Anjo Anjewierden.
|
||||
|
||||
Jul 7, 2005
|
||||
|
||||
* ADDED: entiry(+Name, +Value) to (re-)define CDATA entity values.
|
||||
|
||||
Mar 31, 2005
|
||||
|
||||
* ADDED: make exceptions in call-backs from sgml_parse/3 return the
|
||||
parser immediately with the given exception.
|
||||
|
||||
Mar 29, 2005
|
||||
|
||||
* ADDED: layout(Bool) option to the xml_write/3 and friends predciates.
|
||||
|
||||
Mar 21, 2005
|
||||
|
||||
* ADDED: specify dialect for loading DTDs. After mail from Sebastien Cabot.
|
||||
|
||||
* FIXED: Avoid error on thread_at_exit when using in single-threaded
|
||||
Prolog. Anjo Anjewierden.
|
||||
|
||||
Mar 6, 2005
|
||||
|
||||
* ADDED: improved namespace and indentation support for xml_write/3.
|
||||
|
||||
Mar 5, 2005
|
||||
|
||||
* ADDED: xml_is_dom/1. Option header(Bool) to xml_write to suppress
|
||||
writing the header.
|
||||
|
||||
Mar 4, 2005
|
||||
|
||||
* ADDED: xmlns support to xml_write/3.
|
||||
|
||||
* ENHANCED: library(sgml_write): Indent attributes if there are too many.
|
||||
|
||||
Mar 01, 2005
|
||||
|
||||
* ADDED: encoding argument to xml_quote_* and xml_name/2 predicates.
|
||||
|
||||
Feb 24, 2005
|
||||
|
||||
* ADDED: handle encoding="US-ASCII" for XML documents.
|
||||
|
||||
Feb 22, 2005
|
||||
|
||||
* MODIFIED: Use Sgetcode() rather than Sgetc() to get data from a Prolog
|
||||
stream. Extended parser to accept characters outside 0..255 range.
|
||||
|
||||
Feb 7, 2005
|
||||
|
||||
* ADDED: when converting attributes to integers on 32-bit machines,
|
||||
exploit 64-bit Prolog integers.
|
||||
|
||||
Jan 6, 2005
|
||||
|
||||
* FIXED: Documentation
|
||||
|
||||
Dec 21, 2004
|
||||
|
||||
* ADDED: library(sgml_write), providing conversion of parsed data to
|
||||
a file.
|
||||
|
||||
Dec 20, 2004
|
||||
|
||||
* Working wide-character version. Consequences:
|
||||
- CDATA attributes and content never contain entities anymore
|
||||
as all text can now be represented.
|
||||
- Limit on quoted CDATA attribute values (was 2048 characters)
|
||||
has been removed.
|
||||
|
||||
Dec 19, 2004
|
||||
|
||||
* Start working on wide-character support: introducing wide-character
|
||||
output buffers.
|
||||
|
||||
Dec 15, 2004
|
||||
|
||||
* FIXED: Bug#212: Disallow � character entities.
|
||||
|
||||
Nov 25, 2004
|
||||
|
||||
* FIXED: utf-8 tests, avoid conflict with UTF-8 support in Prolog
|
||||
|
||||
Sep 13, 2004
|
||||
|
||||
* ENHANCED: load_html_file/2: add shorttag(false) to the load_structure/3
|
||||
options for better parsing of common errornous HTML pages.
|
||||
|
||||
Aug 26, 2004
|
||||
|
||||
* FIXED: Bug#177: catalog files from $SGML_CATALOG_FILES were not
|
||||
honoured. Simon Ambler. Also made catalog management thread-safe.
|
||||
|
||||
Jul 22, 2004
|
||||
|
||||
* MODIFIED: Updated XML-Schema (XSD) namespace in xsdp_types.pl
|
||||
|
||||
Apr 28, 2004
|
||||
|
||||
* ADDED: iso_639.pl: ISO-639 language identifiers.
|
||||
|
||||
Apr 27, 2004
|
||||
|
||||
* ADDED: first version of xsdp_types.pl, a module to do type checking
|
||||
and type conversion for XSD (XML Schema DataTypes).
|
||||
|
||||
Apr 26, 2004
|
||||
|
||||
* FIXED: Bug#149: Buffer overflow reading too long NAME, NMTOKEN, etc.
|
||||
Fabien Todescato.
|
||||
|
||||
Jan 17, 2004
|
||||
|
||||
* FIXED: handling <?xml ...?> switching from SGML to XML mode.
|
||||
Fabien Todescato.
|
||||
|
||||
Jan 9, 2004
|
||||
|
||||
* FIXED: avoid sharing DTD objects between threads. Fabien Todescato.
|
||||
|
||||
Nov 20, 2003
|
||||
|
||||
* ADDED: xml_name/1 to test an atom to refer to a valid XML name.
|
||||
|
||||
Nov 3, 2003
|
||||
|
||||
* FIXED: Error parsing SHORTREF declaration that has whitespace at the
|
||||
end. Richard O'Keefe.
|
||||
|
||||
Sep 12, 2003
|
||||
|
||||
* FIXED: Memory leak in load_structure/3 (not freeing the parser data).
|
||||
Petter Egesund.
|
||||
|
||||
Jul 8, 2003
|
||||
|
||||
* ADDED: handle UTF-8 sequences producing characters that cannot be
|
||||
represented as character entities. Suggested by C. M. Sperberg-McQueen.
|
||||
|
||||
* FIXED: handling &#X, where 128<=X<256 with UTF-8 decoding enabled.
|
||||
C. M. Sperberg-McQueen.
|
||||
|
||||
Jun 9, 2003
|
||||
|
||||
* FIXED: SGML SHORTREF declaration performed case-insensitive entity
|
||||
lookup. Richard O'Keefe.
|
||||
|
||||
Jun 4, 2003
|
||||
|
||||
* ENHANCED: type the conflicting CDATA in #PCDATA that violates the DTD
|
||||
|
||||
May 23, 2003
|
||||
|
||||
* FIXED: More catalog trouble. Richard O'Keefe.
|
||||
|
||||
May 22, 2003
|
||||
|
||||
* FIXED: Lookup of system identifiers through the catalogue (avoid early
|
||||
tagging with file:) Richard O'Keefe.
|
||||
|
||||
May 21, 2003
|
||||
|
||||
* FIXED: Handle -- in element-names (Bijan Parsia).
|
||||
|
||||
May 8, 2003
|
||||
|
||||
* Fix registering catalog files
|
||||
|
||||
May 5, 2003
|
||||
|
||||
* Incorporated better CATALOG parsing by Richard O'Keefe. May be incomplete
|
||||
or incorrect.
|
||||
|
||||
* FIXED: call(end, Goal) passing the element-name incorrectly (breaks
|
||||
process_rdf/3).
|
||||
|
||||
* FIXED: delay unification of value in load_structure/3.
|
||||
|
||||
* FIXED: Properly expand UTF-8 values in CDATA attributes
|
||||
|
||||
* FIXED: Properly handle unquoted attributes at the end of an empty element
|
||||
in XML mode <foo bar=10/>
|
||||
|
||||
* FIXED: #CONREF attribute handling in elements with declared content
|
||||
(CDATA/RCDATA). Richard O'Keefe.
|
||||
|
||||
SWI-Prolog VERSION 5.0.10
|
||||
=========================
|
||||
|
||||
* FIXED: properly handle elements that have only an <!ATTLIST declaration
|
||||
but no <!ELEMENT declaration. (C. M. Sperberg-McQueen).
|
||||
|
||||
* FIXED: handle CDATA inside elements with content-type ANY
|
||||
(C. M. Sperberg-McQueen).
|
||||
|
||||
* MODIFIED: silently ignore attempts to redefine entity declarations.
|
||||
Richard O'Keefe.
|
||||
|
||||
* FIXED: skip [] for detection of nesting inside literal values and fix
|
||||
handling of [] in the <!DOCTYPE xxx [...]> declaration. Richard O'Keefe.
|
||||
|
||||
* MODIFIED/ADDED: qualify_attributes option for xmlns mode. Default is
|
||||
now *not* to qualify attributes.
|
||||
|
||||
* FIXED: Handle elements inside shorttag values. Thanks Richard O'Keefe
|
||||
for providing a clear description how to handle this.
|
||||
|
||||
SWI-Prolog VERSION 5.0.9
|
||||
========================
|
||||
|
||||
* FIXED: correct handling of content_length(Len) option (was reading one
|
||||
character too many). Oops, normal reading was broken. Fixed.
|
||||
|
||||
* FIXED: Correctly handle marked sections ending in ]]]> rather than ]]>
|
||||
Spotted by Adrian Boyko.
|
||||
|
||||
* ADDED: xml_quote_attribute/2 and xml_quote_cdata/2, providing simple
|
||||
quote-support.
|
||||
|
||||
* FIXED: parse(content) option to the parser (multiple bugs) required for
|
||||
process_rdf/3 (Girish Padmalayam).
|
||||
|
||||
* FIXED: dtd2pl: printing of NAMEOF and NMTOKEN attributes
|
||||
(Joseph Wayne Norton).
|
||||
|
||||
* FIXED: load_structure/3 to pass doctype(_) to the correct place.
|
||||
|
||||
* ADDED: space(sgml) option. Was documented but omitted.
|
||||
|
||||
|
||||
SWI-Prolog VERSION 4.0.11
|
||||
=========================
|
||||
|
||||
* MODIFIED: When processing non-validated data in space-preserve mode, emit
|
||||
ALL blank data (Richard O'Keefe).
|
||||
|
||||
* FIXED: close file after reading DTD from a file. (Anjo Anjewierden)
|
||||
|
||||
* FIXED: handling of (a) +(b) element declaraction (Richard O'Keefe)
|
||||
|
||||
* ADDED: Warning when redefining (parameter) entities.
|
||||
|
||||
* ENHANCED/FIXED: Process entities refering to files directly. This
|
||||
reduces memory needs and fixes path-problems in recursive includes.
|
||||
This applies for both normal and parameter entities.
|
||||
|
||||
* ADDED: Test for legal value in attributes with type NAMEOF (a|b)
|
||||
|
||||
* FIXED: Handle (a,b), (a&b) and (a|b) as equivalent in ATTLIST type
|
||||
declaration.
|
||||
|
||||
* FIXED: option shorttag was spelled shortag.
|
||||
|
||||
* FIXED: Ensure the output is properly closed, even if the parser encounters
|
||||
an unexpected end-of-file.
|
||||
|
||||
|
||||
SWI-Prolog VERSION 4.0.6
|
||||
========================
|
||||
|
||||
* FIXED: Data overwriting in <DOCTYPE ... [local stuff]> if local stuff
|
||||
is too long (Andrew Dadakov).
|
||||
|
||||
* FIXED: Report elements not in the DTD allowed by the ANY model
|
||||
as error (Andrew Dadakov).
|
||||
|
||||
* FIXED: Call sgml_nomem() after strdup in case of out-of-memory
|
||||
(Richard O'Keefe).
|
||||
|
||||
* PORT: Removed alloca() usage (Richard O'Keefe).
|
||||
|
||||
* LIMIT: Make maximum string length 2048 to allow parsing HTML4 DTD.
|
||||
Maybe we should remove comments while fetching parameter-entity
|
||||
values?
|
||||
|
||||
* FIXED: Include #FIXED and defaulted arguments for omitted tags
|
||||
(reported by Richard O'Keefe).
|
||||
|
||||
* ADDED: handle plain <!DOCTYPE doc> silently if the catalog contains
|
||||
a DOCTYPE doc file.dtd entry.
|
||||
|
||||
* FIXED: Various issues in attribute handling with new routines supplied
|
||||
by Richard O'Keefe. Added shorttag(Bool) to options you can set.
|
||||
|
||||
* ADDED: `make check' to run the test-suite.
|
||||
|
||||
* FIXED: Handling of &<tag> (Richard O'Keefe).
|
||||
|
||||
* FIXED: dtd2pl to use model(Model) to avoid amibiguity between CDATA and
|
||||
(CDATA) model. Richard O'Keefe.
|
||||
|
||||
* FIXED: Various output aspects of the sgml driver program, notably case and
|
||||
character escaping problems. By Richard O'Keefe.
|
||||
|
||||
* ADDED: Ignore SGML declaration in <!SGML ...>
|
||||
|
||||
* FIXED: Do not require ; after character-entity
|
||||
|
||||
* ADDED: Expand character and parameter entities while parsing literals
|
||||
in a DTD (Richard O'Keefe).
|
||||
|
||||
|
||||
VERSION 1.0.13
|
||||
==============
|
||||
|
||||
* FIXED: Interpret <!ENTITY e STARTTAG "x"> as <!ENTITY e "<x>"> (well,
|
||||
dependent on the delimiters). (Richard O'Keefe).
|
||||
|
||||
* FIXED: Allow omitted end-tag for RCDATA and CDATA elements (only effective
|
||||
when hitting the end of the file).
|
||||
|
||||
* FIXED: Proper parsing of <!NOTATION ...> declaration. Also fixed
|
||||
dtd_property(DTD, notations(Notations)) and modified
|
||||
dtd_property(DTD, notation(N, Decl)).
|
||||
|
||||
* ADDED: <!ENTITY #DEFAULT ...> (Richard O'Keefe).
|
||||
|
||||
* FIXED: Ignore newline after entity
|
||||
|
||||
* FIXED: Allow omitted ; expanding entities in CDATA attributes
|
||||
|
||||
* FIXED: Possible crash with SHORTREF endding in &#RE.
|
||||
|
||||
* FIXED: avoid crash on illegal syntax in DTD omited-tag declaration
|
||||
|
||||
VERSION 1.0.12
|
||||
==============
|
||||
|
||||
* FIXED: More white-space issues in handling quoted attribute values.
|
||||
|
||||
* ADDED: XML NAMECHARS to the default set. This seems to match HTML-4
|
||||
better and will only in exceptional cases harm normal SGML processing.
|
||||
|
||||
* ADDED/MODIFIED: Attributes not in the source, but with a default or
|
||||
fixed value declared in the DTD are now included in the output. The
|
||||
old behaviour can be used using the defaults(false) option to
|
||||
load_structure/3.
|
||||
|
||||
* FIXED: expand parameter-entities in <!USEMAP declaration.
|
||||
|
||||
* FIXED: sgml utility to canonise space in output of `list' attributes.
|
||||
|
||||
* FIXED: proper entity-expansion and blank-canonisation in attribute-vaues
|
||||
(Richard O'Keefe).
|
||||
|
||||
* FIXED: false warning at start of NUTOKEN attribute (Richard O'Keefe).
|
||||
|
||||
VERSION 1.0.11
|
||||
==============
|
||||
|
||||
* ADDED: handling of #CONREF attribute default (Richard O'Keefe).
|
||||
|
||||
* FIXED: sgml utility not to print "C" at the end when there where errors
|
||||
(Richard O'Keefe)
|
||||
|
||||
* FIXED: handle value-shorthand for nmtoken (Richard O'Keefe)
|
||||
|
||||
* FIXED: &RE; SHORTREF handling if the newline appears as the first
|
||||
character of a (new) #PCDATA block.
|
||||
|
||||
* CONFIG: Added -with-prolog=<Prolog> by Milan Zamazal for integration
|
||||
as Debian (linux) package.
|
||||
|
||||
|
||||
VERSION 1.0.10
|
||||
==============
|
||||
|
||||
* UPDATE: calls to select/3 for compatibility to SWI-Prolog 3.4
|
||||
|
||||
* FIXED: Allow <!USEMAP before <!SHORTREF
|
||||
|
||||
* FIXED: handling the #empty map (SGML SHORTREF).
|
||||
|
||||
* MODIFIED: state-engine for <>, using a new state S_DECL0 after seeing <
|
||||
to decide whether this is a non-escaped < in CDATA or a real tag. Also
|
||||
changed comment-handling to avoid the need for parser->previous_char.
|
||||
|
||||
* ADDED: sgml utility allow for parsing stdin.
|
||||
|
||||
* PERFORMANCE: Improved expand_[p]entities(), providing about 10%
|
||||
overall improvement.
|
||||
|
||||
* FIXED: crash in sgml (demo-)driver app causing a crash if the input
|
||||
file has no extension (Richard O'Keefe).
|
||||
|
||||
* ADDED: support for RCDATA declared-content elements
|
||||
|
||||
* FIXED: SGML-mode: immediately close EMPTY elements (i.e. do not allow
|
||||
for a closing </img>).
|
||||
|
||||
* IMPROVED: Error reporting on elements not in the DTD.
|
||||
|
||||
* ADDED: get_sgml_parser(Parser, dtd(-DTD)).
|
||||
|
||||
VERSION 1.0.8
|
||||
=============
|
||||
|
||||
* FIXED: Problem in windows version regarding text/binary file and \ <-> /
|
||||
difference.
|
||||
|
||||
* FIXED: Problem finding HTML4 .soc file
|
||||
|
||||
* FIXED: entity_file() to avoid a crash if the entity is not in the catalog.
|
||||
|
||||
* ADDED: Parse not-quoted attribute values that require quotes by parsing
|
||||
upto the next layout character. Give a warning. For example:
|
||||
<hr width=50%> is parsed as <hr width="50%">, but a warning is displayed.
|
||||
|
||||
* FIXED: Crash if start of file is not a declaration but ordinary non-blank
|
||||
text.
|
||||
|
||||
* ADDED: Improved source-location handling and some additional call-backs
|
||||
to the call-back interface, preparing the parser for supporting SGML
|
||||
syntax highlighting and checking editors. See get_sgml_parser/2 and
|
||||
sgml_parse/2 predicates.
|
||||
|
||||
VERSION 1.0.7
|
||||
=============
|
||||
|
||||
* IMPROVED: Redirect all memory management to print a fatal error message
|
||||
instead of crashing.
|
||||
|
||||
* IMPROVED: Handle the (illegal) comment <!-- some text -- more text -->
|
||||
more elegantly: assume <!-- will be terminated by --> and generate a
|
||||
warning if text was found outside --comment--.
|
||||
|
||||
* FIXED: Some issues in marked-section handling
|
||||
|
||||
* ADDED: Direct error reporting of sgml application through callback for
|
||||
demo purposes. Message now includes the current dialect.
|
||||
|
||||
* FIXED: sgml application: do not convert case in XML mode.
|
||||
|
||||
* FIXED: Do not report error on not-declared xmlns attribute in XML mode.
|
||||
|
||||
* Cleaned Makefiles
|
||||
|
||||
VERSION 1.0.6
|
||||
=============
|
||||
|
||||
* ADDED: SGML based documentation of the package with converters to LaTeX
|
||||
and HTML in Prolog.
|
||||
|
||||
* ADDED/MODIFIED: number(NumberMode) option to the load_structure/3.
|
||||
By default NUMBER and NUMBERS tokens are now parsed as tokens of digits.
|
||||
Using number(integer) they are converted to Prolog integers, provided
|
||||
they fit (Richard O'Keefe).
|
||||
|
||||
* ADDED: If a document is parsed without DTD and a catalog is provided,
|
||||
try finding a matching DTD file from the catalog. If successful
|
||||
print a warning and load this DTD.
|
||||
|
||||
* FIXED: Ensure the -xml flag to the sgml utility works again.
|
||||
|
||||
* INSTALL: Check for existence of runtex
|
||||
|
||||
* INSTALL: Do not cache Prolog related variables.
|
||||
|
||||
* FIXED: signed/unsigned character handling in catalog.c (Richard O'Keefe)
|
||||
|
||||
* MODIFIED: Representation for source-locations.
|
||||
|
||||
|
||||
VERSION 1.0.5
|
||||
=============
|
||||
|
||||
* MODIFIED: Get SYSTEM entities relative to the file in which the
|
||||
entity is declared. Get PUBLIC entities from the second argument
|
||||
if the catalog (entry) is not found.
|
||||
|
||||
* FIXED: Deal with elements only containing shortref references
|
||||
|
||||
* MODIFIED: Only insert missing close-tags that should not be on closing
|
||||
outer environments, not because an element is encountered that fits in
|
||||
an outer environment. Improves error behaviour.
|
||||
|
||||
* ADDED: Print default list values in dtd2pl
|
||||
|
||||
* ADDED: Support for the content-model ANY.
|
||||
|
||||
* ADDED: option -xml to pl2dtd to force it loading a DTD in XML mode.
|
||||
|
||||
* FIXED: Do not expand SHORTREF inside CDATA marked sections and elements.
|
||||
|
||||
* ADDED: Properly deal with NUTOKEN: handling DTD default and validate type.
|
||||
|
||||
* FIXED: Expand parameter entities in SHORTREF declaraction (Richard O'Keefe).
|
||||
|
||||
* FIXED: Handling of < as last character of a CDATA element
|
||||
|
||||
* FIXED: proper handling of &#RE; in SHORTREF
|
||||
|
||||
* FIXED: Open CDATA element when encountering a CDATA entity.
|
||||
|
||||
* FIXED: SHORTTAG with attributes: <foo a=b/value/
|
||||
|
||||
|
||||
VERSION 1.0.4
|
||||
=============
|
||||
|
||||
* FIXED: file_to_dtd() not to free the created DTD. This makes dtd2pl work
|
||||
again. (Richard O'Keefe)
|
||||
|
||||
* FIXED: Allow for layout before sub-models: ( (a,b)|c). (Andrew Dadakov)
|
||||
|
||||
* FIXED: Allow for quoted nmtoken, etc. in ATTLIST declaration.
|
||||
(Andrew Dadakov)
|
||||
|
||||
|
||||
VERSION 1.0.3
|
||||
=============
|
||||
|
||||
* FIXED: Allow for (a,b), etc. instead of just (a|b) where an element-list
|
||||
is expected.
|
||||
|
||||
|
||||
VERSION 1.0.2
|
||||
=============
|
||||
|
||||
* ADDED: Partial SHORTTAG support (<tag/content/ and </>)
|
||||
|
||||
* ADDED: Prolog interface: map multi-valued attributes to a list.
|
||||
|
||||
* FIXED: ESIS output of the sgml utility to provide better compliant output
|
||||
for attributes (before the open-tag, including the type and in UPPERCASE).
|
||||
|
||||
* ADDED: Handling <!SHORTREF ...> and friends.
|
||||
|
||||
* FIXED: Added &#RS;, &#RE;, &#TAB; and &#SPACE; (Richard O'Keefe)
|
||||
|
||||
* FIXED: Processing instruction is now <?....[?]> (i.e. optional closing ?)
|
||||
Q: Is this XML or SGML? Check docs!
|
||||
|
||||
* FIXED: Line-number info for DOCTYPE declarations holding [declaractions].
|
||||
|
||||
* FIXED: NUMBER attribute declaration with default (skip layout afterwards)
|
||||
|
||||
* ADDED: Support for NOTATION attribute
|
||||
|
||||
* FIXED: memory allocation/free bug in model-reduction ((a|b)*)
|
||||
|
||||
* ADDED: Passing processing instructions to the user
|
||||
|
||||
* FIXED: Independent case-sensitivity switch for entities (SGML entities are
|
||||
case sensitive).
|
||||
|
||||
* ADDED: SGML Blank-space handling
|
||||
|
||||
* FIXED: Completeness test for A&B?
|
||||
|
||||
* ADDED: Dummy make check (Richard O'Keefe)
|
||||
|
||||
|
||||
VERSION 1.0.1
|
||||
=============
|
||||
|
||||
* ADDED: Programmable XML namespace canonisation.
|
||||
|
||||
* ADDED: White space handling using the xlm:space attribute as well as
|
||||
allow for setting the initial default as option to load_structure.
|
||||
|
||||
* FIXED: Allow for <!ENTITY name 'value'> (i.e. without CDATA type decl).
|
||||
|
||||
* FIXED: Allow for <!DOCTYPE name [DTD]> (i.e. no public nor system)
|
||||
|
||||
* FIXED: Avoid crash on bad attribute-list
|
||||
|
||||
* ADDED: Reporting errors and warnings through print_message/2.
|
||||
|
||||
* FIXED: Handling of end-of-file in CDATA
|
88
packages/sgml/DTD/HTML4.dcl
Normal file
88
packages/sgml/DTD/HTML4.dcl
Normal file
@ -0,0 +1,88 @@
|
||||
<!SGML "ISO 8879:1986 (WWW)"
|
||||
--
|
||||
SGML Declaration for HyperText Markup Language version 4.0
|
||||
|
||||
With support for the first 17 planes of ISO 10646 and
|
||||
increased limits for tag and literal lengths etc.
|
||||
|
||||
Modified by jjc to work around SP's 16-bit character limit.
|
||||
Modified by jjc to support hex character references.
|
||||
--
|
||||
|
||||
CHARSET
|
||||
BASESET "ISO Registration Number 177//CHARSET
|
||||
ISO/IEC 10646-1:1993 UCS-4 with
|
||||
implementation level 3//ESC 2/5 2/15 4/6"
|
||||
DESCSET 0 9 UNUSED
|
||||
9 2 9
|
||||
11 2 UNUSED
|
||||
13 1 13
|
||||
14 18 UNUSED
|
||||
32 95 32
|
||||
127 1 UNUSED
|
||||
128 32 UNUSED
|
||||
-- jjc: changed the rest of the DESCSET.
|
||||
Note that surrogates are not declared UNUSED;
|
||||
this allows non-BMP characters to be parsed. --
|
||||
160 65376 160
|
||||
-- 160 55136 160
|
||||
55296 2048 UNUSED
|
||||
57344 1056768 57344 --
|
||||
|
||||
CAPACITY SGMLREF
|
||||
TOTALCAP 150000
|
||||
GRPCAP 150000
|
||||
ENTCAP 150000
|
||||
|
||||
SCOPE DOCUMENT
|
||||
SYNTAX
|
||||
SHUNCHAR CONTROLS 0 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 127
|
||||
BASESET "ISO 646IRV:1991//CHARSET
|
||||
International Reference Version
|
||||
(IRV)//ESC 2/8 4/2"
|
||||
DESCSET 0 128 0
|
||||
|
||||
FUNCTION
|
||||
RE 13
|
||||
RS 10
|
||||
SPACE 32
|
||||
TAB SEPCHAR 9
|
||||
|
||||
NAMING LCNMSTRT ""
|
||||
UCNMSTRT ""
|
||||
LCNMCHAR ".-_:"
|
||||
UCNMCHAR ".-_:"
|
||||
NAMECASE GENERAL YES
|
||||
ENTITY NO
|
||||
DELIM GENERAL SGMLREF
|
||||
HCRO "&#X" -- added by jjc --
|
||||
SHORTREF SGMLREF
|
||||
NAMES SGMLREF
|
||||
QUANTITY SGMLREF
|
||||
ATTCNT 60 -- increased --
|
||||
ATTSPLEN 65536 -- These are the largest values --
|
||||
LITLEN 65536 -- permitted in the declaration --
|
||||
NAMELEN 65536 -- Avoid fixed limits in actual --
|
||||
PILEN 65536 -- implementations of HTML UA's --
|
||||
TAGLVL 100
|
||||
TAGLEN 65536
|
||||
GRPGTCNT 150
|
||||
GRPCNT 64
|
||||
|
||||
FEATURES
|
||||
MINIMIZE
|
||||
DATATAG NO
|
||||
OMITTAG YES
|
||||
RANK NO
|
||||
SHORTTAG YES
|
||||
LINK
|
||||
SIMPLE NO
|
||||
IMPLICIT NO
|
||||
EXPLICIT NO
|
||||
OTHER
|
||||
CONCUR NO
|
||||
SUBDOC NO
|
||||
FORMAL YES
|
||||
APPINFO NONE
|
||||
>
|
1092
packages/sgml/DTD/HTML4.dtd
Normal file
1092
packages/sgml/DTD/HTML4.dtd
Normal file
File diff suppressed because it is too large
Load Diff
6
packages/sgml/DTD/HTML4.soc
Normal file
6
packages/sgml/DTD/HTML4.soc
Normal file
@ -0,0 +1,6 @@
|
||||
OVERRIDE YES
|
||||
SGMLDECL HTML4.dcl
|
||||
DOCTYPE HTML HTML4.dtd
|
||||
PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML" HTMLlat1.ent
|
||||
PUBLIC "-//W3C//ENTITIES Special//EN//HTML" HTMLspec.ent
|
||||
PUBLIC "-//W3C//ENTITIES Symbols//EN//HTML" HTMLsym.ent
|
195
packages/sgml/DTD/HTMLlat1.ent
Normal file
195
packages/sgml/DTD/HTMLlat1.ent
Normal file
@ -0,0 +1,195 @@
|
||||
<!-- Portions (C) International Organization for Standardization 1986
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Full Latin 1//EN//HTML">
|
||||
%HTMLlat1;
|
||||
-->
|
||||
|
||||
<!ENTITY nbsp CDATA " " -- no-break space = non-breaking space,
|
||||
U+00A0 ISOnum -->
|
||||
<!ENTITY iexcl CDATA "¡" -- inverted exclamation mark, U+00A1 ISOnum -->
|
||||
<!ENTITY cent CDATA "¢" -- cent sign, U+00A2 ISOnum -->
|
||||
<!ENTITY pound CDATA "£" -- pound sign, U+00A3 ISOnum -->
|
||||
<!ENTITY curren CDATA "¤" -- currency sign, U+00A4 ISOnum -->
|
||||
<!ENTITY yen CDATA "¥" -- yen sign = yuan sign, U+00A5 ISOnum -->
|
||||
<!ENTITY brvbar CDATA "¦" -- broken bar = broken vertical bar,
|
||||
U+00A6 ISOnum -->
|
||||
<!ENTITY sect CDATA "§" -- section sign, U+00A7 ISOnum -->
|
||||
<!ENTITY uml CDATA "¨" -- diaeresis = spacing diaeresis,
|
||||
U+00A8 ISOdia -->
|
||||
<!ENTITY copy CDATA "©" -- copyright sign, U+00A9 ISOnum -->
|
||||
<!ENTITY ordf CDATA "ª" -- feminine ordinal indicator, U+00AA ISOnum -->
|
||||
<!ENTITY laquo CDATA "«" -- left-pointing double angle quotation mark
|
||||
= left pointing guillemet, U+00AB ISOnum -->
|
||||
<!ENTITY not CDATA "¬" -- not sign = discretionary hyphen,
|
||||
U+00AC ISOnum -->
|
||||
<!ENTITY shy CDATA "­" -- soft hyphen = discretionary hyphen,
|
||||
U+00AD ISOnum -->
|
||||
<!ENTITY reg CDATA "®" -- registered sign = registered trade mark sign,
|
||||
U+00AE ISOnum -->
|
||||
<!ENTITY macr CDATA "¯" -- macron = spacing macron = overline
|
||||
= APL overbar, U+00AF ISOdia -->
|
||||
<!ENTITY deg CDATA "°" -- degree sign, U+00B0 ISOnum -->
|
||||
<!ENTITY plusmn CDATA "±" -- plus-minus sign = plus-or-minus sign,
|
||||
U+00B1 ISOnum -->
|
||||
<!ENTITY sup2 CDATA "²" -- superscript two = superscript digit two
|
||||
= squared, U+00B2 ISOnum -->
|
||||
<!ENTITY sup3 CDATA "³" -- superscript three = superscript digit three
|
||||
= cubed, U+00B3 ISOnum -->
|
||||
<!ENTITY acute CDATA "´" -- acute accent = spacing acute,
|
||||
U+00B4 ISOdia -->
|
||||
<!ENTITY micro CDATA "µ" -- micro sign, U+00B5 ISOnum -->
|
||||
<!ENTITY para CDATA "¶" -- pilcrow sign = paragraph sign,
|
||||
U+00B6 ISOnum -->
|
||||
<!ENTITY middot CDATA "·" -- middle dot = Georgian comma
|
||||
= Greek middle dot, U+00B7 ISOnum -->
|
||||
<!ENTITY cedil CDATA "¸" -- cedilla = spacing cedilla, U+00B8 ISOdia -->
|
||||
<!ENTITY sup1 CDATA "¹" -- superscript one = superscript digit one,
|
||||
U+00B9 ISOnum -->
|
||||
<!ENTITY ordm CDATA "º" -- masculine ordinal indicator,
|
||||
U+00BA ISOnum -->
|
||||
<!ENTITY raquo CDATA "»" -- right-pointing double angle quotation mark
|
||||
= right pointing guillemet, U+00BB ISOnum -->
|
||||
<!ENTITY frac14 CDATA "¼" -- vulgar fraction one quarter
|
||||
= fraction one quarter, U+00BC ISOnum -->
|
||||
<!ENTITY frac12 CDATA "½" -- vulgar fraction one half
|
||||
= fraction one half, U+00BD ISOnum -->
|
||||
<!ENTITY frac34 CDATA "¾" -- vulgar fraction three quarters
|
||||
= fraction three quarters, U+00BE ISOnum -->
|
||||
<!ENTITY iquest CDATA "¿" -- inverted question mark
|
||||
= turned question mark, U+00BF ISOnum -->
|
||||
<!ENTITY Agrave CDATA "À" -- latin capital letter A with grave
|
||||
= latin capital letter A grave,
|
||||
U+00C0 ISOlat1 -->
|
||||
<!ENTITY Aacute CDATA "Á" -- latin capital letter A with acute,
|
||||
U+00C1 ISOlat1 -->
|
||||
<!ENTITY Acirc CDATA "Â" -- latin capital letter A with circumflex,
|
||||
U+00C2 ISOlat1 -->
|
||||
<!ENTITY Atilde CDATA "Ã" -- latin capital letter A with tilde,
|
||||
U+00C3 ISOlat1 -->
|
||||
<!ENTITY Auml CDATA "Ä" -- latin capital letter A with diaeresis,
|
||||
U+00C4 ISOlat1 -->
|
||||
<!ENTITY Aring CDATA "Å" -- latin capital letter A with ring above
|
||||
= latin capital letter A ring,
|
||||
U+00C5 ISOlat1 -->
|
||||
<!ENTITY AElig CDATA "Æ" -- latin capital letter AE
|
||||
= latin capital ligature AE,
|
||||
U+00C6 ISOlat1 -->
|
||||
<!ENTITY Ccedil CDATA "Ç" -- latin capital letter C with cedilla,
|
||||
U+00C7 ISOlat1 -->
|
||||
<!ENTITY Egrave CDATA "È" -- latin capital letter E with grave,
|
||||
U+00C8 ISOlat1 -->
|
||||
<!ENTITY Eacute CDATA "É" -- latin capital letter E with acute,
|
||||
U+00C9 ISOlat1 -->
|
||||
<!ENTITY Ecirc CDATA "Ê" -- latin capital letter E with circumflex,
|
||||
U+00CA ISOlat1 -->
|
||||
<!ENTITY Euml CDATA "Ë" -- latin capital letter E with diaeresis,
|
||||
U+00CB ISOlat1 -->
|
||||
<!ENTITY Igrave CDATA "Ì" -- latin capital letter I with grave,
|
||||
U+00CC ISOlat1 -->
|
||||
<!ENTITY Iacute CDATA "Í" -- latin capital letter I with acute,
|
||||
U+00CD ISOlat1 -->
|
||||
<!ENTITY Icirc CDATA "Î" -- latin capital letter I with circumflex,
|
||||
U+00CE ISOlat1 -->
|
||||
<!ENTITY Iuml CDATA "Ï" -- latin capital letter I with diaeresis,
|
||||
U+00CF ISOlat1 -->
|
||||
<!ENTITY ETH CDATA "Ð" -- latin capital letter ETH, U+00D0 ISOlat1 -->
|
||||
<!ENTITY Ntilde CDATA "Ñ" -- latin capital letter N with tilde,
|
||||
U+00D1 ISOlat1 -->
|
||||
<!ENTITY Ograve CDATA "Ò" -- latin capital letter O with grave,
|
||||
U+00D2 ISOlat1 -->
|
||||
<!ENTITY Oacute CDATA "Ó" -- latin capital letter O with acute,
|
||||
U+00D3 ISOlat1 -->
|
||||
<!ENTITY Ocirc CDATA "Ô" -- latin capital letter O with circumflex,
|
||||
U+00D4 ISOlat1 -->
|
||||
<!ENTITY Otilde CDATA "Õ" -- latin capital letter O with tilde,
|
||||
U+00D5 ISOlat1 -->
|
||||
<!ENTITY Ouml CDATA "Ö" -- latin capital letter O with diaeresis,
|
||||
U+00D6 ISOlat1 -->
|
||||
<!ENTITY times CDATA "×" -- multiplication sign, U+00D7 ISOnum -->
|
||||
<!ENTITY Oslash CDATA "Ø" -- latin capital letter O with stroke
|
||||
= latin capital letter O slash,
|
||||
U+00D8 ISOlat1 -->
|
||||
<!ENTITY Ugrave CDATA "Ù" -- latin capital letter U with grave,
|
||||
U+00D9 ISOlat1 -->
|
||||
<!ENTITY Uacute CDATA "Ú" -- latin capital letter U with acute,
|
||||
U+00DA ISOlat1 -->
|
||||
<!ENTITY Ucirc CDATA "Û" -- latin capital letter U with circumflex,
|
||||
U+00DB ISOlat1 -->
|
||||
<!ENTITY Uuml CDATA "Ü" -- latin capital letter U with diaeresis,
|
||||
U+00DC ISOlat1 -->
|
||||
<!ENTITY Yacute CDATA "Ý" -- latin capital letter Y with acute,
|
||||
U+00DD ISOlat1 -->
|
||||
<!ENTITY THORN CDATA "Þ" -- latin capital letter THORN,
|
||||
U+00DE ISOlat1 -->
|
||||
<!ENTITY szlig CDATA "ß" -- latin small letter sharp s = ess-zed,
|
||||
U+00DF ISOlat1 -->
|
||||
<!ENTITY agrave CDATA "à" -- latin small letter a with grave
|
||||
= latin small letter a grave,
|
||||
U+00E0 ISOlat1 -->
|
||||
<!ENTITY aacute CDATA "á" -- latin small letter a with acute,
|
||||
U+00E1 ISOlat1 -->
|
||||
<!ENTITY acirc CDATA "â" -- latin small letter a with circumflex,
|
||||
U+00E2 ISOlat1 -->
|
||||
<!ENTITY atilde CDATA "ã" -- latin small letter a with tilde,
|
||||
U+00E3 ISOlat1 -->
|
||||
<!ENTITY auml CDATA "ä" -- latin small letter a with diaeresis,
|
||||
U+00E4 ISOlat1 -->
|
||||
<!ENTITY aring CDATA "å" -- latin small letter a with ring above
|
||||
= latin small letter a ring,
|
||||
U+00E5 ISOlat1 -->
|
||||
<!ENTITY aelig CDATA "æ" -- latin small letter ae
|
||||
= latin small ligature ae, U+00E6 ISOlat1 -->
|
||||
<!ENTITY ccedil CDATA "ç" -- latin small letter c with cedilla,
|
||||
U+00E7 ISOlat1 -->
|
||||
<!ENTITY egrave CDATA "è" -- latin small letter e with grave,
|
||||
U+00E8 ISOlat1 -->
|
||||
<!ENTITY eacute CDATA "é" -- latin small letter e with acute,
|
||||
U+00E9 ISOlat1 -->
|
||||
<!ENTITY ecirc CDATA "ê" -- latin small letter e with circumflex,
|
||||
U+00EA ISOlat1 -->
|
||||
<!ENTITY euml CDATA "ë" -- latin small letter e with diaeresis,
|
||||
U+00EB ISOlat1 -->
|
||||
<!ENTITY igrave CDATA "ì" -- latin small letter i with grave,
|
||||
U+00EC ISOlat1 -->
|
||||
<!ENTITY iacute CDATA "í" -- latin small letter i with acute,
|
||||
U+00ED ISOlat1 -->
|
||||
<!ENTITY icirc CDATA "î" -- latin small letter i with circumflex,
|
||||
U+00EE ISOlat1 -->
|
||||
<!ENTITY iuml CDATA "ï" -- latin small letter i with diaeresis,
|
||||
U+00EF ISOlat1 -->
|
||||
<!ENTITY eth CDATA "ð" -- latin small letter eth, U+00F0 ISOlat1 -->
|
||||
<!ENTITY ntilde CDATA "ñ" -- latin small letter n with tilde,
|
||||
U+00F1 ISOlat1 -->
|
||||
<!ENTITY ograve CDATA "ò" -- latin small letter o with grave,
|
||||
U+00F2 ISOlat1 -->
|
||||
<!ENTITY oacute CDATA "ó" -- latin small letter o with acute,
|
||||
U+00F3 ISOlat1 -->
|
||||
<!ENTITY ocirc CDATA "ô" -- latin small letter o with circumflex,
|
||||
U+00F4 ISOlat1 -->
|
||||
<!ENTITY otilde CDATA "õ" -- latin small letter o with tilde,
|
||||
U+00F5 ISOlat1 -->
|
||||
<!ENTITY ouml CDATA "ö" -- latin small letter o with diaeresis,
|
||||
U+00F6 ISOlat1 -->
|
||||
<!ENTITY divide CDATA "÷" -- division sign, U+00F7 ISOnum -->
|
||||
<!ENTITY oslash CDATA "ø" -- latin small letter o with stroke,
|
||||
= latin small letter o slash,
|
||||
U+00F8 ISOlat1 -->
|
||||
<!ENTITY ugrave CDATA "ù" -- latin small letter u with grave,
|
||||
U+00F9 ISOlat1 -->
|
||||
<!ENTITY uacute CDATA "ú" -- latin small letter u with acute,
|
||||
U+00FA ISOlat1 -->
|
||||
<!ENTITY ucirc CDATA "û" -- latin small letter u with circumflex,
|
||||
U+00FB ISOlat1 -->
|
||||
<!ENTITY uuml CDATA "ü" -- latin small letter u with diaeresis,
|
||||
U+00FC ISOlat1 -->
|
||||
<!ENTITY yacute CDATA "ý" -- latin small letter y with acute,
|
||||
U+00FD ISOlat1 -->
|
||||
<!ENTITY thorn CDATA "þ" -- latin small letter thorn with,
|
||||
U+00FE ISOlat1 -->
|
||||
<!ENTITY yuml CDATA "ÿ" -- latin small letter y with diaeresis,
|
||||
U+00FF ISOlat1 -->
|
77
packages/sgml/DTD/HTMLspec.ent
Normal file
77
packages/sgml/DTD/HTMLspec.ent
Normal file
@ -0,0 +1,77 @@
|
||||
<!-- Special characters for HTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special//EN//HTML">
|
||||
%HTMLspecial; -->
|
||||
|
||||
<!-- Portions (C) International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. CDATA values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are Unicode 2.0 names.
|
||||
|
||||
-->
|
||||
|
||||
<!-- C0 Controls and Basic Latin -->
|
||||
<!ENTITY quot CDATA """ -- quotation mark = APL quote,
|
||||
U+0022 ISOnum -->
|
||||
<!ENTITY amp CDATA "&" -- ampersand, U+0026 ISOnum -->
|
||||
<!ENTITY lt CDATA "<" -- less-than sign, U+003C ISOnum -->
|
||||
<!ENTITY gt CDATA ">" -- greater-than sign, U+003E ISOnum -->
|
||||
|
||||
<!-- Latin Extended-A -->
|
||||
<!ENTITY OElig CDATA "Œ" -- latin capital ligature OE,
|
||||
U+0152 ISOlat2 -->
|
||||
<!ENTITY oelig CDATA "œ" -- latin small ligature oe, U+0153 ISOlat2 -->
|
||||
<!-- ligature is a misnomer, this is a separate character in some languages -->
|
||||
<!ENTITY Scaron CDATA "Š" -- latin capital letter S with caron,
|
||||
U+0160 ISOlat2 -->
|
||||
<!ENTITY scaron CDATA "š" -- latin small letter s with caron,
|
||||
U+0161 ISOlat2 -->
|
||||
<!ENTITY Yuml CDATA "Ÿ" -- latin capital letter Y with diaeresis,
|
||||
U+0178 ISOlat2 -->
|
||||
|
||||
<!-- Spacing Modifier Letters -->
|
||||
<!ENTITY circ CDATA "ˆ" -- modifier letter circumflex accent,
|
||||
U+02C6 ISOpub -->
|
||||
<!ENTITY tilde CDATA "˜" -- small tilde, U+02DC ISOdia -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY ensp CDATA " " -- en space, U+2002 ISOpub -->
|
||||
<!ENTITY emsp CDATA " " -- em space, U+2003 ISOpub -->
|
||||
<!ENTITY thinsp CDATA " " -- thin space, U+2009 ISOpub -->
|
||||
<!ENTITY zwnj CDATA "‌" -- zero width non-joiner,
|
||||
U+200C NEW RFC 2070 -->
|
||||
<!ENTITY zwj CDATA "‍" -- zero width joiner, U+200D NEW RFC 2070 -->
|
||||
<!ENTITY lrm CDATA "‎" -- left-to-right mark, U+200E NEW RFC 2070 -->
|
||||
<!ENTITY rlm CDATA "‏" -- right-to-left mark, U+200F NEW RFC 2070 -->
|
||||
<!ENTITY ndash CDATA "–" -- en dash, U+2013 ISOpub -->
|
||||
<!ENTITY mdash CDATA "—" -- em dash, U+2014 ISOpub -->
|
||||
<!ENTITY lsquo CDATA "‘" -- left single quotation mark,
|
||||
U+2018 ISOnum -->
|
||||
<!ENTITY rsquo CDATA "’" -- right single quotation mark,
|
||||
U+2019 ISOnum -->
|
||||
<!ENTITY sbquo CDATA "‚" -- single low-9 quotation mark, U+201A NEW -->
|
||||
<!ENTITY ldquo CDATA "“" -- left double quotation mark,
|
||||
U+201C ISOnum -->
|
||||
<!ENTITY rdquo CDATA "”" -- right double quotation mark,
|
||||
U+201D ISOnum -->
|
||||
<!ENTITY bdquo CDATA "„" -- double low-9 quotation mark, U+201E NEW -->
|
||||
<!ENTITY dagger CDATA "†" -- dagger, U+2020 ISOpub -->
|
||||
<!ENTITY Dagger CDATA "‡" -- double dagger, U+2021 ISOpub -->
|
||||
<!ENTITY permil CDATA "‰" -- per mille sign, U+2030 ISOtech -->
|
||||
<!ENTITY lsaquo CDATA "‹" -- single left-pointing angle quotation mark,
|
||||
U+2039 ISO proposed -->
|
||||
<!-- lsaquo is proposed but not yet ISO standardized -->
|
||||
<!ENTITY rsaquo CDATA "›" -- single right-pointing angle quotation mark,
|
||||
U+203A ISO proposed -->
|
||||
<!-- rsaquo is proposed but not yet ISO standardized -->
|
||||
<!ENTITY euro CDATA "€" -- euro sign, U+20AC NEW -->
|
241
packages/sgml/DTD/HTMLsym.ent
Normal file
241
packages/sgml/DTD/HTMLsym.ent
Normal file
@ -0,0 +1,241 @@
|
||||
<!-- Mathematical, Greek and Symbolic characters for HTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbolic//EN//HTML">
|
||||
%HTMLsymbol; -->
|
||||
|
||||
<!-- Portions (C) International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. CDATA values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are Unicode 2.0 names.
|
||||
|
||||
-->
|
||||
|
||||
<!-- Latin Extended-B -->
|
||||
<!ENTITY fnof CDATA "ƒ" -- latin small f with hook = function
|
||||
= florin, U+0192 ISOtech -->
|
||||
|
||||
<!-- Greek -->
|
||||
<!ENTITY Alpha CDATA "Α" -- greek capital letter alpha, U+0391 -->
|
||||
<!ENTITY Beta CDATA "Β" -- greek capital letter beta, U+0392 -->
|
||||
<!ENTITY Gamma CDATA "Γ" -- greek capital letter gamma,
|
||||
U+0393 ISOgrk3 -->
|
||||
<!ENTITY Delta CDATA "Δ" -- greek capital letter delta,
|
||||
U+0394 ISOgrk3 -->
|
||||
<!ENTITY Epsilon CDATA "Ε" -- greek capital letter epsilon, U+0395 -->
|
||||
<!ENTITY Zeta CDATA "Ζ" -- greek capital letter zeta, U+0396 -->
|
||||
<!ENTITY Eta CDATA "Η" -- greek capital letter eta, U+0397 -->
|
||||
<!ENTITY Theta CDATA "Θ" -- greek capital letter theta,
|
||||
U+0398 ISOgrk3 -->
|
||||
<!ENTITY Iota CDATA "Ι" -- greek capital letter iota, U+0399 -->
|
||||
<!ENTITY Kappa CDATA "Κ" -- greek capital letter kappa, U+039A -->
|
||||
<!ENTITY Lambda CDATA "Λ" -- greek capital letter lambda,
|
||||
U+039B ISOgrk3 -->
|
||||
<!ENTITY Mu CDATA "Μ" -- greek capital letter mu, U+039C -->
|
||||
<!ENTITY Nu CDATA "Ν" -- greek capital letter nu, U+039D -->
|
||||
<!ENTITY Xi CDATA "Ξ" -- greek capital letter xi, U+039E ISOgrk3 -->
|
||||
<!ENTITY Omicron CDATA "Ο" -- greek capital letter omicron, U+039F -->
|
||||
<!ENTITY Pi CDATA "Π" -- greek capital letter pi, U+03A0 ISOgrk3 -->
|
||||
<!ENTITY Rho CDATA "Ρ" -- greek capital letter rho, U+03A1 -->
|
||||
<!-- there is no Sigmaf, and no U+03A2 character either -->
|
||||
<!ENTITY Sigma CDATA "Σ" -- greek capital letter sigma,
|
||||
U+03A3 ISOgrk3 -->
|
||||
<!ENTITY Tau CDATA "Τ" -- greek capital letter tau, U+03A4 -->
|
||||
<!ENTITY Upsilon CDATA "Υ" -- greek capital letter upsilon,
|
||||
U+03A5 ISOgrk3 -->
|
||||
<!ENTITY Phi CDATA "Φ" -- greek capital letter phi,
|
||||
U+03A6 ISOgrk3 -->
|
||||
<!ENTITY Chi CDATA "Χ" -- greek capital letter chi, U+03A7 -->
|
||||
<!ENTITY Psi CDATA "Ψ" -- greek capital letter psi,
|
||||
U+03A8 ISOgrk3 -->
|
||||
<!ENTITY Omega CDATA "Ω" -- greek capital letter omega,
|
||||
U+03A9 ISOgrk3 -->
|
||||
|
||||
<!ENTITY alpha CDATA "α" -- greek small letter alpha,
|
||||
U+03B1 ISOgrk3 -->
|
||||
<!ENTITY beta CDATA "β" -- greek small letter beta, U+03B2 ISOgrk3 -->
|
||||
<!ENTITY gamma CDATA "γ" -- greek small letter gamma,
|
||||
U+03B3 ISOgrk3 -->
|
||||
<!ENTITY delta CDATA "δ" -- greek small letter delta,
|
||||
U+03B4 ISOgrk3 -->
|
||||
<!ENTITY epsilon CDATA "ε" -- greek small letter epsilon,
|
||||
U+03B5 ISOgrk3 -->
|
||||
<!ENTITY zeta CDATA "ζ" -- greek small letter zeta, U+03B6 ISOgrk3 -->
|
||||
<!ENTITY eta CDATA "η" -- greek small letter eta, U+03B7 ISOgrk3 -->
|
||||
<!ENTITY theta CDATA "θ" -- greek small letter theta,
|
||||
U+03B8 ISOgrk3 -->
|
||||
<!ENTITY iota CDATA "ι" -- greek small letter iota, U+03B9 ISOgrk3 -->
|
||||
<!ENTITY kappa CDATA "κ" -- greek small letter kappa,
|
||||
U+03BA ISOgrk3 -->
|
||||
<!ENTITY lambda CDATA "λ" -- greek small letter lambda,
|
||||
U+03BB ISOgrk3 -->
|
||||
<!ENTITY mu CDATA "μ" -- greek small letter mu, U+03BC ISOgrk3 -->
|
||||
<!ENTITY nu CDATA "ν" -- greek small letter nu, U+03BD ISOgrk3 -->
|
||||
<!ENTITY xi CDATA "ξ" -- greek small letter xi, U+03BE ISOgrk3 -->
|
||||
<!ENTITY omicron CDATA "ο" -- greek small letter omicron, U+03BF NEW -->
|
||||
<!ENTITY pi CDATA "π" -- greek small letter pi, U+03C0 ISOgrk3 -->
|
||||
<!ENTITY rho CDATA "ρ" -- greek small letter rho, U+03C1 ISOgrk3 -->
|
||||
<!ENTITY sigmaf CDATA "ς" -- greek small letter final sigma,
|
||||
U+03C2 ISOgrk3 -->
|
||||
<!ENTITY sigma CDATA "σ" -- greek small letter sigma,
|
||||
U+03C3 ISOgrk3 -->
|
||||
<!ENTITY tau CDATA "τ" -- greek small letter tau, U+03C4 ISOgrk3 -->
|
||||
<!ENTITY upsilon CDATA "υ" -- greek small letter upsilon,
|
||||
U+03C5 ISOgrk3 -->
|
||||
<!ENTITY phi CDATA "φ" -- greek small letter phi, U+03C6 ISOgrk3 -->
|
||||
<!ENTITY chi CDATA "χ" -- greek small letter chi, U+03C7 ISOgrk3 -->
|
||||
<!ENTITY psi CDATA "ψ" -- greek small letter psi, U+03C8 ISOgrk3 -->
|
||||
<!ENTITY omega CDATA "ω" -- greek small letter omega,
|
||||
U+03C9 ISOgrk3 -->
|
||||
<!ENTITY thetasym CDATA "ϑ" -- greek small letter theta symbol,
|
||||
U+03D1 NEW -->
|
||||
<!ENTITY upsih CDATA "ϒ" -- greek upsilon with hook symbol,
|
||||
U+03D2 NEW -->
|
||||
<!ENTITY piv CDATA "ϖ" -- greek pi symbol, U+03D6 ISOgrk3 -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY bull CDATA "•" -- bullet = black small circle,
|
||||
U+2022 ISOpub -->
|
||||
<!-- bullet is NOT the same as bullet operator, U+2219 -->
|
||||
<!ENTITY hellip CDATA "…" -- horizontal ellipsis = three dot leader,
|
||||
U+2026 ISOpub -->
|
||||
<!ENTITY prime CDATA "′" -- prime = minutes = feet, U+2032 ISOtech -->
|
||||
<!ENTITY Prime CDATA "″" -- double prime = seconds = inches,
|
||||
U+2033 ISOtech -->
|
||||
<!ENTITY oline CDATA "‾" -- overline = spacing overscore,
|
||||
U+203E NEW -->
|
||||
<!ENTITY frasl CDATA "⁄" -- fraction slash, U+2044 NEW -->
|
||||
|
||||
<!-- Letterlike Symbols -->
|
||||
<!ENTITY weierp CDATA "℘" -- script capital P = power set
|
||||
= Weierstrass p, U+2118 ISOamso -->
|
||||
<!ENTITY image CDATA "ℑ" -- blackletter capital I = imaginary part,
|
||||
U+2111 ISOamso -->
|
||||
<!ENTITY real CDATA "ℜ" -- blackletter capital R = real part symbol,
|
||||
U+211C ISOamso -->
|
||||
<!ENTITY trade CDATA "™" -- trade mark sign, U+2122 ISOnum -->
|
||||
<!ENTITY alefsym CDATA "ℵ" -- alef symbol = first transfinite cardinal,
|
||||
U+2135 NEW -->
|
||||
<!-- alef symbol is NOT the same as hebrew letter alef,
|
||||
U+05D0 although the same glyph could be used to depict both characters -->
|
||||
|
||||
<!-- Arrows -->
|
||||
<!ENTITY larr CDATA "←" -- leftwards arrow, U+2190 ISOnum -->
|
||||
<!ENTITY uarr CDATA "↑" -- upwards arrow, U+2191 ISOnum-->
|
||||
<!ENTITY rarr CDATA "→" -- rightwards arrow, U+2192 ISOnum -->
|
||||
<!ENTITY darr CDATA "↓" -- downwards arrow, U+2193 ISOnum -->
|
||||
<!ENTITY harr CDATA "↔" -- left right arrow, U+2194 ISOamsa -->
|
||||
<!ENTITY crarr CDATA "↵" -- downwards arrow with corner leftwards
|
||||
= carriage return, U+21B5 NEW -->
|
||||
<!ENTITY lArr CDATA "⇐" -- leftwards double arrow, U+21D0 ISOtech -->
|
||||
<!-- Unicode does not say that lArr is the same as the 'is implied by' arrow
|
||||
but also does not have any other character for that function. So ? lArr can
|
||||
be used for 'is implied by' as ISOtech suggests -->
|
||||
<!ENTITY uArr CDATA "⇑" -- upwards double arrow, U+21D1 ISOamsa -->
|
||||
<!ENTITY rArr CDATA "⇒" -- rightwards double arrow,
|
||||
U+21D2 ISOtech -->
|
||||
<!-- Unicode does not say this is the 'implies' character but does not have
|
||||
another character with this function so ?
|
||||
rArr can be used for 'implies' as ISOtech suggests -->
|
||||
<!ENTITY dArr CDATA "⇓" -- downwards double arrow, U+21D3 ISOamsa -->
|
||||
<!ENTITY hArr CDATA "⇔" -- left right double arrow,
|
||||
U+21D4 ISOamsa -->
|
||||
|
||||
<!-- Mathematical Operators -->
|
||||
<!ENTITY forall CDATA "∀" -- for all, U+2200 ISOtech -->
|
||||
<!ENTITY part CDATA "∂" -- partial differential, U+2202 ISOtech -->
|
||||
<!ENTITY exist CDATA "∃" -- there exists, U+2203 ISOtech -->
|
||||
<!ENTITY empty CDATA "∅" -- empty set = null set = diameter,
|
||||
U+2205 ISOamso -->
|
||||
<!ENTITY nabla CDATA "∇" -- nabla = backward difference,
|
||||
U+2207 ISOtech -->
|
||||
<!ENTITY isin CDATA "∈" -- element of, U+2208 ISOtech -->
|
||||
<!ENTITY notin CDATA "∉" -- not an element of, U+2209 ISOtech -->
|
||||
<!ENTITY ni CDATA "∋" -- contains as member, U+220B ISOtech -->
|
||||
<!-- should there be a more memorable name than 'ni'? -->
|
||||
<!ENTITY prod CDATA "∏" -- n-ary product = product sign,
|
||||
U+220F ISOamsb -->
|
||||
<!-- prod is NOT the same character as U+03A0 'greek capital letter pi' though
|
||||
the same glyph might be used for both -->
|
||||
<!ENTITY sum CDATA "∑" -- n-ary sumation, U+2211 ISOamsb -->
|
||||
<!-- sum is NOT the same character as U+03A3 'greek capital letter sigma'
|
||||
though the same glyph might be used for both -->
|
||||
<!ENTITY minus CDATA "−" -- minus sign, U+2212 ISOtech -->
|
||||
<!ENTITY lowast CDATA "∗" -- asterisk operator, U+2217 ISOtech -->
|
||||
<!ENTITY radic CDATA "√" -- square root = radical sign,
|
||||
U+221A ISOtech -->
|
||||
<!ENTITY prop CDATA "∝" -- proportional to, U+221D ISOtech -->
|
||||
<!ENTITY infin CDATA "∞" -- infinity, U+221E ISOtech -->
|
||||
<!ENTITY ang CDATA "∠" -- angle, U+2220 ISOamso -->
|
||||
<!ENTITY and CDATA "∧" -- logical and = wedge, U+2227 ISOtech -->
|
||||
<!ENTITY or CDATA "∨" -- logical or = vee, U+2228 ISOtech -->
|
||||
<!ENTITY cap CDATA "∩" -- intersection = cap, U+2229 ISOtech -->
|
||||
<!ENTITY cup CDATA "∪" -- union = cup, U+222A ISOtech -->
|
||||
<!ENTITY int CDATA "∫" -- integral, U+222B ISOtech -->
|
||||
<!ENTITY there4 CDATA "∴" -- therefore, U+2234 ISOtech -->
|
||||
<!ENTITY sim CDATA "∼" -- tilde operator = varies with = similar to,
|
||||
U+223C ISOtech -->
|
||||
<!-- tilde operator is NOT the same character as the tilde, U+007E,
|
||||
although the same glyph might be used to represent both -->
|
||||
<!ENTITY cong CDATA "≅" -- approximately equal to, U+2245 ISOtech -->
|
||||
<!ENTITY asymp CDATA "≈" -- almost equal to = asymptotic to,
|
||||
U+2248 ISOamsr -->
|
||||
<!ENTITY ne CDATA "≠" -- not equal to, U+2260 ISOtech -->
|
||||
<!ENTITY equiv CDATA "≡" -- identical to, U+2261 ISOtech -->
|
||||
<!ENTITY le CDATA "≤" -- less-than or equal to, U+2264 ISOtech -->
|
||||
<!ENTITY ge CDATA "≥" -- greater-than or equal to,
|
||||
U+2265 ISOtech -->
|
||||
<!ENTITY sub CDATA "⊂" -- subset of, U+2282 ISOtech -->
|
||||
<!ENTITY sup CDATA "⊃" -- superset of, U+2283 ISOtech -->
|
||||
<!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
|
||||
font encoding and is not included. Should it be, for symmetry?
|
||||
It is in ISOamsn -->
|
||||
<!ENTITY nsub CDATA "⊄" -- not a subset of, U+2284 ISOamsn -->
|
||||
<!ENTITY sube CDATA "⊆" -- subset of or equal to, U+2286 ISOtech -->
|
||||
<!ENTITY supe CDATA "⊇" -- superset of or equal to,
|
||||
U+2287 ISOtech -->
|
||||
<!ENTITY oplus CDATA "⊕" -- circled plus = direct sum,
|
||||
U+2295 ISOamsb -->
|
||||
<!ENTITY otimes CDATA "⊗" -- circled times = vector product,
|
||||
U+2297 ISOamsb -->
|
||||
<!ENTITY perp CDATA "⊥" -- up tack = orthogonal to = perpendicular,
|
||||
U+22A5 ISOtech -->
|
||||
<!ENTITY sdot CDATA "⋅" -- dot operator, U+22C5 ISOamsb -->
|
||||
<!-- dot operator is NOT the same character as U+00B7 middle dot -->
|
||||
|
||||
<!-- Miscellaneous Technical -->
|
||||
<!ENTITY lceil CDATA "⌈" -- left ceiling = apl upstile,
|
||||
U+2308 ISOamsc -->
|
||||
<!ENTITY rceil CDATA "⌉" -- right ceiling, U+2309 ISOamsc -->
|
||||
<!ENTITY lfloor CDATA "⌊" -- left floor = apl downstile,
|
||||
U+230A ISOamsc -->
|
||||
<!ENTITY rfloor CDATA "⌋" -- right floor, U+230B ISOamsc -->
|
||||
<!ENTITY lang CDATA "〈" -- left-pointing angle bracket = bra,
|
||||
U+2329 ISOtech -->
|
||||
<!-- lang is NOT the same character as U+003C 'less than'
|
||||
or U+2039 'single left-pointing angle quotation mark' -->
|
||||
<!ENTITY rang CDATA "〉" -- right-pointing angle bracket = ket,
|
||||
U+232A ISOtech -->
|
||||
<!-- rang is NOT the same character as U+003E 'greater than'
|
||||
or U+203A 'single right-pointing angle quotation mark' -->
|
||||
|
||||
<!-- Geometric Shapes -->
|
||||
<!ENTITY loz CDATA "◊" -- lozenge, U+25CA ISOpub -->
|
||||
|
||||
<!-- Miscellaneous Symbols -->
|
||||
<!ENTITY spades CDATA "♠" -- black spade suit, U+2660 ISOpub -->
|
||||
<!-- black here seems to mean filled as opposed to hollow -->
|
||||
<!ENTITY clubs CDATA "♣" -- black club suit = shamrock,
|
||||
U+2663 ISOpub -->
|
||||
<!ENTITY hearts CDATA "♥" -- black heart suit = valentine,
|
||||
U+2665 ISOpub -->
|
||||
<!ENTITY diams CDATA "♦" -- black diamond suit, U+2666 ISOpub -->
|
20
packages/sgml/FILES
Normal file
20
packages/sgml/FILES
Normal file
@ -0,0 +1,20 @@
|
||||
Files in the SGML/XML parser:
|
||||
|
||||
catalog.c Handle SGML_CATALOG_FILES
|
||||
catalog.h
|
||||
charmap.c Character classification and mapping
|
||||
dtd.h Include file for DTD primitives
|
||||
dtd2pl.c Main file for dtd2pl: convert DTD to Prolog
|
||||
error.c Utilities for generating Prolog exceptions
|
||||
error.h
|
||||
model.c State engine for handling DDT content model
|
||||
model.h
|
||||
parser.c The parser itself
|
||||
parser.h
|
||||
prolog.c Print DTD in Prolog source (used by dtd2pl)
|
||||
prolog.h
|
||||
sgml.c Main file for sgml (stand-alone parser)
|
||||
sgml2pl.c SWI-Prolog foreign code wrapper
|
||||
sgmldefs.h General definitions
|
||||
util.c Basic character handling and utilities
|
||||
util.h
|
167
packages/sgml/INSTALL
Normal file
167
packages/sgml/INSTALL
Normal file
@ -0,0 +1,167 @@
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, and a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure').
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source directory by typing `make clean'. To also remove the files
|
||||
that `configure' created (so you can compile the package for a
|
||||
different kind of computer), type `make distclean'.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Using a Different Build Directory
|
||||
=================================
|
||||
|
||||
You can compile the package in a different directory from the one
|
||||
containing the source code. Doing so allows you to compile it on more
|
||||
than one kind of computer at the same time. To do this, you must use a
|
||||
version of `make' that supports the `VPATH' variable, such as GNU
|
||||
`make'. `cd' to the directory where you want the object files and
|
||||
executables to go and run the `configure' script. `configure'
|
||||
automatically checks for the source code in the directory that
|
||||
`configure' is in and in `..'.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Save the results of the tests in FILE instead of `config.cache'.
|
||||
Set FILE to `/dev/null' to disable caching, for debugging
|
||||
`configure'.
|
||||
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made.
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
220
packages/sgml/Makefile.in
Normal file
220
packages/sgml/Makefile.in
Normal file
@ -0,0 +1,220 @@
|
||||
################################################################
|
||||
# SWI-Prolog `sgml2pl' package
|
||||
# Author: Jan Wielemaker. jan@swi.psy.uva.nl
|
||||
# Copyright: LGPL (see COPYING or www.gnu.org
|
||||
################################################################
|
||||
|
||||
.SUFFIXES: .tex .dvi .doc .pl
|
||||
|
||||
ifeq (@PROLOG_SYSTEM@,yap)
|
||||
|
||||
prefix = @prefix@
|
||||
ROOTDIR = $(prefix)
|
||||
EROOTDIR = @exec_prefix@
|
||||
|
||||
srcdir=@srcdir@
|
||||
|
||||
BINDIR = $(EROOTDIR)/bin
|
||||
LIBDIR=$(EROOTDIR)/lib
|
||||
YAPLIBDIR=$(EROOTDIR)/lib/Yap
|
||||
SHAREDIR=$(ROOTDIR)/share/Yap
|
||||
|
||||
SHELL=@SHELL@
|
||||
PL=@EXTEND_DYNLOADER_PATH@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup
|
||||
CHRDIR=$(SHAREDIR)/chr
|
||||
EXDIR=$(CHRDIR)/examples/chr
|
||||
LN_S=@LN_S@
|
||||
#
|
||||
#
|
||||
CC=@CC@
|
||||
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
|
||||
MKINDEX=true
|
||||
|
||||
LD=$(CC)
|
||||
|
||||
TARGETS= sgml2pl@SHLIB_SUFFIX@
|
||||
|
||||
else # SWI
|
||||
|
||||
PL=@PL@
|
||||
LD=@LD@
|
||||
PLLD=@PLLD@
|
||||
PLBASE=@PLBASE@
|
||||
PLARCH=@PLARCH@
|
||||
PKGDOC=$(PLBASE)/doc/packages
|
||||
PCEHOME=../xpce
|
||||
PLLIB=$(PLBASE)/library
|
||||
PLFOREIGN=$(PLBASE)/lib/$(PLARCH)
|
||||
DESTDIR=
|
||||
SO=@SO@
|
||||
|
||||
DOCTOTEX=$(PCEHOME)/bin/doc2tex
|
||||
PLTOTEX=$(PCEHOME)/bin/pl2tex
|
||||
LATEX=latex
|
||||
DOC=sgml
|
||||
TEX=$(DOC).tex
|
||||
DVI=$(DOC).dvi
|
||||
PDF=$(DOC).pdf
|
||||
HTML=$(DOC).html
|
||||
|
||||
CC=@CC@
|
||||
COFLAGS=@COFLAGS@
|
||||
CWFLAGS=@CWFLAGS@
|
||||
CMFLAGS=@CMFLAGS@
|
||||
CIFLAGS=-I. -I@PLINCL@
|
||||
CFLAGS=$(COFLAGS) $(CWFLAGS) $(CMFLAGS) $(CIFLAGS) @DEFS@
|
||||
LDFLAGS=$(COFLAGS)
|
||||
|
||||
LDSOFLAGS=@LDSOFLAGS@
|
||||
|
||||
TARGETS= sgml2pl.@SO@
|
||||
|
||||
endif #YAP/SWI
|
||||
|
||||
INSTALL=@INSTALL@
|
||||
INSTALL_PROGRAM=@INSTALL_PROGRAM@
|
||||
INSTALL_DATA=@INSTALL_DATA@
|
||||
|
||||
LIBOBJ= parser.o util.o charmap.o catalog.o model.o xmlns.o utf8.o \
|
||||
xml_unicode.o
|
||||
PLOBJ= $(LIBOBJ) error.o sgml2pl.o quote.o
|
||||
SGMLOBJ= $(LIBOBJ) sgml.o
|
||||
DTD2PLOBJ= $(LIBOBJ) dtd2pl.o prolog.o
|
||||
|
||||
HDRS= $(srcdir)/catalog.h $(srcdir)/dtd.h \
|
||||
$(srcdir)/model.h $(srcdir)/prolog.h \
|
||||
$(srcdir)/utf8.h $(srcdir)/xmlns.h \
|
||||
$(srcdir)/config.h $(srcdir)/error.h \
|
||||
$(srcdir)/parser.h $(srcdir)/sgmldefs.h $(srcdir)/util.h
|
||||
|
||||
ALLCSRC= $(LIBOBJ:.o=.c) \
|
||||
$(PLOBJ:.o=.c) $(SGMLOBJ:.o=.c) $(DTD2PLOBJ:.o=.c) \
|
||||
$(HDRS)
|
||||
|
||||
LIBPL= $(srcdir)/sgml.pl $(srcdir)/xsdp_types.pl \
|
||||
$(srcdir)/iso_639.pl $(srcdir)/sgml_write.pl
|
||||
PROGRAMS= dtd2pl sgml
|
||||
DTDFILES= HTML4.dcl HTML4.dtd \
|
||||
HTML4.soc \
|
||||
HTMLlat1.ent \
|
||||
HTMLspec.ent HTMLsym.ent
|
||||
|
||||
ifeq (@PROLOG_SYSTEM@,yap)
|
||||
|
||||
%.o : $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(SHLIB_CFLAGS) -o $@ -c $<
|
||||
|
||||
@DO_SECOND_LD@sgml2pl@SHLIB_SUFFIX@: $(PLOBJ)
|
||||
@DO_SECOND_LD@ @SHLIB_LD@ -o sgml2pl@SHLIB_SUFFIX@ $(PLOBJ)
|
||||
|
||||
all: $(TARGETS) $(PROGRAMS)
|
||||
|
||||
install: $(TARGETS) $(LIBPL) install-dtd
|
||||
mkdir -p $(DESTDIR)$(YAPLIBDIR)
|
||||
$(INSTALL_PROGRAM) $(TARGETS) $(DESTDIR)$(YAPLIBDIR)
|
||||
$(INSTALL_DATA) $(LIBPL) $(DESTDIR)$(SHAREDIR)
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
install-dtd::
|
||||
mkdir -p $(DESTDIR)$(SHAREDIR)/DTD
|
||||
for f in $(DTDFILES); do \
|
||||
$(INSTALL_DATA) $(srcdir)/DTD/$$f $(DESTDIR)$(SHAREDIR)/DTD; \
|
||||
done
|
||||
|
||||
else
|
||||
|
||||
sgml2pl.@SO@: $(PLOBJ)
|
||||
$(PLLD) -shared -o $@ $(PLOBJ)
|
||||
|
||||
all: coflags $(TARGETS) $(PROGRAMS)
|
||||
|
||||
coflags::
|
||||
@echo $(COFLAGS) > .coflags
|
||||
|
||||
install: $(TARGETS) $(LIBPL) install-dtd
|
||||
mkdir -p $(DESTDIR)$(PLBASE)/lib/$(PLARCH)
|
||||
$(INSTALL_PROGRAM) $(TARGETS) $(DESTDIR)$(PLFOREIGN)
|
||||
$(INSTALL_DATA) $(LIBPL) $(DESTDIR)$(PLLIB)
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
install-dtd::
|
||||
mkdir -p $(DESTDIR)$(PLBASE)/library/DTD
|
||||
for f in $(DTDFILES); do \
|
||||
$(INSTALL_DATA) DTD/$$f $(DESTDIR)$(PLBASE)/library/DTD; \
|
||||
done
|
||||
|
||||
endif
|
||||
|
||||
ln-install::
|
||||
@$(MAKE) INSTALL_DATA=../ln-install install
|
||||
|
||||
rpm-install: install
|
||||
|
||||
pdf-install::
|
||||
mkdir -p $(DESTDIR)$(PKGDOC)
|
||||
$(INSTALL_DATA) sgml.pdf $(DESTDIR)$(PKGDOC)
|
||||
|
||||
html-install::
|
||||
mkdir -p $(DESTDIR)$(PKGDOC)
|
||||
$(INSTALL_DATA) sgml.html $(DESTDIR)$(PKGDOC)
|
||||
|
||||
check::
|
||||
$(PL) -f Test/test.pl -g test,halt
|
||||
$(PL) -f Test/wrtest.pl -g test,halt
|
||||
|
||||
uninstall::
|
||||
(cd $(PLBASE)/lib/$(PLARCH) && rm -f $(TARGETS))
|
||||
(cd $(PLBASE)/library && rm -f $(LIBPL))
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
dtd2pl: $(DTD2PLOBJ)
|
||||
$(LD) $(LDFLAGS) -o $@ $(DTD2PLOBJ)
|
||||
|
||||
sgml: $(SGMLOBJ)
|
||||
$(LD) $(LDFLAGS) -o $@ $(SGMLOBJ)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(ALLCSRC)
|
||||
etags $(ALLCSRC)
|
||||
|
||||
################################################################
|
||||
# Documentation
|
||||
################################################################
|
||||
|
||||
doc: $(PDF) $(HTML)
|
||||
pdf: $(PDF)
|
||||
html: $(HTML)
|
||||
|
||||
$(HTML): $(TEX)
|
||||
latex2html $(DOC)
|
||||
mv html/index.html $@
|
||||
rmdir html
|
||||
|
||||
$(PDF): $(TEX)
|
||||
../../man/runtex --pdf $(DOC)
|
||||
|
||||
$(TEX): $(DOCTOTEX)
|
||||
|
||||
.doc.tex:
|
||||
$(DOCTOTEX) $*.doc > $*.tex
|
||||
.pl.tex:
|
||||
$(PLTOTEX) $*.pl > $*.tex
|
||||
|
||||
docclean::
|
||||
rm -f $(TEX)
|
||||
rm -rf html
|
||||
../../man/runtex --clean $(DOC)
|
||||
|
||||
################################################################
|
||||
# Clean
|
||||
################################################################
|
||||
|
||||
clean::
|
||||
rm -f $(PLOBJ) *~ *.o *% a.out core config.log
|
||||
|
||||
distclean: clean
|
||||
rm -f $(TARGETS) $(PROGRAMS)
|
||||
rm -f config.cache config.h config.status Makefile
|
||||
rm -f .coflags
|
||||
|
79
packages/sgml/Makefile.mak
Normal file
79
packages/sgml/Makefile.mak
Normal file
@ -0,0 +1,79 @@
|
||||
################################################################
|
||||
# Build the SWI-Prolog XML/SGML package for MS-Windows
|
||||
#
|
||||
# Author: Jan Wielemaker
|
||||
#
|
||||
# Use:
|
||||
# nmake /f Makefile.mak
|
||||
# nmake /f Makefile.mak install
|
||||
################################################################
|
||||
|
||||
PLHOME=..\..
|
||||
!include ..\..\src\rules.mk
|
||||
PKGDLL=sgml2pl
|
||||
|
||||
LIBOBJ= parser.obj util.obj charmap.obj catalog.obj \
|
||||
model.obj xmlns.obj utf8.obj xml_unicode.obj
|
||||
OBJ= $(LIBOBJ) sgml2pl.obj error.obj quote.obj
|
||||
SGMLOBJ= $(LIBOBJ) sgml.obj
|
||||
DTDFILES= HTML4.dcl HTML4.dtd HTML4.soc \
|
||||
HTMLlat1.ent HTMLspec.ent HTMLsym.ent
|
||||
DTDDIR= $(PLBASE)\library\DTD
|
||||
|
||||
all: $(PKGDLL).dll
|
||||
|
||||
$(PKGDLL).dll: $(OBJ)
|
||||
$(LD) /dll /out:$@ $(LDFLAGS) $(OBJ) $(PLLIB) $(LIBS)
|
||||
|
||||
sgml.exe: $(SGMLOBJ)
|
||||
$(LD) $(LDFLAGS) /out:$@ $(SGMLOBJ) $(LIBS)
|
||||
|
||||
!IF "$(CFG)" == "rt"
|
||||
install: idll
|
||||
!ELSE
|
||||
install: idtd idll ilib
|
||||
!ENDIF
|
||||
|
||||
idll::
|
||||
copy $(PKGDLL).dll "$(PLBASE)\bin"
|
||||
!IF "$(PDB)" == "true"
|
||||
copy $(PKGDLL).pdb "$(PLBASE)\bin"
|
||||
!ENDIF
|
||||
|
||||
ilib::
|
||||
copy sgml.pl "$(PLBASE)\library"
|
||||
copy xsdp_types.pl "$(PLBASE)\library"
|
||||
copy iso_639.pl "$(PLBASE)\library"
|
||||
copy sgml_write.pl "$(PLBASE)\library"
|
||||
$(MAKEINDEX)
|
||||
|
||||
idtd::
|
||||
@if not exist "$(DTDDIR)\$(NULL)" $(MKDIR) "$(DTDDIR)"
|
||||
@echo "Installing DTD files in $(DTDDIR)"
|
||||
@for %f in ($(DTDFILES)) do \
|
||||
@copy DTD\%f "$(DTDDIR)"
|
||||
@echo "done"
|
||||
|
||||
uninstall::
|
||||
del "$(PLBASE)\bin\$(PKGDLL).dll"
|
||||
del "$(PLBASE)\library\sgml.pl"
|
||||
del "$(PLBASE)\library\xsdp_types.pl"
|
||||
del "$(PLBASE)\library\iso_639.pl"
|
||||
del "$(PLBASE)\library\sgml_write.pl"
|
||||
$(MAKEINDEX)
|
||||
|
||||
html-install::
|
||||
copy sgml.html "$(PKGDOC)"
|
||||
|
||||
xpce-install::
|
||||
|
||||
check::
|
||||
cd Test && "$(PLCON)" -f test.pl -g test,halt.
|
||||
|
||||
clean::
|
||||
if exist *.obj del *.obj
|
||||
if exist *~ del *~
|
||||
|
||||
distclean: clean
|
||||
-DEL *.dll *.lib *.exp *.pdb *.ilk 2>nul
|
||||
|
9
packages/sgml/RDF/.cvsignore
Normal file
9
packages/sgml/RDF/.cvsignore
Normal file
@ -0,0 +1,9 @@
|
||||
.plrc
|
||||
config.h
|
||||
Online-requests
|
||||
Literature
|
||||
Tests
|
||||
Makefile
|
||||
config.log
|
||||
config.status
|
||||
config.cache
|
4
packages/sgml/RDF/.gitignore
vendored
Normal file
4
packages/sgml/RDF/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
configure
|
||||
rdf2pl.html
|
||||
rdf2pl.pdf
|
||||
rdf2pl.tex
|
237
packages/sgml/RDF/ChangeLog
Normal file
237
packages/sgml/RDF/ChangeLog
Normal file
@ -0,0 +1,237 @@
|
||||
[Jan 21 2009]
|
||||
|
||||
* FIXED: RDF writer: write valid XML if the namespace entity contains characters
|
||||
that must be %-escaped. Jacopo Urbani.
|
||||
|
||||
[Jan 13 2009]
|
||||
|
||||
* FIXED: RDF/XML could save illegal XML if multiple namespaces are used
|
||||
for predicates where one namespace is a prefix of another one. Jacopo Urbani.
|
||||
[Dec 19 2008]
|
||||
|
||||
* ADDED: Pass content_length through process_rdf/3
|
||||
[Sep 11 2008]
|
||||
|
||||
* PORT: Add AC_PREREQ to configure.h for systems that auto-select autoconf
|
||||
versions. After tip by Ulrich Neumerkel.
|
||||
|
||||
[Aug 11 2008]
|
||||
|
||||
* INSTALL: Remove all configure files from the git repository
|
||||
[Apr 18 2008]
|
||||
|
||||
* MODIFIED: Renamed hash_term/2 to term_hash/2. Added hash_term/2 to
|
||||
library(backcomp), so most code should not notice this.
|
||||
[Feb 28 2008]
|
||||
|
||||
* FIXED: rdf_write_xml/2 loops if it encounters an rdf:Bag.
|
||||
|
||||
[Feb 18 2008]
|
||||
|
||||
* FIXED: More fixes for proper handling of rdf:Bag
|
||||
|
||||
[Feb 13 2008]
|
||||
|
||||
* FIXED: Emit rdf:Bag attributes (etc.) as rdf:li
|
||||
|
||||
* FIXED: possible failure in rdf_write_xml with http://t-d-b.org?
|
||||
|
||||
[Jan 14 2008]
|
||||
|
||||
* FIXED: Bug#343: Handling bnodes in rdf_write_xml. Yver Raimond.
|
||||
|
||||
* FIXED: Added support for rdf:NodeID to rdf_write_xml/2. Yves Raimond.
|
||||
|
||||
[Dec 13 2007]
|
||||
|
||||
* FIXED: library(rdf_write) to deal with operators. Related to Bug#332
|
||||
|
||||
Oct 29, 2007
|
||||
|
||||
* FIXED: extract namespaces used in typed literals. Yves Raimond.
|
||||
|
||||
Jul 9, 2007
|
||||
|
||||
* FIXED: xml:lang with empty literals. Jochem Liem.
|
||||
|
||||
Jun 14, 2007
|
||||
|
||||
* FIXED: return rdf:parseType="Literal" as literal of type
|
||||
rdf:XMLLiteral.
|
||||
|
||||
Jan 18, 2007
|
||||
|
||||
* ADDED: embedded(Bool) option to process_rdf/3
|
||||
|
||||
Jun 25, 2006
|
||||
|
||||
* CLEANUP: Delete unused global variable.
|
||||
|
||||
Jun 5, 2006
|
||||
|
||||
* FIXED: use UTF-8 decoder from new library(utf8). Our own internal one
|
||||
was broken.
|
||||
|
||||
Apr 25, 2006
|
||||
|
||||
* FIXED: decoding of unicode-URIs using UTF-8 over %XX%XX.
|
||||
|
||||
Apr 13, 2006
|
||||
|
||||
* ADDED: library rdf_write to write an RDF file from a list of triples.
|
||||
|
||||
Dec 8, 2005
|
||||
|
||||
* FIXED: xmlns attributes in descriptions. Bijan Parsia
|
||||
|
||||
Nov 23, 2005
|
||||
|
||||
* ADDED: option db(DB) to parse_rdf/2.
|
||||
|
||||
Nov 10, 2005
|
||||
|
||||
* COMMENT: Comment use of IRI
|
||||
|
||||
Jul 7, 2005
|
||||
|
||||
* ADDED: Pass entity(Name, Value) to XML parser
|
||||
|
||||
Jul 5, 2005
|
||||
|
||||
* FIXED: Perform proper URI decoding to Unicode atoms
|
||||
|
||||
Jul 4, 2005
|
||||
|
||||
* FIXED: Make "make check" work from the build directory.
|
||||
|
||||
Mar 31, 2005
|
||||
|
||||
* FIXED: memory leak in process_rdf/2
|
||||
|
||||
Mar 29, 2005
|
||||
|
||||
* FIXED: dataType --> datatype (Vangelis Vassiliadis)
|
||||
|
||||
Oct 21, 2004
|
||||
|
||||
* FIXED: Bug#196: avoid need for autoloading. Sandro Hawke.
|
||||
|
||||
Sep 13, 2004
|
||||
|
||||
* ADDED: namespaces(-NameSpaces) option to load_rdf/3 and process_rdf/3
|
||||
to query the document namespace declarations.
|
||||
|
||||
Aug 13, 2004
|
||||
|
||||
* MODIFIED: load_rdf/3 no longer returns resources as Prefix:URI, but
|
||||
instead returns the plain atoms.
|
||||
|
||||
Jul 31, 2004
|
||||
|
||||
* ADDED: converted rdf_nt.pl into public rdf_ntriples.pl library for
|
||||
loading data in the W3C ntriple format.
|
||||
|
||||
Jun 29, 2004
|
||||
|
||||
* FIXED: sharing code for blank nodes. Broken in recent cleanup.
|
||||
|
||||
Jun 17, 2004
|
||||
|
||||
* CLEANUP: start/end of loading a file, use option/3 from library
|
||||
|
||||
Apr 21, 2004
|
||||
|
||||
* ADDED: Support for xml:lang and rdf:dataType attributes.
|
||||
|
||||
* INTERNAL: Use global variables rather than assert/retract for
|
||||
keeping track of the state for process_rdf/3.
|
||||
|
||||
Nov 29, 2003
|
||||
|
||||
* ADDED: warning for incorrect and multiple definitions of rdf:ID.
|
||||
Maarten Menken.
|
||||
|
||||
Nov 7, 2003
|
||||
|
||||
* ADDED: process_rdf/3: allow processing from a stream
|
||||
|
||||
Oct 6, 2003
|
||||
|
||||
* MODIFIED: synopsis of process_rdf/3 to
|
||||
process_rdf(+File, :OnTriples, +Options) for consistency and to allow
|
||||
extending the option list. Old calls are mapped to the new.
|
||||
|
||||
* Added option blank_nodes(share) to load_rdf/3 and process_rdf/3.
|
||||
|
||||
Aug 18, 2003
|
||||
|
||||
* Guarantee that anonymous ids start with __
|
||||
|
||||
Mar 20, 2003
|
||||
|
||||
* Fixed exception in cleanup. Dominique de Waleffe.
|
||||
|
||||
Feb 28, 2003
|
||||
|
||||
* ADDED: Use BaseURI to create non-conflicting anonymous resources.
|
||||
|
||||
* FIXED: rdf_parser:global_id to ignore xml:base for absolute URIs
|
||||
|
||||
Jan 17, 2003
|
||||
|
||||
* FIXED: online.pl (web frontend) to avoid using goal/1 option for the
|
||||
xml parser. Now uses 4.0.8 clib memfile library primitives.
|
||||
|
||||
* FIXED: process_rdf/3, Peter Marks.
|
||||
|
||||
* ADDED: parseType="Collection", satisfying the W3C Working Draft
|
||||
8 November 2002.
|
||||
|
||||
################################################################
|
||||
# Sumary of incompatibilities:
|
||||
#
|
||||
# Many problems in nested bag handling, changing output of
|
||||
# suite/t5.rdf
|
||||
#
|
||||
# Content of Alt-container was incorrectly rendered as rdf:li
|
||||
# instead of rdf:_1, rdf:_2, etc (suite/t27.rdf).
|
||||
################################################################
|
||||
|
||||
* ADDED: Translate rdf:li predicates into _1, _2, etc.
|
||||
|
||||
* FIXED: parseType=Literal to avoid extraneous [..] around the value
|
||||
|
||||
Oct 28, 2002
|
||||
|
||||
* CLEANUP: pass base-uri as attribute, preparing for xml:base and making
|
||||
the parser ready for multi-threading.
|
||||
|
||||
Sep 16, 2002
|
||||
|
||||
* MODIFIED: Allow for unqualified attribute-names
|
||||
|
||||
* ADDED: "make check"
|
||||
|
||||
Older entries
|
||||
|
||||
* FIXED: Type-exception in atom_chars/2
|
||||
|
||||
* FIXED: handling mixed <name>literal</name> and <name>object</name>
|
||||
(space canonisation problem).
|
||||
|
||||
* CGI Demo: report errors generated before a fatal exception.
|
||||
|
||||
* FIXED: handling of propertyElt of the form
|
||||
rdf:ID="myid" rdf:parseType="Resource"
|
||||
|
||||
* For objects, map NameSpace:Local to the simple concatenation of the two.
|
||||
This implies:
|
||||
|
||||
# Subjects are always atoms
|
||||
# Predicates are NameSpace:LocalName or simply Name
|
||||
# Objects are atoms (URI) or literal(Value)
|
||||
|
||||
* Warn on things that cannot be converted into an RDF-object rather then
|
||||
failing silently.
|
||||
|
||||
* Removed some undesirable choice-points.
|
128
packages/sgml/RDF/Makefile.in
Normal file
128
packages/sgml/RDF/Makefile.in
Normal file
@ -0,0 +1,128 @@
|
||||
################################################################
|
||||
# SWI-Prolog `RDF' package
|
||||
# Author: Jan Wielemaker. jan@swi.psy.uva.nl
|
||||
# Copyright: LGPL (see COPYING or www.gnu.org
|
||||
################################################################
|
||||
|
||||
.SUFFIXES: .tex .dvi .doc .pl
|
||||
|
||||
SHELL=@SHELL@
|
||||
PLBASE=@PLBASE@
|
||||
PLARCH=@PLARCH@
|
||||
PL=@PL@
|
||||
XPCEBASE=$(PLBASE)/xpce
|
||||
PKGDOC=$(PLBASE)/doc/packages
|
||||
PCEHOME=../../xpce
|
||||
DESTDIR=
|
||||
|
||||
CGISCRIPT=rdf-parser
|
||||
CGIDIR=/etc/httpd/cgi-bin
|
||||
CGIURL=http://gollem.science.uva.nl/cgi-bin
|
||||
WEBPAGE=/swi40/prolog/packages/rdf-online.html
|
||||
CGIGRP=www
|
||||
|
||||
DOCTOTEX=$(PCEHOME)/bin/doc2tex
|
||||
PLTOTEX=$(PCEHOME)/bin/pl2tex
|
||||
RUNTEX=../../../man/runtex
|
||||
LATEX=latex
|
||||
DOC=rdf2pl
|
||||
TEX=$(DOC).tex
|
||||
DVI=$(DOC).dvi
|
||||
PDF=$(DOC).pdf
|
||||
HTML=$(DOC).html
|
||||
|
||||
INSTALL=@INSTALL@
|
||||
INSTALL_PROGRAM=@INSTALL_PROGRAM@
|
||||
INSTALL_DATA=@INSTALL_DATA@
|
||||
|
||||
LIBPL= rdf.pl rdf_parser.pl rdf_triple.pl rewrite.pl \
|
||||
rdf_ntriples.pl rdf_write.pl
|
||||
XPCEPL= rdf_diagram.pl
|
||||
|
||||
all:
|
||||
@echo "Nothing to do for this package"
|
||||
|
||||
install: $(LIBPL) xpce-install
|
||||
$(INSTALL_DATA) $(LIBPL) $(DESTDIR)$(PLBASE)/library
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
ln-install::
|
||||
@$(MAKE) INSTALL_DATA=../../ln-install install
|
||||
|
||||
xpce-install: $(XPCEPL)
|
||||
if [ -d $(DESTDIR)$(XPCEBASE) ]; then \
|
||||
$(INSTALL) -m 644 $(XPCEPL) $(DESTDIR)$(XPCEBASE)/prolog/lib; \
|
||||
fi
|
||||
|
||||
rpm-install: install
|
||||
|
||||
pdf-install::
|
||||
$(INSTALL_DATA) $(DOC).pdf $(DESTDIR)$(PKGDOC)
|
||||
|
||||
html-install::
|
||||
$(INSTALL_DATA) $(DOC).html $(DESTDIR)$(PKGDOC)
|
||||
|
||||
uninstall:
|
||||
(cd $(PLBASE)/library && rm -f $(LIBPL))
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
check::
|
||||
$(PL) -f rdf_test.pl -g test,halt -t 'halt(1)'
|
||||
$(PL) -q -f write_test.pl -g run_tests,halt -t 'halt(1)'
|
||||
|
||||
################################################################
|
||||
# CGI INSTALL
|
||||
################################################################
|
||||
|
||||
cgi-install: $(CGIDIR)/$(CGISCRIPT) \
|
||||
Online-requests \
|
||||
$(WEBPAGE)
|
||||
|
||||
cgi-uninstall:
|
||||
rm -f $(CGIDIR)/$(CGISCRIPT) $(WEBPAGE)
|
||||
|
||||
Online-requests:
|
||||
mkdir $@
|
||||
chmod 775 $@
|
||||
chgrp $(CGIGRP) $@
|
||||
|
||||
$(WEBPAGE): online.html
|
||||
sed 's%@ACTION@%$(CGIURL)/$(CGISCRIPT)%' online.html > $@
|
||||
|
||||
$(CGIDIR)/$(CGISCRIPT): rdf-parser Makefile
|
||||
sed -e "s%@BASEDIR@%`pwd`%" -e s%@SWI@%$(PL)% rdf-parser > $@
|
||||
chmod 755 $@
|
||||
|
||||
################################################################
|
||||
# Documentation
|
||||
################################################################
|
||||
|
||||
doc: $(PDF) $(HTML)
|
||||
pdf: $(PDF)
|
||||
html: $(HTML)
|
||||
|
||||
$(HTML): $(TEX)
|
||||
latex2html $(DOC)
|
||||
mv html/index.html $@
|
||||
|
||||
$(PDF): $(TEX)
|
||||
$(RUNTEX) --pdf $(DOC)
|
||||
|
||||
$(TEX): $(DOCTOTEX)
|
||||
|
||||
.doc.tex:
|
||||
$(DOCTOTEX) $*.doc > $*.tex
|
||||
.pl.tex:
|
||||
$(PLTOTEX) $*.pl > $*.tex
|
||||
|
||||
################################################################
|
||||
# Clean
|
||||
################################################################
|
||||
|
||||
clean:
|
||||
rm -f *~ *% config.log
|
||||
|
||||
distclean: clean
|
||||
rm -f $(TARGETS) config.h config.cache config.status Makefile
|
||||
rm -f $(TEX)
|
||||
$(RUNTEX) --clean $(DOC)
|
51
packages/sgml/RDF/Makefile.mak
Normal file
51
packages/sgml/RDF/Makefile.mak
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################
|
||||
# Build the SWI-Prolog RDF package for MS-Windows
|
||||
# NOTE: This package requires the SGML package
|
||||
#
|
||||
# Author: Jan Wielemaker
|
||||
#
|
||||
# Use:
|
||||
# nmake /f Makefile.mak
|
||||
# nmake /f Makefile.mak install
|
||||
################################################################
|
||||
|
||||
PLHOME=..\..\..
|
||||
!include $(PLHOME)\src\rules.mk
|
||||
|
||||
all:
|
||||
|
||||
!IF "$(CFG)" == "rt"
|
||||
install::
|
||||
!ELSE
|
||||
install::
|
||||
copy rdf.pl "$(PLBASE)\library"
|
||||
copy rdf_parser.pl "$(PLBASE)\library"
|
||||
copy rdf_triple.pl "$(PLBASE)\library"
|
||||
copy rewrite.pl "$(PLBASE)\library"
|
||||
copy rdf_ntriples.pl "$(PLBASE)\library"
|
||||
copy rdf_write.pl "$(PLBASE)\library"
|
||||
$(MAKEINDEX)
|
||||
!ENDIF
|
||||
|
||||
xpce-install::
|
||||
copy rdf_diagram.pl "$(PLBASE)\xpce\prolog\lib"
|
||||
$(MAKEINDEX)
|
||||
|
||||
html-install::
|
||||
copy rdf2pl.html "$(PKGDOC)"
|
||||
|
||||
uninstall::
|
||||
del "$(PLBASE)\library\rdf.pl"
|
||||
del "$(PLBASE)\library\rdf_parser.pl"
|
||||
del "$(PLBASE)\library\rdf_triple.pl"
|
||||
del "$(PLBASE)\library\rewrite.pl"
|
||||
del "$(PLBASE)\library\rdf_ntriples.pl"
|
||||
del "$(PLBASE)\library\rdf_write.pl"
|
||||
$(MAKEINDEX)
|
||||
|
||||
clean::
|
||||
if exist *~ del *~
|
||||
|
||||
distclean: clean
|
||||
|
||||
|
12
packages/sgml/RDF/README
Normal file
12
packages/sgml/RDF/README
Normal file
@ -0,0 +1,12 @@
|
||||
---+ RDF/XML parser and writer
|
||||
|
||||
This directory implements the RDF/XML parser on top of the SWI-Prolog
|
||||
XML parser. The main entry point is provided by load_rdf/3 or the
|
||||
call-back version process_rdf/3.
|
||||
|
||||
In addition, rdf_write.pl provides writing (serialization) of an RDD/XML
|
||||
document from a list of triples.
|
||||
|
||||
* [[load_rdf/3]]
|
||||
* [[process_rdf/3]]
|
||||
* [[rdf_write_xml/2]]
|
32
packages/sgml/RDF/configure.in
Normal file
32
packages/sgml/RDF/configure.in
Normal file
@ -0,0 +1,32 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(install-sh)
|
||||
AC_PREREQ([2.50])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_SUBST(PL)
|
||||
AC_SUBST(PLBASE)
|
||||
AC_SUBST(PLARCH)
|
||||
|
||||
# Do not cache this, it changes too often in many configurations
|
||||
unset ac_cv_prog_PL
|
||||
|
||||
if test -z "$PLINCL"; then
|
||||
plcandidates="swi-prolog swipl pl"
|
||||
AC_CHECK_PROGS(PL, $plcandidates, "none")
|
||||
if test $PL = "none"; then
|
||||
AC_ERROR("Cannot find SWI-Prolog. SWI-Prolog must be installed first")
|
||||
else
|
||||
AC_CHECKING("Running $PL -dump-runtime-variables")
|
||||
eval `$PL -dump-runtime-variables`
|
||||
fi
|
||||
AC_MSG_RESULT(" PLBASE=$PLBASE")
|
||||
AC_MSG_RESULT(" PLARCH=$PLARCH")
|
||||
else
|
||||
PL=../../pl.sh
|
||||
fi
|
||||
|
||||
AC_CHECK_PROGS(MAKE, gmake make, "make")
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_OUTPUT(Makefile)
|
238
packages/sgml/RDF/install-sh
Executable file
238
packages/sgml/RDF/install-sh
Executable file
@ -0,0 +1,238 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
tranformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
177
packages/sgml/RDF/online.html
Normal file
177
packages/sgml/RDF/online.html
Normal file
@ -0,0 +1,177 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Online SWI-Prolog RDF parser demo</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 align=center>Online SWI-Prolog RDF parser demo</h1>
|
||||
|
||||
<p>
|
||||
This page provides an online demonstration of an RDF parser written in <a
|
||||
href="http://www.swi-prolog.org">SWI-Prolog</a> and distributed as part of the
|
||||
normal SWI-Prolog distribution. This RDF parser has a couple of attractive
|
||||
properties:
|
||||
|
||||
<dl>
|
||||
<dt><b>Small</b><dd>
|
||||
Both in terms of source-code (< 1200 lines) and executable.
|
||||
|
||||
<dt><b>Fast</b><dd>
|
||||
Parses about 1.2 Mbytes/sec on an AMD 1600+ running SWI-Prolog 5.1.6 and
|
||||
SuSE Linux 8.1 (tested on a 9MB RDFS file containing 179403 triples).
|
||||
|
||||
<dt><b>Conforming</b><dd>
|
||||
This parser conforms to http://www.w3.org/TR/rdf-syntax-grammar/,
|
||||
W3C Working Draft 8 November 2002. It includes the revised bag
|
||||
syntax, <code>xml:base</code>, <code>parseType="Collection"</code>
|
||||
and <code>nodeID</code> features.
|
||||
|
||||
<dt><b>Prolog based</b><dd>
|
||||
Many people regard the Prolog programming language a good vehicle to
|
||||
reason about RDF statements. Having a simple and fast Prolog-based RDF
|
||||
parser makes life easier.
|
||||
|
||||
<dt><b>Portability</b><dd>
|
||||
The RDF parser itself is written in ISO Prolog. The XML parser is
|
||||
written in ANSI-C. There is no standard for interfacing Prolog and C,
|
||||
but the interface is relatively small.
|
||||
|
||||
<dt><b>Discussion Page</b><dd>
|
||||
There is a
|
||||
<a href="http://gollem.science.uva.nl/twiki/pl/bin/view/Library/RdfParse">
|
||||
discussion page</a> on this parser on the SWI-Prolog collaborative
|
||||
(<em>twiki</em> web) </dl>
|
||||
|
||||
A more detailed description of this packages is available in <a
|
||||
href="http://www.swi-prolog.org/packages/rdf2pl.html">in this
|
||||
document</a>. The sources of the parser are included in the full
|
||||
source for SWI-Prolog. The individual source files can also be
|
||||
examined through the <a
|
||||
href="http://gollem.science.uva.nl/cgi-bin/pl-cvsweb/pl/packages/sgml/RDF">
|
||||
cvsweb service</a>.
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
Please write your RDF description into the text-area below or select a
|
||||
local file using the <b>File:</b> item and submit it. If anything goes
|
||||
wrong, please mail <a href="mailto:wielemak@science.uva.nl">Jan
|
||||
Wielemaker</a>.
|
||||
|
||||
<p>
|
||||
<em>The RDF-data submitted is kept <b>anonymously</b> on our server and
|
||||
might be used by us to examine problems with our RDF parser. We do not
|
||||
publish this material.</em> The result-page provides a form for
|
||||
attaching a comment to the stored RDF statement.
|
||||
|
||||
<p>
|
||||
<form
|
||||
name=rdf
|
||||
method=post
|
||||
enctype="multipart/form-data"
|
||||
action="@ACTION@">
|
||||
<table align=center>
|
||||
<tr><td colspan=2>
|
||||
<textarea name=rdf rows=15 cols=72 wrap=off></textarea>
|
||||
<tr><td>File: <input name=attachment type=file>
|
||||
<td align=right>
|
||||
<input type=button value='Example 1' onClick="ex1()">
|
||||
<input type=button value='Example 2' onClick="ex2()">
|
||||
<input type=button value='Example 3' onClick="ex3()">
|
||||
<input type=button value='Example 19' onClick="ex19()">
|
||||
<tr><td align=left><input type=reset value="Clear Text">
|
||||
<td align=right><input type=submit value="Parse RDF">
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<h4><hr>Notes<hr></h4
|
||||
|
||||
<dl>
|
||||
<dt><b><em>rdf:</em>resource, etc.</b><dd>
|
||||
The specification and discussion on the rdf interest group yielded no
|
||||
satisfactory solution how to deal with RDF attributes that are not in
|
||||
the RDF namespace such as <b>ID</b>, <b>resource</b>, etc. This parser
|
||||
interprets such attributes in the namespace of the element, so the
|
||||
statement below is not interpreted as a <b>propertyElt</b> with value
|
||||
<code>me</code> but as a <b>typedNode</b> with predicate
|
||||
<code>resource</code> and value <b>literal(</b>me<b>)</b>.
|
||||
|
||||
<pre>
|
||||
<s:Creator resource="#me">
|
||||
</pre>
|
||||
</dl>
|
||||
|
||||
<!---------------------------------------------------------------->
|
||||
<!-- EXAMPLES -->
|
||||
<!---------------------------------------------------------------->
|
||||
|
||||
<script language="JavaScript">
|
||||
|
||||
function ex1()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
||||
\n\
|
||||
<!-- Example from REC-rdf-syntax -->\n\
|
||||
\n\
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
||||
xmlns:s="http://description.org/schema/">\n\
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">\n\
|
||||
<s:Creator>Ora Lassila</s:Creator>\n\
|
||||
</rdf:Description>\n\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
function ex2()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
||||
\n\
|
||||
<!-- Example from REC-rdf-syntax, demonstrating reification -->\n\
|
||||
\n\
|
||||
<rdf:RDF\n\
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
||||
xmlns:s="http://description.org/schema/">\n\
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila" bagID="D_001">\n\
|
||||
<s:Creator>Ora Lassila</s:Creator>\n\
|
||||
<s:Title>Ora\'s Home Page</s:Title>\n\
|
||||
</rdf:Description>\n\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
function ex3()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
||||
\n\
|
||||
<!-- Example from REC-rdf-syntax, non-binary relations -->\n\
|
||||
\n\
|
||||
<rdf:RDF\n\
|
||||
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
||||
xmlns:n="http://www.nist.gov/units/">\n\
|
||||
<Description about="John_Smith">\n\
|
||||
<n:weight rdf:parseType="Resource">\n\
|
||||
<rdf:value>200</rdf:value>\n\
|
||||
<n:units rdf:resource="http://www.nist.gov/units/Pounds"/>\n\
|
||||
</n:weight>\n\
|
||||
</Description>\n\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
function ex19()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
||||
\n\
|
||||
<!-- Example 19: Complete example of a RDF collection of nodes\n\
|
||||
using rdf:parseType="Collection" -->\n\
|
||||
\n\
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
||||
xmlns:ex="http://example.org/stuff/1.0/">\n\
|
||||
<rdf:Description rdf:about="http://example.org/basket">\n\
|
||||
<ex:hasFruit rdf:parseType="Collection">\n\
|
||||
<rdf:Description rdf:about="http://example.org/banana"/>\n\
|
||||
<rdf:Description rdf:about="http://example.org/apple"/>\n\
|
||||
<rdf:Description rdf:about="http://example.org/pear"/>\n\
|
||||
</ex:hasFruit>\n\
|
||||
</rdf:Description>\n\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
457
packages/sgml/RDF/online.pl
Normal file
457
packages/sgml/RDF/online.pl
Normal file
@ -0,0 +1,457 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog RDF parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
:- use_module(library(cgi)).
|
||||
:- use_module(library(sgml)).
|
||||
:- use_module(rdf).
|
||||
:- use_module(rdf_parser).
|
||||
:- use_module(rewrite).
|
||||
:- use_module(pretty_print).
|
||||
|
||||
term_expansion(F, T) :- rew_term_expansion(F, T).
|
||||
goal_expansion(F, T) :- rew_goal_expansion(F, T).
|
||||
|
||||
:- dynamic new_rdf_namespace/1.
|
||||
|
||||
parse(Text, RDFTerm, Triples) :-
|
||||
parse_atom(Text, Term),
|
||||
( find_rdf(Term, RDFTerm)
|
||||
-> true
|
||||
; RDFTerm = Term
|
||||
),
|
||||
xml_to_rdf(RDFTerm, [], Triples).
|
||||
|
||||
find_rdf(Term, RDFTerm) :-
|
||||
RDFTerm = element(NS:'RDF', _, _),
|
||||
term_member(RDFTerm, Term), !,
|
||||
( rdf_name_space(NS)
|
||||
-> true
|
||||
; assert(rdf_parser:rdf_name_space(NS)),
|
||||
assert(new_rdf_namespace(NS))
|
||||
).
|
||||
|
||||
term_member(X, X).
|
||||
term_member(X, Compound) :-
|
||||
compound(Compound),
|
||||
arg(_, Compound, Arg),
|
||||
term_member(X, Arg).
|
||||
|
||||
% parse_atom(+Atom, -Term, +Options
|
||||
%
|
||||
% Parse and atom into a structured term
|
||||
|
||||
parse_atom(Atom, Term) :-
|
||||
atom_to_memory_file(Atom, MemFile),
|
||||
open_memory_file(MemFile, read, Stream),
|
||||
new_sgml_parser(Parser, []),
|
||||
set_sgml_parser(Parser, dialect(xmlns)),
|
||||
set_sgml_parser(Parser, space(sgml)),
|
||||
sgml_parse(Parser,
|
||||
[ source(Stream),
|
||||
document(Term)
|
||||
]),
|
||||
free_sgml_parser(Parser),
|
||||
close(Stream),
|
||||
free_memory_file(MemFile).
|
||||
|
||||
|
||||
/*******************************
|
||||
* HTML GENERATION *
|
||||
*******************************/
|
||||
|
||||
:- op(100, fx, #).
|
||||
:- op(110, xfx, ::).
|
||||
|
||||
emit([]) :- !.
|
||||
emit([H|T]) :- !,
|
||||
emit(H),
|
||||
emit(T).
|
||||
emit(Fmt-Args) :- !,
|
||||
format(Fmt, Args),
|
||||
retractall(nl_done(_)).
|
||||
emit(#Term) :- !,
|
||||
#Term.
|
||||
emit(#Term::Content) :- !,
|
||||
#Term::Content.
|
||||
emit(Atom) :-
|
||||
write(Atom),
|
||||
retractall(nl_done(_)).
|
||||
|
||||
#Term::Content :-
|
||||
Term =.. [Name|Attributes],
|
||||
layout(before(open, Name)),
|
||||
format('<~w', [Name]),
|
||||
attlist(Attributes),
|
||||
format('>', []),
|
||||
retractall(nl_done(_)),
|
||||
layout(after(open, Name)),
|
||||
emit(Content),
|
||||
end_tag(Name).
|
||||
#pre(Text) :- !,
|
||||
sgml_quote(Text, Quoted),
|
||||
#pre::Quoted.
|
||||
#box(Text) :- !,
|
||||
box(Text, '#e0e0e0').
|
||||
#box(Text, Colour) :- !,
|
||||
box(Text, Colour).
|
||||
#Term :-
|
||||
Term =.. [Name|Attributes],
|
||||
layout(before(open, Name)),
|
||||
format('<~w', [Name]),
|
||||
attlist(Attributes),
|
||||
format('>', []),
|
||||
retractall(nl_done(_)),
|
||||
layout(after(open, Name)),
|
||||
end_tag(Name).
|
||||
|
||||
end_tag(Name) :-
|
||||
blines(Name, _, o), !.
|
||||
end_tag(Name) :-
|
||||
layout(before(close, Name)),
|
||||
format('</~w>', [Name]),
|
||||
retractall(nl_done(_)),
|
||||
layout(after(close, Name)).
|
||||
|
||||
|
||||
layout(before(open, Name)) :-
|
||||
blines(Name, N-_, _), !,
|
||||
nls(N).
|
||||
layout(after(open, Name)) :-
|
||||
blines(Name, _-N, _), !,
|
||||
nls(N).
|
||||
layout(before(close, Name)) :-
|
||||
blines(Name, _, N-_), !,
|
||||
nls(N).
|
||||
layout(after(close, Name)) :-
|
||||
blines(Name, _, _-N), !,
|
||||
nls(N).
|
||||
layout(_) :-
|
||||
retractall(nl_done(_)).
|
||||
|
||||
:- dynamic
|
||||
nl_done/1.
|
||||
|
||||
nls(N) :-
|
||||
( nl_done(Done)
|
||||
-> true
|
||||
; Done = 0
|
||||
),
|
||||
ToDo is N - Done,
|
||||
New is max(N, Done),
|
||||
retractall(nl_done(Done)),
|
||||
assert(nl_done(New)),
|
||||
do_nl(ToDo).
|
||||
|
||||
do_nl(N) :-
|
||||
N > 0, !,
|
||||
nl,
|
||||
NN is N - 1,
|
||||
do_nl(NN).
|
||||
do_nl(_).
|
||||
|
||||
blines(tr, 1-0, 0-0).
|
||||
blines(table, 2-1, 1-1).
|
||||
blines(form, 2-1, 1-1).
|
||||
blines(h1, 2-0, 0-1).
|
||||
blines(h2, 2-0, 0-2).
|
||||
blines(h3, 2-0, 0-2).
|
||||
blines(h4, 2-0, 0-2).
|
||||
blines(p, 2-1, o). % omitted end-tag
|
||||
|
||||
attlist([]).
|
||||
attlist([Name=Value|T]) :- !,
|
||||
sgml_quote_value(Value, Quoted),
|
||||
format(' ~w=~w', [Name, Quoted]),
|
||||
attlist(T).
|
||||
attlist([Name|T]) :-
|
||||
format(' ~w', [Name]),
|
||||
attlist(T).
|
||||
|
||||
head(Title) :-
|
||||
emit([ 'Content-type: text/html\n\n',
|
||||
'<html>\n',
|
||||
'<head>\n',
|
||||
'<title>~w</title>~n'-[Title],
|
||||
'</head>\n\n',
|
||||
'<body bgcolor="white">\n'
|
||||
]).
|
||||
foot :-
|
||||
emit([ '</body>\n',
|
||||
'</html>\n'
|
||||
]).
|
||||
|
||||
|
||||
pre(Text) :-
|
||||
sgml_quote(Text, Quoted),
|
||||
#pre::Quoted.
|
||||
|
||||
box(Text, Colour) :-
|
||||
emit('<p>\n'),
|
||||
#table(width='80%', align=center, border=6, bgcolor=Colour)::
|
||||
[#tr::[#td(nowrap)::[#pre(Text)]]].
|
||||
|
||||
|
||||
/*******************************
|
||||
* QUOTING *
|
||||
*******************************/
|
||||
|
||||
sgml_quote_value(Value, Arg) :-
|
||||
atom_chars(Value, Chars),
|
||||
( name_chars(Chars)
|
||||
-> Arg = Value
|
||||
; sgml_quote_chars(Chars, Quoted),
|
||||
atom_chars(Arg, Quoted)
|
||||
).
|
||||
|
||||
name_chars([H|T]) :-
|
||||
char_type(H, alpha),
|
||||
all_alnum(T).
|
||||
|
||||
all_alnum([]).
|
||||
all_alnum([H|T]) :-
|
||||
char_type(H, csymf),
|
||||
all_alnum(T).
|
||||
|
||||
sgml_quote_chars(L, ['"'|T]) :-
|
||||
sgml_quote2(L, T, ['"']).
|
||||
|
||||
sgml_quote2([], T, T).
|
||||
sgml_quote2([H|T0], List, Rest) :-
|
||||
sgml_quote_char(H, List, T), !,
|
||||
sgml_quote2(T0, T, Rest).
|
||||
sgml_quote2([H|T0], [H|T], Rest) :-
|
||||
sgml_quote2(T0, T, Rest).
|
||||
|
||||
sgml_quote_char('<', [&, l, t, ;|T], T).
|
||||
sgml_quote_char('>', [&, g, t, ;|T], T).
|
||||
sgml_quote_char('&', [&, a, m, p, ;|T], T).
|
||||
sgml_quote_char('"', [&, q, u, o, t, ;|T], T).
|
||||
%sgml_quote_char('\'', [&, a, p, o, s, ;|T], T).
|
||||
|
||||
sgml_quote(Text, Quoted) :-
|
||||
atom_chars(Text, Chars),
|
||||
sgml_quote2(Chars, QuotedChars, []),
|
||||
atom_chars(Quoted, QuotedChars).
|
||||
|
||||
|
||||
/*******************************
|
||||
* PAGE GENERATION *
|
||||
*******************************/
|
||||
|
||||
parsed(Time, Triples) :-
|
||||
length(Triples, Len),
|
||||
#h2::'RDF statement parsed successfully',
|
||||
#p::[ 'Your RDF statement has been parsed in ~2f seconds, '-[Time],
|
||||
'creating ', #b::Len, ' triples. ',
|
||||
'Please find the created triples in the table below.'
|
||||
],
|
||||
( getenv('HTTP_REFERER', Referer)
|
||||
-> #p::[ 'If you want to try another RDF statement, please go ',
|
||||
'back to ', #a(href=Referer)::'the request form', '.'
|
||||
]
|
||||
; true
|
||||
).
|
||||
|
||||
rdf_table(Triples) :-
|
||||
maplist(triple_row, Triples, TripleRows),
|
||||
#p,
|
||||
#table(caption='RDF triples',
|
||||
align=center, border=2, cellpadding=3)::
|
||||
[ #tr::[#th::'Subject', #th::'Predicate', #th::'Object']
|
||||
| TripleRows
|
||||
].
|
||||
|
||||
triple_row(rdf(Subj, Pred, Obj), #tr::[#td::S,#td::P,#td::O]) :-
|
||||
cell(Subj, S),
|
||||
cell(Pred, P),
|
||||
cell(Obj, O).
|
||||
|
||||
cell(rdf:Local, [#em::rdf, :, #b::Local]) :- !.
|
||||
cell(literal(X), [#b::'literal(', X, #b::')']) :- !.
|
||||
cell(each(X), [#b::'each(', X, #b::')']) :- !.
|
||||
cell(pefix(X), [#b::'prefix(', X, #b::')']) :- !.
|
||||
cell(NS:Local, [NS, :, #b::Local]) :- !.
|
||||
cell(V, [T]) :-
|
||||
sformat(T, '~p', [V]).
|
||||
|
||||
/*******************************
|
||||
* ERRORS *
|
||||
*******************************/
|
||||
|
||||
show_errors :-
|
||||
getenv('ERROR_FILE', File),
|
||||
size_file(File, Size),
|
||||
Size > 0, !,
|
||||
read_file(File, Data),
|
||||
#h4::[#font(color=red)::
|
||||
'The following errors occurred while processing your request'],
|
||||
#p,
|
||||
#box(Data, '#ff8c00').
|
||||
show_errors.
|
||||
|
||||
show_new_namepace :-
|
||||
new_rdf_namespace(NS), !,
|
||||
#h4::[#font(color=red)::'Warning: unofficial RDF Namespace'],
|
||||
#p::['It appears your RDF description uses the unofficial ',
|
||||
'name space ', #b::NS, '. ',
|
||||
'This name space has been added for RDF.'
|
||||
].
|
||||
show_new_namepace.
|
||||
|
||||
|
||||
/*******************************
|
||||
* COMMENT *
|
||||
*******************************/
|
||||
|
||||
comment(TextId) :-
|
||||
#h4::'<hr>Comment',
|
||||
#p::[ 'If you do not agree with the output or have other comments, ',
|
||||
'Please write them in the text-area below and submit them'
|
||||
],
|
||||
getenv('REQUEST_URI', Script),
|
||||
#form(method=post, action=Script)::
|
||||
[ #input(type=hidden, name=id, value=TextId),
|
||||
#table(align=center)::
|
||||
[ #tr::[#td::[#textarea(name=comment, cols=64, rows=10)]],
|
||||
#tr::[#td(align=right)::['E-mail: ', #input(name=mail)]],
|
||||
#tr::[#td(align=right)::[#input(type=submit)]]
|
||||
]
|
||||
].
|
||||
|
||||
|
||||
/*******************************
|
||||
* REQUEST *
|
||||
*******************************/
|
||||
|
||||
request_location('Online-requests').
|
||||
|
||||
% Save the request and return a local identifier for it.
|
||||
|
||||
save_request(Text, Id) :-
|
||||
request_dir(Dir, Date),
|
||||
concat_atom([Dir, /, Date], DateDir),
|
||||
ensure_dir(DateDir),
|
||||
between(1, 10000, N),
|
||||
concat_atom([DateDir, /, N, '.rdf'], File),
|
||||
\+ exists_file(File), !,
|
||||
open(File, write, Fd),
|
||||
format(Fd, '~w~n', [Text]),
|
||||
close(Fd),
|
||||
concat_atom([Date, /, N], Id).
|
||||
|
||||
request_dir(BaseDir, Date) :-
|
||||
get_time(Time),
|
||||
convert_time(Time, Y, M, D, _, _, _, _),
|
||||
request_location(BaseDir),
|
||||
concat_atom([D, -, M, -, Y], Date).
|
||||
|
||||
ensure_dir(Dir) :-
|
||||
exists_directory(Dir), !.
|
||||
ensure_dir(Dir) :-
|
||||
make_directory(Dir).
|
||||
|
||||
save_comment(Id, Mail, Comment) :-
|
||||
request_location(Base),
|
||||
concat_atom([Base, '/', Id], FileBase),
|
||||
absolute_file_name(FileBase, AbsFileBase),
|
||||
absolute_file_name(Base, AbsBase),
|
||||
sub_atom(AbsFileBase, 0, _, _, AbsBase), % verify in tree
|
||||
atom_concat(AbsFileBase, '.cmt', CmtFile),
|
||||
open(CmtFile, write, Fd),
|
||||
format(Fd, 'E-mail: ~w~n~n~w~n', [Mail, Comment]),
|
||||
close(Fd).
|
||||
|
||||
|
||||
/*******************************
|
||||
* ENTRY *
|
||||
*******************************/
|
||||
|
||||
main :-
|
||||
cgi_get_form(Arguments),
|
||||
( ( memberchk(attachment(Text), Arguments),
|
||||
Text \== ''
|
||||
; memberchk(rdf(Text), Arguments)
|
||||
)
|
||||
-> save_request(Text, TextId),
|
||||
( OldTime is cputime,
|
||||
parse(Text, _Prolog, Triples),
|
||||
Time is cputime - OldTime
|
||||
-> head('RDF Triples'),
|
||||
parsed(Time, Triples),
|
||||
show_errors,
|
||||
show_new_namepace,
|
||||
rdf_table(Triples),
|
||||
comment(TextId),
|
||||
foot
|
||||
; head('Failed to parse'),
|
||||
#p::[ 'I failed to parse your request' ],
|
||||
show_errors,
|
||||
comment(TextId),
|
||||
foot
|
||||
),
|
||||
halt
|
||||
; memberchk(comment(Comment), Arguments),
|
||||
memberchk(id(Id), Arguments),
|
||||
memberchk(mail(Mail), Arguments)
|
||||
-> save_comment(Id, Mail, Comment),
|
||||
head('Thanks for comment'),
|
||||
#p::'Thank you for your comments',
|
||||
foot,
|
||||
halt
|
||||
).
|
||||
main :-
|
||||
head('Failed'),
|
||||
#p::[ 'This CGI-script failed to understand your request' ],
|
||||
foot,
|
||||
halt.
|
||||
|
||||
go :-
|
||||
catch(main, E, error(E)).
|
||||
|
||||
error(E) :-
|
||||
message_to_string(E, Msg),
|
||||
head('Failed to parse'),
|
||||
show_errors,
|
||||
#p::[ 'An exception was raised while parsing your request:' ],
|
||||
#pre(Msg),
|
||||
foot,
|
||||
halt.
|
||||
|
||||
|
||||
/*******************************
|
||||
* TEST *
|
||||
*******************************/
|
||||
|
||||
test :-
|
||||
read_file('suite/t1.rdf', Text),
|
||||
catch(parse(Text, _Prolog, Triples), E, error(E)),
|
||||
head('RDF Triples'),
|
||||
rdf_table(Triples),
|
||||
foot.
|
||||
|
||||
|
||||
/*******************************
|
||||
* UTIL *
|
||||
*******************************/
|
||||
|
||||
read_file(File, Atom) :-
|
||||
open(File, read, Fd),
|
||||
get_code(Fd, C),
|
||||
read_stream(C, Fd, Chars),
|
||||
close(Fd),
|
||||
atom_codes(Atom, Chars).
|
||||
|
||||
read_stream(-1, _, []) :- !.
|
||||
read_stream(C0, Fd, [C0|T]) :-
|
||||
get_code(Fd, C),
|
||||
read_stream(C, Fd, T).
|
167
packages/sgml/RDF/pretty_print.pl
Normal file
167
packages/sgml/RDF/pretty_print.pl
Normal file
@ -0,0 +1,167 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog SGML/XML parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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(dia_pretty_print,
|
||||
[ pretty_print/1
|
||||
]).
|
||||
|
||||
:- require([ atom_length/2
|
||||
, between/3
|
||||
, forall/2
|
||||
, is_list/1
|
||||
, member/2
|
||||
, memberchk/2
|
||||
]).
|
||||
|
||||
|
||||
pretty_print(Term) :-
|
||||
numbervars(Term, 0, _),
|
||||
pp(Term, 0),
|
||||
write('.'), nl, fail.
|
||||
pretty_print(_).
|
||||
|
||||
|
||||
pp(Term, _Indent) :-
|
||||
atomic(Term), !,
|
||||
writeq(Term).
|
||||
pp(Var, _Indent) :-
|
||||
var(Var), !,
|
||||
write(Var).
|
||||
pp(Var, _Indent) :-
|
||||
Var = '$VAR'(_), !,
|
||||
print(Var).
|
||||
pp('$aref'(Name), _Indent) :- !,
|
||||
write(Name).
|
||||
pp(Module:Term, Indent) :-
|
||||
atomic(Module), !,
|
||||
writeq(Module), write(:),
|
||||
pp(Term, Indent).
|
||||
pp([A1 = V1|ArgList], Indent) :- % [] is done by `atomic'!
|
||||
is_list(ArgList),
|
||||
forall(member(A, ArgList), A = (_ = _)),
|
||||
longest_attribute([A1 = V1|ArgList], 0, L), !,
|
||||
NewIndent is Indent + 2,
|
||||
( L > 9, Indent < 25, length(ArgList, Args), Args > 1
|
||||
-> ArgIndent is Indent + 4,
|
||||
ValGoal = (nl, indent(ArgIndent))
|
||||
; ArgIndent is Indent + 6 + L,
|
||||
ValGoal = write(' ')
|
||||
),
|
||||
write('[ '),
|
||||
pp(A1, Indent), term_length(A1, L1),
|
||||
tab(L-L1), write(' ='), ValGoal,
|
||||
pp(V1, ArgIndent),
|
||||
forall(member(A = V, ArgList),
|
||||
(write(','), nl,
|
||||
indent(NewIndent),
|
||||
pp(A, Indent), term_length(A, LA), tab(L-LA),
|
||||
write(' ='), ValGoal, pp(V, ArgIndent))),
|
||||
nl,
|
||||
indent(Indent),
|
||||
write(']').
|
||||
pp([H|T], Indent) :-
|
||||
is_list(T), !,
|
||||
write('[ '),
|
||||
NewIndent is Indent + 2,
|
||||
pp(H, NewIndent),
|
||||
forall(member(E, T),
|
||||
(write(','), nl,
|
||||
indent(NewIndent),
|
||||
pp(E, NewIndent))),
|
||||
nl,
|
||||
indent(Indent),
|
||||
write(']').
|
||||
pp(Term, Indent) :-
|
||||
functor(Term, Name, 2),
|
||||
current_op(_, Type, Name),
|
||||
memberchk(Type, [xfx, yfx]), !,
|
||||
arg(1, Term, A1),
|
||||
arg(2, Term, A2),
|
||||
pp(A1, Indent), format(' ~q ', [Name]), pp(A2, Indent).
|
||||
pp(Term, Indent) :-
|
||||
functor(Term, Name, _Arity),
|
||||
atom_length(Name, L),
|
||||
NewIndent is Indent + L + 1,
|
||||
format('~q(', Name),
|
||||
( term_argument_length(Term, AL),
|
||||
NewIndent + AL < 72
|
||||
-> Wrap = nowrap
|
||||
; Wrap = wrap
|
||||
),
|
||||
forall(generate_arg(I, Term, Arg),
|
||||
pparg(I, Arg, Wrap, NewIndent)),
|
||||
write(')').
|
||||
|
||||
generate_arg(ArgN, Term, Arg) :-
|
||||
functor(Term, _, Arity),
|
||||
between(1, Arity, ArgN),
|
||||
arg(ArgN, Term, Arg).
|
||||
|
||||
pparg(1, Term, _, Indent) :- !,
|
||||
pp(Term, Indent).
|
||||
pparg(_, Term, wrap, Indent) :- !,
|
||||
write(','), nl,
|
||||
indent(Indent),
|
||||
pp(Term, Indent).
|
||||
pparg(_, Term, _, Indent) :-
|
||||
write(', '),
|
||||
pp(Term, Indent).
|
||||
|
||||
longest_attribute([], L, L).
|
||||
longest_attribute([A = _|T], L0, L) :-
|
||||
term_length(A, AL),
|
||||
max(L0, AL, L1),
|
||||
longest_attribute(T, L1, L).
|
||||
|
||||
term_length(A, AL) :-
|
||||
atomic(A), !,
|
||||
atom_length(A, AL).
|
||||
term_length(Var, AL) :-
|
||||
var(Var), !,
|
||||
AL = 1.
|
||||
term_length('$VAR'(N), AL) :-
|
||||
varname(N, L),
|
||||
length(L, AL).
|
||||
term_length('$aref'(N), AL) :-
|
||||
atom_length(N, AL).
|
||||
|
||||
term_argument_length(Term, L) :-
|
||||
term_argument_length(Term, 1, 0, L).
|
||||
|
||||
term_argument_length(Term, A, L0, L) :-
|
||||
arg(A, Term, Arg), !,
|
||||
term_length(Arg, AL),
|
||||
L1 is AL + L0,
|
||||
NA is A + 1,
|
||||
term_argument_length(Term, NA, L1, L).
|
||||
term_argument_length(_, _, L, L).
|
||||
|
||||
|
||||
max(A, B, M) :-
|
||||
( A >= B
|
||||
-> M = A
|
||||
; M = B
|
||||
).
|
||||
|
||||
|
||||
varname(N, [C]) :-
|
||||
N < 26, !,
|
||||
C is N + 0'A.
|
||||
varname(N, [C1, C2]) :-
|
||||
C1 is N // 26 + 0'A,
|
||||
C2 is N mod 26 + 0'A.
|
||||
|
||||
indent(I) :-
|
||||
Tabs is I // 8,
|
||||
forall(between(1, Tabs, _), put(9)),
|
||||
Spaces is I mod 8,
|
||||
tab(Spaces).
|
35
packages/sgml/RDF/rdf-parser
Executable file
35
packages/sgml/RDF/rdf-parser
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This is not the normal parser, just the front-end for the CGI interface.
|
||||
# The real CGI stuff is written in Prolog in the file online.pl. The
|
||||
# request is in online.html
|
||||
#
|
||||
# The RDF parser itself is just a Prolog library. See rdf2pl.{html,pdf}.
|
||||
|
||||
base=@BASEDIR@
|
||||
tmp=/tmp/rdf-parser-$$
|
||||
export ERROR_FILE=$tmp
|
||||
|
||||
ulimit -t 20 # seconds CPU time limit
|
||||
|
||||
function error()
|
||||
{ cat << _EOM_
|
||||
Content-type: text/plain
|
||||
|
||||
Sorry, an internal error occurred. For details, see below.
|
||||
|
||||
_EOM_
|
||||
cat $tmp
|
||||
rm -r $tmp
|
||||
exit 0
|
||||
}
|
||||
|
||||
cd $base > $tmp 2>&1
|
||||
@SWI@ -f none -F none -t halt \
|
||||
-g "load_files(online,[silent(true)]),go" 2>$tmp
|
||||
|
||||
case $? in
|
||||
0) rm -f $tmp
|
||||
exit 0 ;;
|
||||
*) error ;;
|
||||
esac
|
156
packages/sgml/RDF/rdf.html
Normal file
156
packages/sgml/RDF/rdf.html
Normal file
@ -0,0 +1,156 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Online SWI-Prolog RDF parser demo</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 align=center>Online SWI-Prolog RDF parser demo</h1>
|
||||
|
||||
<p>
|
||||
This page provides an online demonstration of an RDF parser written in
|
||||
<a href="http://www.swi.psy.uva.nl/projects/SWI-Prolog/">SWI-Prolog</a>.
|
||||
This RDF parser has a couple of attractive properties:
|
||||
|
||||
<dl>
|
||||
<dt><b>Small</b><dd>
|
||||
Both in terms of source-code (< 700 lines) and executable.
|
||||
<dt><b>Fast</b><dd>
|
||||
Parses about 400 Kbytes/sec on a Pentium-II/450.
|
||||
<dt><b>Conforming</b><dd>
|
||||
This parser conforms to <a href="http://www.w3.org/TR/REC-rdf-syntax">
|
||||
http://www.w3.org/TR/REC-rdf-syntax</a>.
|
||||
<dt><b>Prolog based</b><dd>
|
||||
Many people regard the Prolog programming language a good vehicle to
|
||||
reason about RDF statements. Having a simple and fast Prolog-based RDF
|
||||
parser makes life easier.
|
||||
<dt><b>Portability</b><dd>
|
||||
The RDF parser itself is written in ISO Prolog. The XML parser is
|
||||
written in ANSI-C. There is no standard for interfacing Prolog and C,
|
||||
but the interface is relatively small.
|
||||
</dl>
|
||||
|
||||
A more detailed description of this packages is available in <a
|
||||
href="rdf2pl.html">in this document</a>. The sources of the parser are
|
||||
included into the <a
|
||||
href="http://www.swi.psy.uva.nl/projects/SWI-Prolog/packages/sgml/">sgml</a>
|
||||
packages for SWI-Prolog. The individual source files can also be
|
||||
examined through the <a
|
||||
href="http://gollem.swi.psy.uva.nl/cgi-bin/pl-cvsweb/packages/sgml/RDF">
|
||||
cvsweb service</a>, which also provides access to the most recent
|
||||
<a
|
||||
href="http://gollem.swi.psy.uva.nl/cgi-bin/pl-cvsweb/packages/sgml/RDF/ChangeLog">
|
||||
changes</a>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
Please write your RDF description into the text-area below or select a
|
||||
local file using the <b>File:</b> item and submit it. If anything goes
|
||||
wrong, please mail <a href="mailto:jan@swi.psy.uva.nl">Jan
|
||||
Wielemaker</a>.
|
||||
|
||||
<p>
|
||||
<em>The RDF-data submitted is kept <b>anonymously</b> on our server and
|
||||
might be used by us to examine problems with our RDF parser. We do not
|
||||
publish this material.</em> The result-page provides a form for
|
||||
attaching a comment to the stored RDF statement.
|
||||
|
||||
<!-- enctype="multipart/form-data" -->
|
||||
|
||||
|
||||
<p>
|
||||
<form
|
||||
name=rdf
|
||||
method=get
|
||||
action="http://localhost:8000/rdf">
|
||||
<table align=center>
|
||||
<tr><td colspan=2>
|
||||
<textarea name=rdf rows=15 cols=72 wrap=off></textarea>
|
||||
<tr><td>File: <input name=attachment type=file>
|
||||
<td align=right>
|
||||
<input type=button value='Example 1' onClick="ex1()">
|
||||
<input type=button value='Example 2' onClick="ex2()">
|
||||
<input type=button value='Example 3' onClick="ex3()">
|
||||
<tr><td align=left><input type=reset value="Clear Text">
|
||||
<td align=right><input type=submit value="Parse RDF">
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<h4><hr>Notes<hr></h4
|
||||
|
||||
<dl>
|
||||
<dt><b><em>rdf:</em>resource, etc.</b><dd>
|
||||
The specification and discussion on the rdf interest group yielded no
|
||||
satisfactory solution how to deal with RDF attributes that are not in
|
||||
the RDF namespace such as <b>ID</b>, <b>resource</b>, etc. This parser
|
||||
interprets such attributes in the namespace of the element, so the
|
||||
statement below is not interpreted as a <b>propertyElt</b> with value
|
||||
<code>me</code> but as a <b>typedNode</b> with predicate
|
||||
<code>resource</code> and value <b>literal(</b>me<b>)</b>.
|
||||
|
||||
<pre>
|
||||
<s:Creator resource="#me">
|
||||
</pre>
|
||||
</dl>
|
||||
|
||||
<!---------------------------------------------------------------->
|
||||
<!-- EXAMPLES -->
|
||||
<!---------------------------------------------------------------->
|
||||
|
||||
<script language="JavaScript">
|
||||
|
||||
function ex1()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\
|
||||
\
|
||||
<!-- Example from REC-rdf-syntax -->\
|
||||
\
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
|
||||
xmlns:s="http://description.org/schema/">\
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">\
|
||||
<s:Creator>Ora Lassila</s:Creator>\
|
||||
</rdf:Description>\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
function ex2()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\
|
||||
\
|
||||
<!-- Example from REC-rdf-syntax, demonstrating reification -->\
|
||||
\
|
||||
<rdf:RDF\
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
|
||||
xmlns:s="http://description.org/schema/">\
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila" bagID="D_001">\
|
||||
<s:Creator>Ora Lassila</s:Creator>\
|
||||
<s:Title>Ora\'s Home Page</s:Title>\
|
||||
</rdf:Description>\
|
||||
</rdf:RDF>';
|
||||
}
|
||||
|
||||
function ex3()
|
||||
{ document.rdf.rdf.value='<?xml version="1.0"?>\
|
||||
\
|
||||
<!-- Example from REC-rdf-syntax, non-binary relations -->\
|
||||
\
|
||||
<RDF\
|
||||
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\
|
||||
xmlns:n="http://www.nist.gov/units/">\
|
||||
<Description about="John_Smith">\
|
||||
<n:weight rdf:parseType="Resource">\
|
||||
<rdf:value>200</rdf:value>\
|
||||
<n:units rdf:resource="http://www.nist.gov/units/Pounds"/>\
|
||||
</n:weight>\
|
||||
</Description>\
|
||||
</RDF>';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
456
packages/sgml/RDF/rdf.pl
Normal file
456
packages/sgml/RDF/rdf.pl
Normal file
@ -0,0 +1,456 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: wielemak@science.uva.nl
|
||||
WWW: http://www.swi-prolog.org
|
||||
Copyright (C): 2002-2007, University of Amsterdam
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
As a special exception, if you link this library with other files,
|
||||
compiled with a Free Software compiler, to produce an executable, this
|
||||
library does not by itself cause the resulting executable to be covered
|
||||
by the GNU General Public License. This exception does not however
|
||||
invalidate any other reasons why the executable file might be covered by
|
||||
the GNU General Public License.
|
||||
*/
|
||||
|
||||
|
||||
:- module(rdf,
|
||||
[ load_rdf/2, % +File, -Triples
|
||||
load_rdf/3, % +File, -Triples, +Options
|
||||
xml_to_rdf/3, % +XML, -Triples, +Options
|
||||
process_rdf/3 % +File, :OnTriples, +Options
|
||||
]).
|
||||
|
||||
:- meta_predicate(process_rdf(+, :, +)).
|
||||
|
||||
:- use_module(library(sgml)). % Basic XML loading
|
||||
:- use_module(library(option)). % option/3
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(rdf_parser). % Basic parser
|
||||
:- use_module(rdf_triple). % Generate triples
|
||||
|
||||
%% load_rdf(+File, -Triples) is det.
|
||||
%% load_rdf(+File, -Triples, +Options) is det.
|
||||
%
|
||||
% Parse an XML file holding an RDF term into a list of RDF triples.
|
||||
% see rdf_triple.pl for a definition of the output format. Options:
|
||||
%
|
||||
% * base_uri(+URI)
|
||||
% URI to use as base
|
||||
%
|
||||
% * expand_foreach(+Bool)
|
||||
% Apply each(Container, Pred, Object) on the members of
|
||||
% Container
|
||||
%
|
||||
% * namespaces(-Namespaces:list(NS=URL))
|
||||
% Return list of namespaces declared using xmlns:NS=URL in
|
||||
% the document. This can be used to update the namespace
|
||||
% list with rdf_register_ns/2.
|
||||
%
|
||||
% @see Use process_rdf/3 for processing large documents in
|
||||
% _|call-back|_ style.
|
||||
|
||||
load_rdf(File, Triples) :-
|
||||
load_rdf(File, Triples, []).
|
||||
|
||||
load_rdf(File, Triples, Options0) :-
|
||||
entity_options(Options0, EntOptions, Options1),
|
||||
meta_options(Options1, Options),
|
||||
init_ns_collect(Options, NSList),
|
||||
load_structure(File,
|
||||
[ RDFElement
|
||||
],
|
||||
[ dialect(xmlns),
|
||||
space(sgml),
|
||||
call(xmlns, rdf:on_xmlns)
|
||||
| EntOptions
|
||||
]),
|
||||
rdf_start_file(Options, Cleanup),
|
||||
call_cleanup(xml_to_rdf(RDFElement, Triples0, Options),
|
||||
rdf_end_file(Cleanup)),
|
||||
exit_ns_collect(NSList),
|
||||
post_process(Options, Triples0, Triples).
|
||||
|
||||
entity_options([], [], []).
|
||||
entity_options([H|T0], Entities, Rest) :-
|
||||
( H = entity(_,_)
|
||||
-> Entities = [H|ET],
|
||||
entity_options(T0, ET, Rest)
|
||||
; Rest = [H|RT],
|
||||
entity_options(T0, Entities, RT)
|
||||
).
|
||||
|
||||
|
||||
%% xml_to_rdf(+XML, -Triples, +Options)
|
||||
|
||||
xml_to_rdf(XML, Triples, Options) :-
|
||||
is_list(Options), !,
|
||||
xml_to_plrdf(XML, RDF, Options),
|
||||
rdf_triples(RDF, Triples).
|
||||
xml_to_rdf(XML, BaseURI, Triples) :-
|
||||
atom(BaseURI), !,
|
||||
xml_to_rdf(XML, Triples, [base_uri(BaseURI)]).
|
||||
|
||||
|
||||
/*******************************
|
||||
* POST-PROCESSING *
|
||||
*******************************/
|
||||
|
||||
post_process([], Triples, Triples).
|
||||
post_process([expand_foreach(true)|T], Triples0, Triples) :- !,
|
||||
expand_each(Triples0, Triples1),
|
||||
post_process(T, Triples1, Triples).
|
||||
post_process([_|T], Triples0, Triples) :- !,
|
||||
post_process(T, Triples0, Triples).
|
||||
|
||||
|
||||
/*******************************
|
||||
* EXPAND *
|
||||
*******************************/
|
||||
|
||||
expand_each(Triples0, Triples) :-
|
||||
select(rdf(each(Container), Pred, Object),
|
||||
Triples0, Triples1), !,
|
||||
each_triples(Triples1, Container, Pred, Object, Triples2),
|
||||
expand_each(Triples2, Triples).
|
||||
expand_each(Triples, Triples).
|
||||
|
||||
each_triples([], _, _, _, []).
|
||||
each_triples([H0|T0], Container, P, O,
|
||||
[H0, rdf(S,P,O)|T]) :-
|
||||
H0 = rdf(Container, rdf:A, S),
|
||||
member_attribute(A), !,
|
||||
each_triples(T0, Container, P, O, T).
|
||||
each_triples([H|T0], Container, P, O, [H|T]) :-
|
||||
each_triples(T0, Container, P, O, T).
|
||||
|
||||
member_attribute(A) :-
|
||||
sub_atom(A, 0, _, _, '_'). % must check number?
|
||||
|
||||
|
||||
/*******************************
|
||||
* BIG FILES *
|
||||
*******************************/
|
||||
|
||||
%% process_rdf(+Input, :OnObject, +Options)
|
||||
%
|
||||
% Process RDF from Input. Input is either an atom or a term of the
|
||||
% format stream(Handle). For each encountered description, call
|
||||
% OnObject(+Triples) to handle the triples resulting from the
|
||||
% description. Defined Options are:
|
||||
%
|
||||
% * base_uri(+URI)
|
||||
% Determines the reference URI.
|
||||
%
|
||||
% * db(DB)
|
||||
% When loading from a stream, the source is taken from
|
||||
% this option or -if non-existent- from base_uri.
|
||||
%
|
||||
% * lang(LanguageID)
|
||||
% Set initial language (as xml:lang)
|
||||
%
|
||||
% * convert_typed_literal(:Convertor)
|
||||
% Call Convertor(+Type, +Content, -RDFObject) to create
|
||||
% a triple rdf(S, P, RDFObject) instead of rdf(S, P,
|
||||
% literal(type(Type, Content)).
|
||||
%
|
||||
% * namespaces(-Namespaces:list(NS=URL))
|
||||
% Return list of namespaces declared using xmlns:NS=URL in
|
||||
% the document. This can be used to update the namespace
|
||||
% list with rdf_register_ns/2.
|
||||
%
|
||||
% * entity(Name, Value)
|
||||
% Overrule entity values found in the file
|
||||
%
|
||||
% * embedded(Boolean)
|
||||
% If =true=, do not give warnings if rdf:RDF is embedded
|
||||
% in other XML data.
|
||||
|
||||
process_rdf(File, OnObject, Options0) :-
|
||||
is_list(Options0), !,
|
||||
entity_options(Options0, EntOptions, Options1),
|
||||
meta_options(Options1, Options2),
|
||||
process_options(Options2, ProcessOptions, Options),
|
||||
option(base_uri(BaseURI), Options, []),
|
||||
rdf_start_file(Options, Cleanup),
|
||||
strip_module(OnObject, Module, Pred),
|
||||
nb_setval(rdf_object_handler, Module:Pred),
|
||||
nb_setval(rdf_options, Options),
|
||||
nb_setval(rdf_state, -),
|
||||
init_ns_collect(Options, NSList),
|
||||
( File = stream(In)
|
||||
-> Source = BaseURI
|
||||
; is_stream(File)
|
||||
-> In = File,
|
||||
option(db(Source), Options, BaseURI)
|
||||
; open(File, read, In, [type(binary)]),
|
||||
Close = In,
|
||||
Source = File
|
||||
),
|
||||
new_sgml_parser(Parser, [dtd(DTD)]),
|
||||
def_entities(EntOptions, DTD),
|
||||
set_sgml_parser(Parser, file(Source)),
|
||||
set_sgml_parser(Parser, dialect(xmlns)),
|
||||
set_sgml_parser(Parser, space(sgml)),
|
||||
do_process_rdf(Parser, In, NSList, Close, Cleanup, ProcessOptions).
|
||||
process_rdf(File, BaseURI, OnObject) :-
|
||||
process_rdf(File, OnObject, [base_uri(BaseURI)]).
|
||||
|
||||
def_entities([], _).
|
||||
def_entities([entity(Name, Value)|T], DTD) :- !,
|
||||
def_entity(DTD, Name, Value),
|
||||
def_entities(T, DTD).
|
||||
def_entities([_|T0], DTD) :-
|
||||
def_entities(T0, DTD).
|
||||
|
||||
def_entity(DTD, Name, Value) :-
|
||||
open_dtd(DTD, [], Stream),
|
||||
xml_quote_attribute(Value, QValue),
|
||||
format(Stream, '<!ENTITY ~w "~w">~n', [Name, QValue]),
|
||||
close(Stream).
|
||||
|
||||
|
||||
do_process_rdf(Parser, In, NSList, Close, Cleanup, Options) :-
|
||||
call_cleanup(( sgml_parse(Parser,
|
||||
[ source(In),
|
||||
call(begin, rdf:on_begin),
|
||||
call(xmlns, rdf:on_xmlns)
|
||||
| Options
|
||||
]),
|
||||
exit_ns_collect(NSList)
|
||||
),
|
||||
cleanup_process(Close, Cleanup, Parser)).
|
||||
|
||||
cleanup_process(In, Cleanup, Parser) :-
|
||||
( var(In)
|
||||
-> true
|
||||
; close(In)
|
||||
),
|
||||
free_sgml_parser(Parser),
|
||||
nb_delete(rdf_options),
|
||||
nb_delete(rdf_object_handler),
|
||||
nb_delete(rdf_state),
|
||||
nb_delete(rdf_nslist),
|
||||
rdf_end_file(Cleanup).
|
||||
|
||||
on_begin(NS:'RDF', Attr, _) :-
|
||||
rdf_name_space(NS), !,
|
||||
nb_getval(rdf_options, Options0),
|
||||
modify_state(Attr, Options0, Options),
|
||||
nb_setval(rdf_state, Options).
|
||||
on_begin(Tag, Attr, Parser) :-
|
||||
nb_getval(rdf_state, Options),
|
||||
( Options == (-)
|
||||
-> nb_getval(rdf_options, RdfOptions),
|
||||
( memberchk(embedded(true), RdfOptions)
|
||||
-> true
|
||||
; print_message(warning, rdf(unexpected(Tag, Parser)))
|
||||
)
|
||||
; get_sgml_parser(Parser, line(Start)),
|
||||
get_sgml_parser(Parser, file(File)),
|
||||
sgml_parse(Parser,
|
||||
[ document(Content),
|
||||
parse(content)
|
||||
]),
|
||||
nb_getval(rdf_object_handler, OnTriples),
|
||||
element_to_plrdf(element(Tag, Attr, Content), Objects, Options),
|
||||
rdf_triples(Objects, Triples),
|
||||
call(OnTriples, Triples, File:Start)
|
||||
).
|
||||
|
||||
%% on_xmlns(+NS, +URL, +Parser)
|
||||
%
|
||||
% Build up the list of encountered xmlns:NS=URL declarations. We
|
||||
% use destructive assignment here as an alternative to
|
||||
% assert/retract, ensuring thread-safety and better performance.
|
||||
|
||||
on_xmlns(NS, URL, _Parser) :-
|
||||
( nb_getval(rdf_nslist, List),
|
||||
List = list(L0)
|
||||
-> nb_linkarg(1, List, [NS=URL|L0])
|
||||
; true
|
||||
).
|
||||
|
||||
init_ns_collect(Options, NSList) :-
|
||||
( option(namespaces(NSList), Options, -),
|
||||
NSList \== (-)
|
||||
-> nb_setval(rdf_nslist, list([]))
|
||||
; nb_setval(rdf_nslist, -),
|
||||
NSList = (-)
|
||||
).
|
||||
|
||||
exit_ns_collect(NSList) :-
|
||||
( NSList == (-)
|
||||
-> true
|
||||
; nb_getval(rdf_nslist, list(NSList))
|
||||
).
|
||||
|
||||
modify_state([], Options, Options).
|
||||
modify_state([H|T], Options0, Options) :-
|
||||
modify_state1(H, Options0, Options1),
|
||||
modify_state(T, Options1, Options).
|
||||
|
||||
modify_state1(xml:base = Base0, Options0, Options) :- !,
|
||||
remove_fragment(Base0, Base),
|
||||
set_option(base_uri(Base), Options0, Options).
|
||||
modify_state1(xml:lang = Lang, Options0, Options) :- !,
|
||||
set_option(lang(Lang), Options0, Options).
|
||||
modify_state1(_, Options, Options).
|
||||
|
||||
%% remove_fragment(+URI, -WithoutFragment)
|
||||
%
|
||||
% When handling xml:base, we must delete the possible fragment.
|
||||
|
||||
remove_fragment(URI, Plain) :-
|
||||
sub_atom(URI, B, _, _, #), !,
|
||||
sub_atom(URI, 0, B, _, Plain).
|
||||
remove_fragment(URI, URI).
|
||||
|
||||
|
||||
set_option(Opt, Options0, [Opt|Options]) :-
|
||||
functor(Opt, F, A),
|
||||
functor(VO, F, A),
|
||||
delete(Options0, VO, Options).
|
||||
|
||||
|
||||
%% meta_options(+OptionsIn, -OptionsOut)
|
||||
%
|
||||
% Do module qualification for options that are module sensitive.
|
||||
|
||||
:- module_transparent
|
||||
meta_options/2.
|
||||
|
||||
meta_options([], []).
|
||||
meta_options([Name=Value|T0], List) :-
|
||||
atom(Name), !,
|
||||
Opt =.. [Name, Value],
|
||||
meta_options([Opt|T0], List).
|
||||
meta_options([H0|T0], [H|T]) :-
|
||||
( H0 = convert_typed_literal(Handler)
|
||||
-> strip_module(Handler, M, P),
|
||||
H = convert_typed_literal(M:P)
|
||||
; H = H0
|
||||
),
|
||||
meta_options(T0, T).
|
||||
|
||||
|
||||
process_options(Options, Process, RestOptions) :-
|
||||
select_option(content_length(Len), Options, RestOptions), !,
|
||||
Process = [content_length(Len)].
|
||||
process_options(Options, [], Options).
|
||||
|
||||
|
||||
/*******************************
|
||||
* MESSAGES *
|
||||
*******************************/
|
||||
|
||||
:- multifile
|
||||
prolog:message/3.
|
||||
|
||||
% Catch messages. sgml/4 is generated by the SGML2PL binding.
|
||||
|
||||
prolog:message(rdf(unparsed(Data))) -->
|
||||
{ phrase(unparse_xml(Data), XML)
|
||||
},
|
||||
[ 'RDF: Failed to interpret "~s"'-[XML] ].
|
||||
prolog:message(rdf(shared_blank_nodes(N))) -->
|
||||
[ 'RDF: Shared ~D blank nodes'-[N] ].
|
||||
prolog:message(rdf(not_a_name(Name))) -->
|
||||
[ 'RDF: argument to rdf:ID is not an XML name: ~p'-[Name] ].
|
||||
prolog:message(rdf(redefined_id(Id))) -->
|
||||
[ 'RDF: rdf:ID ~p: multiple definitions'-[Id] ].
|
||||
prolog:message(rdf(unexpected(Tag, Parser))) -->
|
||||
{ get_sgml_parser(Parser, file(File)),
|
||||
get_sgml_parser(Parser, line(Line))
|
||||
},
|
||||
[ 'RDF: ~w:~d: Unexpected element ~w'-[File, Line, Tag] ].
|
||||
|
||||
|
||||
/*******************************
|
||||
* XML-TO-TEXT *
|
||||
*******************************/
|
||||
|
||||
unparse_xml([]) --> !,
|
||||
[].
|
||||
unparse_xml([H|T]) --> !,
|
||||
unparse_xml(H),
|
||||
unparse_xml(T).
|
||||
unparse_xml(Atom) -->
|
||||
{ atom(Atom)
|
||||
}, !,
|
||||
atom(Atom).
|
||||
unparse_xml(element(Name, Attr, Content)) -->
|
||||
"<",
|
||||
identifier(Name),
|
||||
attributes(Attr),
|
||||
( { Content == []
|
||||
}
|
||||
-> "/>"
|
||||
; ">",
|
||||
unparse_xml(Content)
|
||||
).
|
||||
|
||||
attributes([]) -->
|
||||
[].
|
||||
attributes([H|T]) -->
|
||||
attribute(H),
|
||||
attributes(T).
|
||||
|
||||
attribute(Name=Value) -->
|
||||
" ",
|
||||
identifier(Name),
|
||||
"=",
|
||||
value(Value).
|
||||
|
||||
identifier(NS:Local) --> !,
|
||||
"{", atom(NS), "}",
|
||||
atom(Local).
|
||||
identifier(Local) -->
|
||||
atom(Local).
|
||||
|
||||
atom(Atom, Text, Rest) :-
|
||||
atom_codes(Atom, Chars),
|
||||
append(Chars, Rest, Text).
|
||||
|
||||
value(Value) -->
|
||||
{ atom_codes(Value, Chars)
|
||||
},
|
||||
"\"",
|
||||
quoted(Chars),
|
||||
"\"".
|
||||
|
||||
quoted([]) -->
|
||||
[].
|
||||
quoted([H|T]) -->
|
||||
quote(H), !,
|
||||
quoted(T).
|
||||
|
||||
quote(0'<) --> "<".
|
||||
quote(0'>) --> ">".
|
||||
quote(0'") --> """.
|
||||
quote(0'&) --> "&".
|
||||
quote(X) --> [X].
|
||||
|
||||
|
||||
/*******************************
|
||||
* XREF *
|
||||
*******************************/
|
||||
|
||||
:- multifile prolog:meta_goal/2.
|
||||
prolog:meta_goal(process_rdf(_,G,_), [G+2]).
|
475
packages/sgml/RDF/rdf2pl.doc
Normal file
475
packages/sgml/RDF/rdf2pl.doc
Normal file
@ -0,0 +1,475 @@
|
||||
\documentclass[11pt]{article}
|
||||
\usepackage{pl}
|
||||
\usepackage{html}
|
||||
\usepackage{times}
|
||||
|
||||
\onefile
|
||||
\htmloutput{html} % Output directory
|
||||
\htmlmainfile{index} % Main document file
|
||||
\bodycolor{white} % Page colour
|
||||
|
||||
\newcommand{\elem}[1]{{\tt\string<#1\string>}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\title{SWI-Prolog RDF parser}
|
||||
\author{Jan Wielemaker \\
|
||||
HCS, \\
|
||||
University of Amsterdam \\
|
||||
The Netherlands \\
|
||||
E-mail: \email{jan@swi-prolog.org}}
|
||||
|
||||
\maketitle
|
||||
|
||||
\begin{abstract}
|
||||
\url[RDF]{http://www.w3.org/RDF/} ({\bf R}esource {\bf D}escription {\bf
|
||||
F}ormat) is a \url[W3C]{http://www.w3.org/} standard for expressing
|
||||
meta-data about web-resources. It has two representations providing
|
||||
the same semantics. RDF documents are normally transferred as XML
|
||||
documents using the RDF-XML syntax. This format is unsuitable for
|
||||
processing. The parser defined here converts an RDF-XML document into
|
||||
the \jargon{triple} notation. The library \pllib{rdf_write} creates
|
||||
an RDF/XML document from a list of triples.
|
||||
\end{abstract}
|
||||
|
||||
\vfill
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\vfill
|
||||
\vfill
|
||||
|
||||
\newpage
|
||||
|
||||
\section{Introduction}
|
||||
|
||||
RDF is a promising standard for representing meta-data about documents
|
||||
on the web as well as exchanging frame-based data (e.g. ontologies). RDF
|
||||
is often associated with `semantics on the web'. It consists of a formal
|
||||
data-model defined in terms of \jargon{triples}. In addition, a
|
||||
\jargon{graph} model is defined for visualisation and an XML application
|
||||
is defined for exchange.
|
||||
|
||||
`Semantics on the web' is also associated with the Prolog programming
|
||||
language. It is assumed that Prolog is a suitable vehicle to reason with
|
||||
the data expressed in RDF models. Most of the related web-infra
|
||||
structure (e.g. XML parsers, DOM implementations) are defined in Java,
|
||||
Perl, C or C+{+}.
|
||||
|
||||
Various routes are available to the Prolog user. Low-level XML parsing
|
||||
is due to its nature best done in C or C+{+}. These languages produce
|
||||
fast code. As XML/SGML are at the basis of most of the other web-related
|
||||
formats we will benefit most here. XML and SGML, being very stable
|
||||
specifications, make fast compiled languages even more attractive.
|
||||
|
||||
But what about RDF? RDF-XML is defined in XML, and provided with a
|
||||
Prolog term representing the XML document processing it according to the
|
||||
RDF syntax is quick and easy in Prolog. The alternative, getting yet
|
||||
another library and language attached to the system, is getting less
|
||||
attractive. In this document we explore the suitability of Prolog for
|
||||
processing XML documents in general and into RDF in particular.
|
||||
|
||||
|
||||
\section{Parsing RDF in Prolog}
|
||||
|
||||
We realised an RDF compiler in Prolog on top of the {\bf sgml2pl}
|
||||
package (providing a name-space sensitive XML parser). The
|
||||
transformation is realised in two passes.
|
||||
|
||||
The first pass rewrites the XML term into a Prolog term conveying the
|
||||
same information in a more friendly manner. This transformation is
|
||||
defined in a high-level pattern matching language defined on top of
|
||||
Prolog with properties similar to DCG (Definite Clause Grammar).
|
||||
|
||||
The source of this translation is very close to the BNF notation used by
|
||||
the \url[specification]{http://www.w3.org/TR/REC-rdf-syntax/}, so
|
||||
correctness is `obvious'. Below is a part of the definition for RDF
|
||||
containers. Note that XML elements are represented using a term of the
|
||||
format:
|
||||
|
||||
\begin{quote}
|
||||
\term{element}{Name, [AttrName = Value...], [Content ...]}
|
||||
\end{quote}
|
||||
|
||||
\begin{code}
|
||||
memberElt(LI) ::=
|
||||
\referencedItem(LI).
|
||||
memberElt(LI) ::=
|
||||
\inlineItem(LI).
|
||||
|
||||
referencedItem(LI) ::=
|
||||
element(\rdf(li),
|
||||
[ \resourceAttr(LI) ],
|
||||
[]).
|
||||
|
||||
inlineItem(literal(LI)) ::=
|
||||
element(\rdf(li),
|
||||
[ \parseLiteral ],
|
||||
LI).
|
||||
inlineItem(description(description, _, _, Properties)) ::=
|
||||
element(\rdf(li),
|
||||
[ \parseResource ],
|
||||
\propertyElts(Properties)).
|
||||
inlineItem(LI) ::=
|
||||
element(\rdf(li),
|
||||
[],
|
||||
[\rdf_object(LI)]), !. % inlined object
|
||||
inlineItem(literal(LI)) ::=
|
||||
element(\rdf(li),
|
||||
[],
|
||||
[LI]). % string value
|
||||
\end{code}
|
||||
|
||||
Expression in the rule that are prefixed by the \verb$\$ operator acts
|
||||
as invocation of another rule-set. The body-term is converted into
|
||||
a term where all rule-references are replaced by variables. The
|
||||
resulting term is matched and translation of the arguments is achieved
|
||||
by calling the appropriate rule. Below is the Prolog code for the
|
||||
{\bf referencedItem} rule:
|
||||
|
||||
\begin{code}
|
||||
referencedItem(A, element(B, [C], [])) :-
|
||||
rdf(li, B),
|
||||
resourceAttr(A, C).
|
||||
\end{code}
|
||||
|
||||
Additional code can be added using a notation close to the Prolog
|
||||
DCG notation. Here is the rule for a description, producing
|
||||
properties both using {\bf propAttrs} and {\bf propertyElts}.
|
||||
|
||||
\begin{code}
|
||||
description(description, About, BagID, Properties) ::=
|
||||
element(\rdf('Description'),
|
||||
\attrs([ \?idAboutAttr(About),
|
||||
\?bagIdAttr(BagID)
|
||||
| \propAttrs(PropAttrs)
|
||||
]),
|
||||
\propertyElts(PropElts)),
|
||||
{ !, append(PropAttrs, PropElts, Properties)
|
||||
}.
|
||||
\end{code}
|
||||
|
||||
|
||||
\section{Predicates}
|
||||
|
||||
The parser is designed to operate in various environments and therefore
|
||||
provides interfaces at various levels. First we describe the top level
|
||||
defined in \pllib{rdf}, simply parsing a RDF-XML file into a list of
|
||||
triples. Please note these are {\em not} asserted into the database
|
||||
because it is not necessarily the final format the user wishes to reason
|
||||
with and it is not clean how the user wants to deal with multiple RDF
|
||||
documents. Some options are using global URI's in one pool, in Prolog
|
||||
modules or using an additional argument.
|
||||
|
||||
\begin{description}
|
||||
\predicate{load_rdf}{2}{+File, -Triples}
|
||||
Same as \term{load_rdf}{File, Triples, []}.
|
||||
|
||||
\predicate{load_rdf}{3}{+File, -Triples, +Options}
|
||||
Read the RDF-XML file \arg{File} and return a list of \arg{Triples}.
|
||||
\arg{Options} defines additional processing options. Currently defined
|
||||
options are:
|
||||
|
||||
\begin{description}
|
||||
\termitem{base_uri}{BaseURI}
|
||||
If provided local identifiers and identifier-references are globalised
|
||||
using this URI. If omited or the atom \verb$[]$, local identifiers are
|
||||
not tagged.
|
||||
|
||||
\termitem{blank_nodes}{Mode}
|
||||
If \arg{Mode} is \const{share} (default), blank-node properties (i.e.\
|
||||
complex properties without identifier) are reused if they result in
|
||||
exactly the same triple-set. Two descriptions are shared if their
|
||||
intermediate description is the same. This means they should produce the
|
||||
same set of triples in the same order. The value \const{noshare} creates
|
||||
a new resource for each blank node.
|
||||
|
||||
\termitem{expand_foreach}{Boolean}
|
||||
If \arg{Boolean} is \const{true}, expand \const{rdf:aboutEach} into
|
||||
a set of triples. By default the parser generates
|
||||
\term{rdf}{each(Container), Predicate, Subject}.
|
||||
|
||||
\termitem{lang}{Lang}
|
||||
Define the initial language (i.e.\ pretend there is an \const{xml:lang}
|
||||
declaration in an enclosing element).
|
||||
|
||||
\termitem{ignore_lang}{Bool}
|
||||
If \const{true}, \const{xml:lang} declarations in the document are
|
||||
ignored. This is mostly for compatibility with older versions of
|
||||
this library that did not support language identifiers.
|
||||
|
||||
\termitem{convert_typed_literal}{:ConvertPred}
|
||||
If the parser finds a literal with the \const{rdf:datatype}=\arg{Type}
|
||||
attribute, call \term{ConvertPred}{+Type, +Content, -Literal}.
|
||||
\arg{Content} is the XML element contentas returned by the XML
|
||||
parser (a list). The predicate must unify \arg{Literal}
|
||||
with a Prolog representation of \arg{Content} according to
|
||||
\arg{Type} or throw an exception if the conversion cannot be made.
|
||||
|
||||
This option servers two purposes. First of all it can be used
|
||||
to ignore type declarations for backward compatibility of this
|
||||
library. Second it can be used to convert typed literals to
|
||||
a meaningful Prolog representation. E.g.\ convert '42' to the
|
||||
Prolog integer 42 if the type is \const{xsd:int} or a related
|
||||
type.
|
||||
|
||||
\termitem{namespaces}{-List}
|
||||
Unify \arg{List} with a list of \arg{NS}=\arg{URL} for each
|
||||
encountered \const{xmlns}:\arg{NS}=\arg{URL} declaration found
|
||||
in the source.
|
||||
|
||||
\termitem{entity}{+Name, +Value}
|
||||
Overrule entity declaration in file. As it is common practice
|
||||
to declare namespaces using entities in RDF/XML, this option
|
||||
allows for changing the namespace without changing the file.
|
||||
Multiple of these options are allowed.
|
||||
\end{description}
|
||||
|
||||
The \arg{Triples} list is a list of \term{rdf}{Subject, Predicate,
|
||||
Object} triples. \arg{Subject} is either a plain resource (an atom),
|
||||
or one of the terms \term{each}{URI} or \term{prefix}{URI} with the
|
||||
obvious meaning. \arg{Predicate} is either a plain atom for
|
||||
explicitely non-qualified names or a term
|
||||
\mbox{\arg{NameSpace}{\bf :}\arg{Name}}. If \arg{NameSpace} is the
|
||||
defined RDF name space it is returned as the atom \const{rdf}.
|
||||
Finally, \arg{Object} is a URI, a \arg{Predicate} or a term of the
|
||||
format \term{literal}{Value} for literal values. \arg{Value} is
|
||||
either a plain atom or a parsed XML term (list of atoms and elements).
|
||||
\end{description}
|
||||
|
||||
|
||||
\subsection{RDF Object representation} \label{sec:rdfobject}
|
||||
|
||||
The \emph{Object} (3rd) part of a triple can have several different
|
||||
types. If the object is a resource it is returned as either a plain
|
||||
atom or a term \mbox{\arg{NameSpace}{\bf :}\arg{Name}}. If it is a
|
||||
literal it is returned as \term{literal}{Value}, where \arg{Value}
|
||||
takes one of the formats defined below.
|
||||
|
||||
\begin{itemlist}
|
||||
\item [An atom]
|
||||
If the literal \arg{Value} is a plain atom is a literal value not
|
||||
subject to a datatype or \const{xml:lang} qualifier.
|
||||
|
||||
\item [\term{lang}{LanguageID, Atom}]
|
||||
If the literal is subject to an \const{xml:lang} qualifier
|
||||
\arg{LanguageID} specifies the language and \arg{Atom} the
|
||||
actual text.
|
||||
|
||||
\item [A list]
|
||||
If the literal is an XML literal as created by
|
||||
\mbox{parseType="Literal"}, the raw output of the XML parser for the
|
||||
content of the element is returned. This content is a list of
|
||||
\term{element}{Name, Attributes, Content} and atoms for CDATA parts as
|
||||
described with the SWI-Prolog \url[SGML/XML
|
||||
parser]{http://www.swi-prolog.org/packages/sgml2pl.html}
|
||||
|
||||
\item [\term{type}{Type, StringValue}]
|
||||
If the literal has an \verb$rdf:datatype=$\arg{Type} a term of this
|
||||
format is returned.
|
||||
\end{itemlist}
|
||||
|
||||
|
||||
\subsection{Name spaces}
|
||||
|
||||
XML name spaces are identified using a URI. Unfortunately various URI's
|
||||
are in common use to refer to RDF. The \file{rdf_parser.pl} module
|
||||
therefore defines the namespace as a multifile/1 predicate, that can be
|
||||
extended by the user. For example, to parse the \url[Netscape
|
||||
OpenDirectory]{http://www.mozilla.org/rdf/doc/inference.html}
|
||||
\file{structure.rdf} file, the following declarations are used:
|
||||
|
||||
\begin{code}
|
||||
:- multifile
|
||||
rdf_parser:rdf_name_space/1.
|
||||
|
||||
rdf_parser:rdf_name_space('http://www.w3.org/TR/RDF/').
|
||||
rdf_parser:rdf_name_space('http://directory.mozilla.org/rdf').
|
||||
rdf_parser:rdf_name_space('http://dmoz.org/rdf').
|
||||
\end{code}
|
||||
|
||||
The initial definition of this predicate is given below.
|
||||
|
||||
\begin{code}
|
||||
rdf_name_space('http://www.w3.org/1999/02/22-rdf-syntax-ns#').
|
||||
rdf_name_space('http://www.w3.org/TR/REC-rdf-syntax').
|
||||
\end{code}
|
||||
|
||||
|
||||
\subsection{Low-level access}
|
||||
|
||||
The above defined load_rdf/[2,3] is not always suitable. For example, it
|
||||
cannot deal with documents where the RDF statement is embedded in an XML
|
||||
document. It also cannot deal with really large documents (e.g.\ the
|
||||
Netscape OpenDirectory project, currently about 90 MBytes), without huge
|
||||
amounts of memory.
|
||||
|
||||
For really large documents, the {\bf sgml2pl} parser can be programmed
|
||||
to handle the content of a specific element (i.e. \elem{rdf:RDF})
|
||||
element-by-element. The parsing primitives defined in this section
|
||||
can be used to process these one-by-one.
|
||||
|
||||
\begin{description}
|
||||
\predicate{xml_to_rdf}{3}{+XML, +BaseURI, -Triples}
|
||||
Process an XML term produced by load_structure/3 using the
|
||||
\term{dialect}{xmlns} output option. \arg{XML} is either
|
||||
a complete \elem{rdf:RDF} element, a list of RDF-objects
|
||||
(container or description) or a single description of container.
|
||||
|
||||
\predicate{process_rdf}{3}{+Input, :OnTriples, +Options}
|
||||
|
||||
Exploits the call-back interface of {\bf sgml2pl}, calling
|
||||
\term{\arg{OnTriples}}{Triples, File:Line} with the list of triples
|
||||
resulting from a single top level RDF object for each RDF element in the
|
||||
input as well as the source-location where the description started.
|
||||
\arg{Input} is either a file name or term \term{stream}{Stream}. When
|
||||
using a stream all triples are associated to the value of the
|
||||
\const{base_uri} option. This predicate can be used to process arbitrary
|
||||
large RDF files as the file is processed object-by-object. The example
|
||||
below simply asserts all triples into the database:
|
||||
|
||||
\begin{code}
|
||||
assert_list([], _).
|
||||
assert_list([H|T], Source) :-
|
||||
assert(H),
|
||||
assert_list(T, Source).
|
||||
|
||||
?- process_rdf('structure,rdf', assert_list, []).
|
||||
\end{code}
|
||||
|
||||
\arg{Options} are described with load_rdf/3. The option
|
||||
\const{expand_foreach} is not supported as the container may be in a
|
||||
different description. Additional it provides \const{embedded}:
|
||||
|
||||
\begin{description}
|
||||
\termitem{embedded}{Boolean}
|
||||
The predicate process_rdf/3 processes arbitrary XML documents, only
|
||||
interpreting the content of \const{rdf:RDF} elements. If this option
|
||||
is \const{false} (default), it gives a warning on elements that are
|
||||
not processed. The option \term{embedded}{true} can be used to
|
||||
process RDF embedded in \jargon{xhtml} without warnings.
|
||||
\end{description}
|
||||
|
||||
\end{description}
|
||||
|
||||
|
||||
|
||||
|
||||
\section{Writing RDF graphs}
|
||||
|
||||
The library \pllib{rdf_write} provides the inverse of load_rdf/2 using
|
||||
the predicate rdf_write_xml/2. In most cases the RDF parser is used in
|
||||
combination with the Semweb package providing \pllib{semweb/rdf_db}.
|
||||
This library defines rdf_save/2 to save a named RDF graph from the
|
||||
database to a file. This library writes a list of rdf terms to a stream.
|
||||
It has been developed for the SeRQL server which computes an RDF graph
|
||||
that needs to be transmitted in an HTTP request. As we see this as a
|
||||
typical use-case scenario the library only provides writing to a stream.
|
||||
|
||||
\begin{description}
|
||||
\predicate{rdf_write_xml}{2}{+Stream, +Triples}
|
||||
Write an RDF/XML document to \arg{Stream} from the list of \arg{Triples}.
|
||||
\arg{Stream} must use one of the following Prolog stream encodings:
|
||||
\const{ascii}, \const{iso_latin_1} or \const{utf8}. Characters that
|
||||
cannot be represented in the encoding are represented as XML entities.
|
||||
Using ASCII is a good idea for documents that can be represented almost
|
||||
completely in ASCII. For more international documents using UTF-8 creates
|
||||
a more compact document that is easier to read.
|
||||
|
||||
\begin{code}
|
||||
rdf_write(File, Triples) :-
|
||||
open(File, write, Out, [encoding(utf8)]),
|
||||
call_cleanup(rdf_write_xml(Out, Triples),
|
||||
close(Out)).
|
||||
\end{code}
|
||||
\end{description}
|
||||
|
||||
|
||||
\section{Testing the RDF translator}
|
||||
|
||||
A test-suite and driver program are provided by \file{rdf_test.pl} in
|
||||
the source directory. To run these tests, load this file into Prolog in
|
||||
the distribution directory. The test files are in the directory
|
||||
\file{suite} and the proper output in \file{suite/ok}. Predicates
|
||||
provided by \file{rdf_test.pl}:
|
||||
|
||||
\begin{description}
|
||||
\predicate{suite}{1}{+N}
|
||||
Run test \arg{N} using the file \file{suite/tN.rdf} and display the
|
||||
RDF source, the intermediate Prolog representation and the resulting
|
||||
triples.
|
||||
\predicate{passed}{1}{+N}
|
||||
Process \file{suite/tN.rdf} and store the resulting triples in
|
||||
\file{suite/ok/tN.pl} for later validation by test/0.
|
||||
\predicate{test}{0}{}
|
||||
Run all tests and classify the result.
|
||||
\end{description}
|
||||
|
||||
\appendix
|
||||
|
||||
\section{Metrics}
|
||||
|
||||
It took three days to write and one to document the Prolog RDF parser.
|
||||
A significant part of the time was spent understanding the RDF
|
||||
specification.
|
||||
|
||||
The size of the source (including comments) is given in the table
|
||||
below.
|
||||
|
||||
\begin{center}
|
||||
\begin{tabular}{|rrr|l|l|}
|
||||
\hline
|
||||
\bf lines & \bf words & \bf bytes & \bf file & \bf function \\
|
||||
\hline
|
||||
109 & 255 & 2663 & rdf.pl & Driver program \\
|
||||
312 & 649 & 6416 & rdf_parser.pl & 1-st phase parser \\
|
||||
246 & 752 & 5852 & rdf_triple.pl & 2-nd phase parser \\
|
||||
126 & 339 & 2596 & rewrite.pl & rule-compiler \\
|
||||
\hline
|
||||
793 & 1995 & 17527 & total & \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
|
||||
We also compared the performance using an RDF-Schema file generated by
|
||||
\url[Protege-2000]{http://www.smi.stanford.edu/projects/protege/} and
|
||||
interpreted as RDF. This file contains 162 descriptions in 50 Kbytes,
|
||||
resulting in 599 triples. Environment: Intel Pentium-II/450 with
|
||||
384 Mbytes memory running SuSE Linux 6.3.
|
||||
|
||||
The parser described here requires 0.15 seconds excluding 0.13 seconds
|
||||
Prolog startup time to process this file. The \url[Pro
|
||||
Solutions]{http://www.pro-solutions.com/rdfdemo/} parser (written in
|
||||
Perl) requires 1.5 seconds exluding 0.25 seconds startup time.
|
||||
|
||||
|
||||
\section{Installation}
|
||||
|
||||
\subsection{Unix systems}
|
||||
|
||||
Installation on Unix system uses the commonly found {\em configure},
|
||||
{\em make} and {\em make install} sequence. SWI-Prolog should be
|
||||
installed before building this package. If SWI-Prolog is not installed
|
||||
as \program{pl}, the environment variable \env{PL} must be set to the
|
||||
name of the SWI-Prolog executable. Installation is now accomplished
|
||||
using:
|
||||
|
||||
\begin{code}
|
||||
% ./configure
|
||||
% make
|
||||
% make install
|
||||
\end{code}
|
||||
|
||||
This installs the Prolog library files in \file{$PLBASE/library}, where
|
||||
\file{$PLBASE} refers to the SWI-Prolog `home-directory'.
|
||||
|
||||
\subsection{Windows}
|
||||
|
||||
Run the file \file{setup.pl} by double clicking it. This will install
|
||||
the required files into the SWI-Prolog directory and update the
|
||||
library directory.
|
||||
|
||||
\end{document}
|
||||
|
||||
|
492
packages/sgml/RDF/rdf_diagram.pl
Normal file
492
packages/sgml/RDF/rdf_diagram.pl
Normal file
@ -0,0 +1,492 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog SGML/XML parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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-2002 SWI, University of Amsterdam. All rights reserved.
|
||||
*/
|
||||
|
||||
:- module(rdf_diagram,
|
||||
[ rdf_diagram_from_file/1 % +File
|
||||
]).
|
||||
:- use_module(library(pce)).
|
||||
:- use_module(library(pce_tagged_connection)).
|
||||
:- use_module(library(autowin)).
|
||||
:- use_module(library(pce_report)).
|
||||
:- use_module(library(print_graphics)).
|
||||
:- use_module(library(rdf_parser)). % get access to declared namespaces
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
This file defines the class rdf_diagram, a window capable of showing a
|
||||
set of triples.
|
||||
|
||||
The predicate rdf_diagram_from_file(+File) is a simple demo and useful
|
||||
tool to show RDF from simple RDF files.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
/*******************************
|
||||
* SIMPLE ENTRY *
|
||||
*******************************/
|
||||
|
||||
% rdf_diagram_from_file(+File)
|
||||
%
|
||||
% Show the triples from File in a window.
|
||||
|
||||
rdf_diagram_from_file(File) :-
|
||||
absolute_file_name(File,
|
||||
[ access(read),
|
||||
extensions([rdf,rdfs,owl,''])
|
||||
], AbsFile),
|
||||
load_rdf(AbsFile, Triples,
|
||||
[ expand_foreach(true)
|
||||
]),
|
||||
new(D, rdf_diagram(string('RDF diagram for %s', File))),
|
||||
send(new(report_dialog), below, D),
|
||||
send(D, triples, Triples),
|
||||
send(D, open).
|
||||
|
||||
|
||||
/*******************************
|
||||
* CLASS RDF-DIAGRAM *
|
||||
*******************************/
|
||||
|
||||
:- pce_begin_class(rdf_diagram, auto_sized_picture,
|
||||
"Show set of RDF triples in a window").
|
||||
:- use_class_template(print_graphics).
|
||||
|
||||
variable(auto_layout, bool := @on, both, "Automatically layout on resize").
|
||||
variable(type_in_node, bool := @on, both, "Display type inside node").
|
||||
|
||||
initialise(D, Label:[name]) :->
|
||||
send_super(D, initialise, Label),
|
||||
send(D, scrollbars, both),
|
||||
send(D, fill_popup),
|
||||
send(D, resize_message,
|
||||
if(and(D?auto_layout == @on,
|
||||
D?focus_recogniser == @nil),
|
||||
message(D, layout))).
|
||||
|
||||
fill_popup(D) :->
|
||||
send(D, popup, new(P, popup)),
|
||||
send_list(P, append,
|
||||
[ menu_item(layout, message(D, layout)),
|
||||
gap,
|
||||
menu_item(print, message(D, print))
|
||||
]).
|
||||
|
||||
:- pce_group(triples).
|
||||
|
||||
append(D, Triple:prolog) :->
|
||||
"Append and rdf(Subject, Predicate, Object) triple"::
|
||||
( subject_name(Triple, SubjectName),
|
||||
get(D, resource, SubjectName, Subject),
|
||||
( get(D, type_in_node, @on),
|
||||
is_type(Triple)
|
||||
-> object_resource(Triple, ObjectName),
|
||||
send(Subject, type, ObjectName)
|
||||
; predicate_name(Triple, PredName),
|
||||
( object_resource(Triple, ObjectName)
|
||||
-> get(D, resource, ObjectName, Object)
|
||||
; object_literal(Triple, Literal)
|
||||
-> get(D, literal, Literal, Object)
|
||||
),
|
||||
send(Subject, connect, PredName, Object)
|
||||
)
|
||||
-> true
|
||||
; term_to_atom(Triple, Atom),
|
||||
ignore(send(D, report, error,
|
||||
'Failed to display triple: %s', Atom))
|
||||
).
|
||||
|
||||
triples(D, Triples:prolog) :->
|
||||
"Show disgram from Prolog triples"::
|
||||
send(D, clear),
|
||||
forall(member(T, Triples),
|
||||
send(D, append, T)),
|
||||
send(D, layout).
|
||||
|
||||
resource(D, Resource:name) :->
|
||||
"Add Resource to diagram"::
|
||||
get(D, resource, Resource, @on, _).
|
||||
|
||||
resource(D, Resource:name, Create:[bool], Subject:rdf_resource) :<-
|
||||
"Get reference for a subject or create one"::
|
||||
( get(D, member, Resource, Subject)
|
||||
-> true
|
||||
; Create \== @off,
|
||||
get(D, create_resource, Resource, Subject),
|
||||
send(D, display, Subject, D?visible?center)
|
||||
).
|
||||
|
||||
literal(D, Value:prolog, Gr:rdf_literal) :<-
|
||||
"Display a literal. Don't try to re-use"::
|
||||
( literal_name(Value, Name),
|
||||
get(D, member, Name, Gr)
|
||||
-> true
|
||||
; get(D, create_literal, Value, Gr),
|
||||
send(D, display, Gr, D?visible?center)
|
||||
).
|
||||
|
||||
|
||||
create_resource(D, Resource:name, Subject:rdf_resource) :<-
|
||||
"Create visualisation of Resource"::
|
||||
new(Subject, rdf_resource(Resource, D)).
|
||||
|
||||
|
||||
create_literal(_D, Value:prolog, Gr:rdf_literal) :<-
|
||||
"Create visualisation of literal"::
|
||||
new(Gr, rdf_literal(Value)).
|
||||
|
||||
|
||||
node_label(_D, Resource:name, Label:name) :<-
|
||||
"Generate label to show for a node"::
|
||||
local_name(Resource, Label).
|
||||
|
||||
|
||||
:- pce_group(layout).
|
||||
|
||||
layout(D) :->
|
||||
"Produce automatic layout"::
|
||||
new(Nodes, chain),
|
||||
send(D?graphicals, for_all,
|
||||
if(message(@arg1, instance_of, rdf_any),
|
||||
message(Nodes, append, @arg1))),
|
||||
send(Nodes?head, layout, 2, 40,
|
||||
iterations := 200,
|
||||
area := D?visible,
|
||||
network := Nodes).
|
||||
|
||||
copy_layout(D, From:rdf_diagram, Subst:prolog) :->
|
||||
"Copy the layout from another windows"::
|
||||
send(D?graphicals, for_some,
|
||||
message(D, copy_location, @arg1, From, prolog(Subst))).
|
||||
|
||||
copy_location(_D, Obj:graphical, From:rdf_diagram, Subst:prolog) :->
|
||||
"Copy location of a single RDF object"::
|
||||
( send(Obj, instance_of, rdf_any)
|
||||
-> ( get(Obj, name, Name),
|
||||
find(From, Name, Subst, FromObj)
|
||||
-> format('Copied location of ~p from ~p~n', [Obj, FromObj]),
|
||||
get(FromObj, center, Center),
|
||||
send(Obj, center, Center)
|
||||
)
|
||||
; true
|
||||
).
|
||||
|
||||
find(D, Name, _Subst, Obj) :-
|
||||
get(D, member, Name, Obj).
|
||||
find(D, Name, Subst, Obj) :-
|
||||
member(Name=AltName, Subst),
|
||||
atom_concat('_:', AltName, FullAltName),
|
||||
get(D, member, FullAltName, Obj).
|
||||
find(D, Name, Subst, _) :-
|
||||
format('Cannot find ~w in ~p, Subst =~n', [Name, D]),
|
||||
pp(Subst),
|
||||
fail.
|
||||
|
||||
|
||||
:- pce_end_class(rdf_diagram).
|
||||
|
||||
|
||||
/*******************************
|
||||
* SHAPES *
|
||||
*******************************/
|
||||
|
||||
:- pce_begin_class(rdf_connection, tagged_connection,
|
||||
"Represents a triple").
|
||||
|
||||
:- pce_global(@rdf_link, new(link(link, link,
|
||||
line(0,0,0,0,second)))).
|
||||
|
||||
initialise(C, Gr1:graphical, Gr2:graphical, Pred:name, Ctx:[object]) :->
|
||||
"Create from predicate"::
|
||||
send_super(C, initialise, Gr1, Gr2, @rdf_link),
|
||||
send(C, tag, rdf_label(Pred, italic, Ctx)).
|
||||
|
||||
ideal_length(C, Len:int) :<-
|
||||
"Layout: compute the desired length"::
|
||||
get(C, height, H),
|
||||
( H < 40
|
||||
-> get(C, tag, Tag),
|
||||
get(Tag, width, W),
|
||||
Len is W + 30
|
||||
; Len = 40
|
||||
).
|
||||
|
||||
:- pce_end_class(rdf_connection).
|
||||
|
||||
:- pce_begin_class(rdf_any(name), figure,
|
||||
"Represent an RDF resource or literal").
|
||||
|
||||
handle(w/2, 0, link, north).
|
||||
handle(w, h/2, link, east).
|
||||
handle(w/2, h, link, south).
|
||||
handle(0, h/2, link, west).
|
||||
|
||||
initialise(F, Ref:name) :->
|
||||
"Create visualisation"::
|
||||
send_super(F, initialise),
|
||||
send(F, name, Ref).
|
||||
|
||||
connect(F, Pred:name, Object:graphical) :->
|
||||
new(_C, rdf_connection(F, Object, Pred, F)).
|
||||
|
||||
:- pce_global(@rdf_any_recogniser,
|
||||
make_rdf_any_recogniser).
|
||||
:- pce_global(@rdf_any_popup,
|
||||
make_rdf_any_popup).
|
||||
|
||||
make_rdf_any_recogniser(G) :-
|
||||
new(M1, move_gesture(left)),
|
||||
new(M2, move_network_gesture(left, c)),
|
||||
new(P, popup_gesture(@receiver?popup)),
|
||||
new(G, handler_group(M1, M2, P)).
|
||||
|
||||
popup(_F, Popup:popup) :<-
|
||||
"Create popup menu"::
|
||||
Popup = @rdf_any_popup.
|
||||
|
||||
make_rdf_any_popup(Popup) :-
|
||||
new(Popup, popup),
|
||||
Gr = @arg1,
|
||||
send(Popup, append,
|
||||
menu_item(layout, message(Gr, layout))).
|
||||
|
||||
event(F, Ev:event) :->
|
||||
( \+ send(Ev, is_a, ms_right_down),
|
||||
send_super(F, event, Ev)
|
||||
-> true
|
||||
; send(@rdf_any_recogniser, event, Ev)
|
||||
).
|
||||
|
||||
node_label(F, Resource:name, Label:name) :<-
|
||||
"Return label to use for a resource"::
|
||||
get(F, device, Dev),
|
||||
( send(Dev, has_get_method, node_label)
|
||||
-> get(Dev, node_label, Resource, Label)
|
||||
; local_name(Resource, Label)
|
||||
).
|
||||
|
||||
:- pce_end_class(rdf_any).
|
||||
|
||||
|
||||
:- pce_begin_class(move_network_gesture, move_gesture,
|
||||
"Move network of connected graphicals").
|
||||
|
||||
variable(outline, box, get,
|
||||
"Box used to indicate move").
|
||||
variable(network, chain*, both,
|
||||
"Stored value of the network").
|
||||
variable(origin, point, get,
|
||||
"Start origin of network").
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
The gesture maintains an outline, the selection to be moved and the
|
||||
positon where the move orginiated. The outline itself is given a
|
||||
normal move_gesture to make it move on dragging. This move_gesture
|
||||
should operate on the same button and modifier.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
initialise(G, B:[button_name], M:[modifier]) :->
|
||||
send(G, send_super, initialise, B, M),
|
||||
send(G, slot, outline, new(Box, box(0,0))),
|
||||
send(G, slot, origin, point(0,0)),
|
||||
send(Box, texture, dotted),
|
||||
send(Box, recogniser, move_gesture(G?button, G?modifier)).
|
||||
|
||||
initiate(G, Ev:event) :->
|
||||
get(Ev, receiver, Gr),
|
||||
get(Gr, device, Dev),
|
||||
get(G, outline, Outline),
|
||||
get(Gr, network, Network),
|
||||
send(G, network, Network),
|
||||
new(Union, area(0,0,0,0)),
|
||||
send(Network, for_all, message(Union, union, @arg1?area)),
|
||||
send(G?origin, copy, Union?position),
|
||||
send(Outline, area, Union),
|
||||
send(Union, done),
|
||||
send(Dev, display, Outline),
|
||||
ignore(send(Ev, post, Outline)).
|
||||
|
||||
drag(G, Ev) :->
|
||||
send(Ev, post, G?outline).
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Terminate. First undisplay the outline. Next calculate by how much
|
||||
the outline has been dragged and move all objects of the selection by
|
||||
this amount.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
terminate(G, Ev:event) :->
|
||||
ignore(send(G, drag, Ev)),
|
||||
get(G, outline, Outline),
|
||||
send(Outline, device, @nil),
|
||||
get(Outline?area?position, difference, G?origin, Offset),
|
||||
get(G, network, Network),
|
||||
send(Network, for_all, message(@arg1, relative_move, Offset)),
|
||||
send(G, network, @nil).
|
||||
|
||||
:- pce_end_class(move_network_gesture).
|
||||
|
||||
|
||||
|
||||
:- pce_begin_class(rdf_label, text,
|
||||
"Label for an RDF relation").
|
||||
|
||||
variable(resource, name, get, "Represented predicate").
|
||||
|
||||
initialise(L, Pred:name, Font:font, Context:[object]) :->
|
||||
( Context == @default
|
||||
-> local_name(Pred, Label)
|
||||
; get(Context, node_label, Pred, Label)
|
||||
),
|
||||
send_super(L, initialise, Label, center, Font),
|
||||
send(L, slot, resource, Pred),
|
||||
send(L, background, @default).
|
||||
|
||||
:- pce_global(@rdf_label_recogniser,
|
||||
make_rdf_label_recogniser).
|
||||
|
||||
make_rdf_label_recogniser(G) :-
|
||||
new(G, handler_group),
|
||||
send(G, append,
|
||||
handler(area_enter, message(@receiver, identify))),
|
||||
send(G, append,
|
||||
handler(area_exit, message(@receiver, report, status, ''))),
|
||||
send(G, append, popup_gesture(new(P, popup))),
|
||||
send_list(P, append,
|
||||
[ menu_item(copy,
|
||||
message(@display, copy, @arg1?resource))
|
||||
]).
|
||||
|
||||
event(F, Ev:event) :->
|
||||
( send_super(F, event, Ev)
|
||||
-> true
|
||||
; send(@rdf_label_recogniser, event, Ev)
|
||||
).
|
||||
|
||||
identify(L) :->
|
||||
send(L, report, status, '%s', L?resource).
|
||||
|
||||
:- pce_end_class.
|
||||
|
||||
|
||||
|
||||
:- pce_begin_class(rdf_resource, rdf_any,
|
||||
"Represent an RDF resource").
|
||||
|
||||
initialise(F, Ref:name, Ctx:[object]) :->
|
||||
"Create visualisation"::
|
||||
send_super(F, initialise, Ref),
|
||||
send(F, display, ellipse(100, 50), point(-50,-25)),
|
||||
send(F, display, new(T, rdf_label(Ref, normal, Ctx))),
|
||||
send(T, center, point(0,0)).
|
||||
|
||||
type(F, Type:name) :->
|
||||
send(F, display, new(TL, rdf_label(Type, small, F))),
|
||||
send(TL, center, point(0,14)),
|
||||
get(F, member, ellipse, E),
|
||||
send(E, shadow, 2).
|
||||
|
||||
identify(F) :->
|
||||
send(F, report, status, 'Resource %s', F?name).
|
||||
|
||||
:- pce_end_class(rdf_resource).
|
||||
|
||||
|
||||
:- pce_begin_class(rdf_literal, rdf_any,
|
||||
"Represent an RDF literal value").
|
||||
|
||||
variable(value, prolog, get, "Represented literal value").
|
||||
|
||||
initialise(F, Value:prolog) :->
|
||||
"Create visualisation"::
|
||||
send(F, slot, value, Value),
|
||||
literal_label(Value, Label),
|
||||
atom_concat('__lit:', Label, Id),
|
||||
send_super(F, initialise, Id),
|
||||
send(F, display, new(B, box)),
|
||||
send(B, fill_pattern, colour(grey80)),
|
||||
send(B, pen, 0),
|
||||
send(F, display, new(T, text(Label, center))),
|
||||
send(T, center, point(0,0)),
|
||||
send(F, fit).
|
||||
|
||||
literal_label(literal(Value0), Value) :- !,
|
||||
literal_label(Value0, Value).
|
||||
literal_label(xml(Value0), Value) :- !,
|
||||
literal_label(Value0, Value).
|
||||
literal_label(Value, Value) :-
|
||||
atomic(Value), !.
|
||||
literal_label(Value, Label) :-
|
||||
term_to_atom(Value, Label).
|
||||
|
||||
literal_name(Value, Name) :-
|
||||
literal_label(Value, Label),
|
||||
atom_concat('__lit:', Label, Name).
|
||||
|
||||
fit(F) :->
|
||||
"Make box fit contents"::
|
||||
get(F, member, text, Text),
|
||||
get(Text?area, clone, Area),
|
||||
send(Area, increase, 3),
|
||||
get(F, member, box, Box),
|
||||
send(Box, area, Area).
|
||||
|
||||
:- pce_end_class(rdf_literal).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************
|
||||
* PRIMITIVES *
|
||||
*******************************/
|
||||
|
||||
subject_name(rdf(Name0, _, _), Name) :-
|
||||
resource_name(Name0, Name).
|
||||
predicate_name(rdf(_, Name0, _), Name) :-
|
||||
resource_name(Name0, Name).
|
||||
object_resource(rdf(_, _, Name0), Name) :-
|
||||
resource_name(Name0, Name).
|
||||
object_literal(rdf(_,_,Literal), Literal).
|
||||
|
||||
|
||||
resource_name(Name, Name) :-
|
||||
atom(Name), !.
|
||||
resource_name(rdf:Local, Name) :- !, % known namespaces
|
||||
concat_atom([rdf, :, Local], Name).
|
||||
resource_name(NS:Local, Name) :- !,
|
||||
atom_concat(NS, Local, Name).
|
||||
resource_name(node(Anon), Name) :- % Not for predicates
|
||||
atom_concat('_:', Anon, Name).
|
||||
|
||||
is_type(rdf(_, rdf:type, _)) :- !. % our parser
|
||||
is_type(rdf(_, Pred, _)) :- % our parser
|
||||
atom(Pred),
|
||||
rdf_name_space(NS),
|
||||
atom_concat(NS, type, Pred), !.
|
||||
|
||||
% local_name(+Resource, -Label)
|
||||
%
|
||||
% Return easy readable local name
|
||||
|
||||
local_name(Resource, Local) :-
|
||||
sub_atom(Resource, _, _, A, #),
|
||||
sub_atom(Resource, _, A, 0, Local),
|
||||
\+ sub_atom(Local, _, _, _, #), !.
|
||||
local_name(Resource, Local) :-
|
||||
atom_concat('rdf:', Local, Resource), !.
|
||||
local_name(Resource, Local) :-
|
||||
file_base_name(Resource, Local),
|
||||
Local \== ''.
|
||||
local_name(Resource, Resource).
|
||||
|
311
packages/sgml/RDF/rdf_ntriples.pl
Normal file
311
packages/sgml/RDF/rdf_ntriples.pl
Normal file
@ -0,0 +1,311 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog SGML/XML parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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-2002 SWI, University of Amsterdam. All rights reserved.
|
||||
*/
|
||||
|
||||
:- module(rdf_ntriples,
|
||||
[ load_rdf_ntriples/2, % +File, -Triples
|
||||
rdf_ntriple_part/4 % +Field, -Value, <DCG>
|
||||
]).
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
This module parses n-triple files as defined by the W3C RDF working in
|
||||
http://www.w3.org/TR/rdf-testcases/#ntriples. This format is a
|
||||
simplified version of the RDF N3 notation used in the *.nt files that
|
||||
are used to describe the normative outcome of the RDF test-cases.
|
||||
|
||||
The returned list terms are of the form
|
||||
|
||||
rdf(Subject, Predicate, Object)
|
||||
|
||||
where
|
||||
|
||||
# Subject
|
||||
is an atom or node(Id) for anonymous nodes
|
||||
|
||||
# Predicate
|
||||
is an atom
|
||||
|
||||
# Object
|
||||
is an atom, node(Id), literal(Atom) or xml(Atom)
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
% load_rdf_ntriples(+Source, -Triples)
|
||||
%
|
||||
% Load a file or stream to a list of rdf(S,P,O) triples.
|
||||
|
||||
load_rdf_ntriples(File, Triples) :-
|
||||
open_nt_file(File, In, Close),
|
||||
call_cleanup(stream_to_triples(In, Triples), Close).
|
||||
|
||||
% open_nt_file(+Input, -Stream, -Close)
|
||||
%
|
||||
% Open Input, returning Stream and a goal to cleanup Stream if it
|
||||
% was opened.
|
||||
|
||||
open_nt_file(stream(Stream), Stream, true) :- !.
|
||||
open_nt_file(Stream, Stream, true) :-
|
||||
is_stream(Stream), !.
|
||||
open_nt_file(Spec, Stream, close(Stream)) :-
|
||||
absolute_file_name(Spec,
|
||||
[ access(read),
|
||||
extensions([nt,''])
|
||||
], Path),
|
||||
open(Path, read, Stream).
|
||||
|
||||
|
||||
% rdf_ntriple_part(+Type, -Value, <DCG>)
|
||||
%
|
||||
% Parse one of the fields of an ntriple. This is used for the
|
||||
% SWI-Prolog Sesame (www.openrdf.org) implementation to realise
|
||||
% /servlets/removeStatements. I do not think public use of this
|
||||
% predicate should be stimulated.
|
||||
|
||||
rdf_ntriple_part(subject, Subject) -->
|
||||
subject(Subject).
|
||||
rdf_ntriple_part(predicate, Predicate) -->
|
||||
predicate(Predicate).
|
||||
rdf_ntriple_part(object, Object) -->
|
||||
predicate(Object).
|
||||
|
||||
|
||||
% stream_to_triples(+Stream, -ListOfTriples)
|
||||
%
|
||||
% Read Stream, returning all its triples
|
||||
|
||||
stream_to_triples(In, Triples) :-
|
||||
read_line_to_codes(In, Line),
|
||||
( Line == end_of_file
|
||||
-> Triples = []
|
||||
; phrase(line(Triples, Tail), Line),
|
||||
stream_to_triples(In, Tail)
|
||||
).
|
||||
|
||||
line(Triples, Tail) -->
|
||||
wss,
|
||||
( comment
|
||||
-> {Triples = Tail}
|
||||
; triple(Triple)
|
||||
-> {Triples = [Triple|Tail]}
|
||||
).
|
||||
|
||||
comment -->
|
||||
"#", !,
|
||||
skip_rest.
|
||||
comment -->
|
||||
end_of_input.
|
||||
|
||||
triple(rdf(Subject, Predicate, Object)) -->
|
||||
subject(Subject), ws, wss,
|
||||
predicate(Predicate), ws, wss,
|
||||
object(Object), wss, ".", wss.
|
||||
|
||||
subject(Subject) -->
|
||||
uniref(Subject), !.
|
||||
subject(Subject) -->
|
||||
node_id(Subject).
|
||||
|
||||
predicate(Predicate) -->
|
||||
uniref(Predicate).
|
||||
|
||||
object(Object) -->
|
||||
uniref(Object), !.
|
||||
object(Object) -->
|
||||
node_id(Object).
|
||||
object(Object) -->
|
||||
literal(Object).
|
||||
|
||||
|
||||
uniref(URI) -->
|
||||
"<",
|
||||
escaped_uri_codes(Codes),
|
||||
">", !,
|
||||
{ atom_codes(URI, Codes)
|
||||
}.
|
||||
|
||||
node_id(node(Id)) --> % anonymous nodes
|
||||
"_:",
|
||||
name_start(C0),
|
||||
name_codes(Codes),
|
||||
{ atom_codes(Id, [C0|Codes])
|
||||
}.
|
||||
|
||||
literal(Literal) -->
|
||||
lang_string(Literal), !.
|
||||
literal(Literal) -->
|
||||
xml_string(Literal).
|
||||
|
||||
|
||||
% name_start(-Code)
|
||||
% name_codes(-ListfCodes)
|
||||
%
|
||||
% Parse identifier names
|
||||
|
||||
name_start(C) -->
|
||||
[C],
|
||||
{ code_type(C, alpha)
|
||||
}.
|
||||
|
||||
name_codes([C|T]) -->
|
||||
[C],
|
||||
{ code_type(C, alnum)
|
||||
}, !,
|
||||
name_codes(T).
|
||||
name_codes([]) -->
|
||||
[].
|
||||
|
||||
|
||||
% escaped_uri_codes(-CodeList)
|
||||
%
|
||||
% Decode string holding %xx escaped characters.
|
||||
|
||||
escaped_uri_codes([]) -->
|
||||
[].
|
||||
escaped_uri_codes([C|T]) -->
|
||||
"%", [D0,D1], !,
|
||||
{ code_type(D0, xdigit(V0)),
|
||||
code_type(D1, xdigit(V1)),
|
||||
C is V0<<4 + V1
|
||||
},
|
||||
escaped_uri_codes(T).
|
||||
escaped_uri_codes([C|T]) -->
|
||||
"\\u", [D0,D1,D2,D3], !,
|
||||
{ code_type(D0, xdigit(V0)),
|
||||
code_type(D1, xdigit(V1)),
|
||||
code_type(D2, xdigit(V2)),
|
||||
code_type(D3, xdigit(V3)),
|
||||
C is V0<<12 + V1<<8 + V2<<4 + V3
|
||||
},
|
||||
escaped_uri_codes(T).
|
||||
escaped_uri_codes([C|T]) -->
|
||||
[C],
|
||||
escaped_uri_codes(T).
|
||||
|
||||
|
||||
% lang_string()
|
||||
%
|
||||
% Process a language string
|
||||
|
||||
lang_string(String) -->
|
||||
"\"",
|
||||
string(Codes),
|
||||
"\"", !,
|
||||
{ atom_codes(Atom, Codes)
|
||||
},
|
||||
( langsep
|
||||
-> language(Lang),
|
||||
{ String = literal(lang(Lang, Atom))
|
||||
}
|
||||
; "^^"
|
||||
-> uniref(Type),
|
||||
{ String = literal(type(Type, Atom))
|
||||
}
|
||||
; { String = literal(Atom)
|
||||
}
|
||||
).
|
||||
|
||||
langsep -->
|
||||
"-".
|
||||
langsep -->
|
||||
"@".
|
||||
|
||||
% xml_string(String)
|
||||
%
|
||||
% Handle xml"..."
|
||||
|
||||
xml_string(xml(String)) -->
|
||||
"xml\"", % really no whitespace?
|
||||
string(Codes),
|
||||
"\"",
|
||||
{ atom_codes(String, Codes)
|
||||
}.
|
||||
|
||||
string([]) -->
|
||||
[].
|
||||
string([C0|T]) -->
|
||||
string_char(C0),
|
||||
string(T).
|
||||
|
||||
string_char(0'\\) -->
|
||||
"\\\\".
|
||||
string_char(0'") -->
|
||||
"\\\"".
|
||||
string_char(10) -->
|
||||
"\\n".
|
||||
string_char(13) -->
|
||||
"\\r".
|
||||
string_char(9) -->
|
||||
"\\t".
|
||||
string_char(C) -->
|
||||
"\\u",
|
||||
'4xdigits'(C).
|
||||
string_char(C) -->
|
||||
"\\u",
|
||||
'4xdigits'(C0),
|
||||
'4xdigits'(C1),
|
||||
{ C is C0<<16 + C1
|
||||
}.
|
||||
string_char(C) -->
|
||||
[C].
|
||||
|
||||
'4xdigits'(C) -->
|
||||
[C0,C1,C2,C3],
|
||||
{ code_type(C0, xdigit(V0)),
|
||||
code_type(C1, xdigit(V1)),
|
||||
code_type(C2, xdigit(V2)),
|
||||
code_type(C3, xdigit(V3)),
|
||||
|
||||
C is V0<<12 + V1<<8 + V2<<4 + V3
|
||||
}.
|
||||
|
||||
% language(-Lang)
|
||||
%
|
||||
% Return xml:lang language identifier.
|
||||
|
||||
language(Lang) -->
|
||||
lang_code(C0),
|
||||
lang_codes(Codes),
|
||||
{ atom_codes(Lang, [C0|Codes])
|
||||
}.
|
||||
|
||||
lang_code(C) -->
|
||||
[C],
|
||||
{ C \== 0'.,
|
||||
\+ code_type(C, white)
|
||||
}.
|
||||
|
||||
lang_codes([C|T]) -->
|
||||
lang_code(C), !,
|
||||
lang_codes(T).
|
||||
lang_codes([]) -->
|
||||
[].
|
||||
|
||||
|
||||
/*******************************
|
||||
* BASICS *
|
||||
*******************************/
|
||||
|
||||
skip_rest(_,[]).
|
||||
|
||||
ws -->
|
||||
[C],
|
||||
{ code_type(C, white)
|
||||
}.
|
||||
|
||||
end_of_input([], []).
|
||||
|
||||
|
||||
wss -->
|
||||
ws, !,
|
||||
wss.
|
||||
wss -->
|
||||
[].
|
724
packages/sgml/RDF/rdf_parser.pl
Normal file
724
packages/sgml/RDF/rdf_parser.pl
Normal file
@ -0,0 +1,724 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: wielemak@science.uva.nl
|
||||
WWW: http://www.swi-prolog.org
|
||||
Copyright (C): 2002-2006, University of Amsterdam
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
As a special exception, if you link this library with other files,
|
||||
compiled with a Free Software compiler, to produce an executable, this
|
||||
library does not by itself cause the resulting executable to be covered
|
||||
by the GNU General Public License. This exception does not however
|
||||
invalidate any other reasons why the executable file might be covered by
|
||||
the GNU General Public License.
|
||||
*/
|
||||
|
||||
:- module(rdf_parser,
|
||||
[ xml_to_plrdf/3, % +XMLTerm, -RDFTerm, +Options
|
||||
element_to_plrdf/3, % +ContentList, -RDFTerm, +Options
|
||||
rdf_name_space/1
|
||||
]).
|
||||
:- use_module(rewrite).
|
||||
:- use_module(library(sgml)). % xml_name/1
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(library(url)).
|
||||
:- use_module(library(utf8)).
|
||||
|
||||
:- op(500, fx, \?). % Optional (attrs)
|
||||
|
||||
term_expansion(F, T) :- rew_term_expansion(F, T).
|
||||
goal_expansion(F, T) :- rew_goal_expansion(F, T).
|
||||
|
||||
:- multifile rdf_name_space/1.
|
||||
:- dynamic rdf_name_space/1.
|
||||
|
||||
%% rdf_name_space(?URL) is nondet.
|
||||
%
|
||||
% True if URL must be handled as rdf: Determines special handling
|
||||
% of rdf:about, rdf:resource, etc.
|
||||
|
||||
|
||||
rdf_name_space('http://www.w3.org/1999/02/22-rdf-syntax-ns#').
|
||||
rdf_name_space('http://www.w3.org/TR/REC-rdf-syntax').
|
||||
|
||||
|
||||
%% xml_to_plrdf(+RDFElementOrObject, -RDFTerm, +Options)
|
||||
%
|
||||
% Translate an XML (using namespaces) term into an Prolog term
|
||||
% representing the RDF data. This term can then be fed into
|
||||
% rdf_triples/[2,3] to create a list of RDF triples.
|
||||
%
|
||||
% if `BaseURI' == [], local URI's are not globalised.
|
||||
|
||||
|
||||
xml_to_plrdf(Element, RDF, Options) :-
|
||||
is_list(Element), !,
|
||||
rewrite(\xml_content_objects(RDF, Options), Element).
|
||||
xml_to_plrdf(Element, RDF, Options) :-
|
||||
rewrite(\xml_objects(RDF, Options), Element).
|
||||
|
||||
%% element_to_plrdf(+DOM, -RDFTerm, +Options)
|
||||
%
|
||||
% Rewrite a single XML element.
|
||||
|
||||
element_to_plrdf(Element, RDF, Options) :-
|
||||
rewrite(\nodeElementList(RDF, Options), [Element]).
|
||||
|
||||
xml_objects(Objects, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\xml_objects(Objects, Options), E)
|
||||
}.
|
||||
xml_objects(Objects, Options) ::=
|
||||
element((\rdf('RDF'), !),
|
||||
_,
|
||||
\nodeElementList(Objects, Options)),
|
||||
!.
|
||||
xml_objects(Objects, Options) ::=
|
||||
element(_, _, \xml_content_objects(Objects, Options)).
|
||||
|
||||
xml_content_objects([], _) ::=
|
||||
[].
|
||||
xml_content_objects([H|T], Options) ::=
|
||||
[ \xml_objects(H, Options)
|
||||
| \xml_content_objects(T, Options)
|
||||
].
|
||||
|
||||
|
||||
nodeElementList([], _Options) ::=
|
||||
[], !.
|
||||
nodeElementList(L, Options) ::=
|
||||
[ (\ws, !)
|
||||
| \nodeElementList(L, Options)
|
||||
].
|
||||
nodeElementList([H|T], Options) ::=
|
||||
[ \nodeElementOrError(H, Options)
|
||||
| \nodeElementList(T, Options)
|
||||
].
|
||||
|
||||
nodeElementOrError(H, Options) ::=
|
||||
\nodeElement(H, Options), !.
|
||||
nodeElementOrError(unparsed(Data), _Options) ::=
|
||||
Data.
|
||||
|
||||
nodeElement(container(Type, Id, Elements), Options) ::=
|
||||
\container(Type, Id, Elements, Options), !. % compatibility
|
||||
nodeElement(description(Type, About, BagID, Properties), Options) ::=
|
||||
\description(Type, About, BagID, Properties, Options).
|
||||
|
||||
|
||||
/*******************************
|
||||
* DESCRIPTION *
|
||||
*******************************/
|
||||
|
||||
description(Type, About, BagID, Properties, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\description(Type, About, BagID, Properties, Options), E)
|
||||
}.
|
||||
description(description, About, BagID, Properties, Options) ::=
|
||||
element(\rdf('Description'),
|
||||
\attrs([ \?idAboutAttr(About, Options),
|
||||
\?bagIdAttr(BagID, Options)
|
||||
| \propAttrs(PropAttrs, Options)
|
||||
]),
|
||||
\propertyElts(PropElts, Options)),
|
||||
{ !, append(PropAttrs, PropElts, Properties)
|
||||
}.
|
||||
description(Type, About, BagID, Properties, Options) ::=
|
||||
element(Type,
|
||||
\attrs([ \?idAboutAttr(About, Options),
|
||||
\?bagIdAttr(BagID, Options)
|
||||
| \propAttrs(PropAttrs, Options)
|
||||
]),
|
||||
\propertyElts(PropElts, Options)),
|
||||
{ append(PropAttrs, PropElts, Properties)
|
||||
}.
|
||||
|
||||
propAttrs([], _) ::=
|
||||
[], !.
|
||||
propAttrs([H|T], Options) ::=
|
||||
[ \propAttr(H, Options)
|
||||
| \propAttrs(T, Options)
|
||||
].
|
||||
|
||||
propAttr(rdf:type = URI, Options) ::=
|
||||
\rdf_or_unqualified(type) = \uri(URI, Options), !.
|
||||
propAttr(Name = Literal, Options) ::=
|
||||
Name = Value,
|
||||
{ mkliteral(Value, Literal, Options)
|
||||
}.
|
||||
|
||||
propertyElts([], _) ::=
|
||||
[], !.
|
||||
propertyElts(Elts, Options) ::=
|
||||
[ (\ws, !)
|
||||
| \propertyElts(Elts, Options)
|
||||
].
|
||||
propertyElts([H|T], Options) ::=
|
||||
[ \propertyElt(H, Options)
|
||||
| \propertyElts(T, Options)
|
||||
].
|
||||
|
||||
propertyElt(E, Options) ::=
|
||||
\propertyElt(Id, Name, Value, Options),
|
||||
{ mkprop(Name, Value, Prop),
|
||||
( var(Id)
|
||||
-> E = Prop
|
||||
; E = id(Id, Prop)
|
||||
)
|
||||
}.
|
||||
|
||||
mkprop(NS:Local, Value, rdf:Local = Value) :-
|
||||
rdf_name_space(NS), !.
|
||||
mkprop(Name, Value, Name = Value).
|
||||
|
||||
|
||||
propertyElt(Id, Name, Value, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\propertyElt(Id, Name, Value, Options), E)
|
||||
}.
|
||||
% 5.14 emptyPropertyElt
|
||||
propertyElt(Id, Name, Value, Options) ::=
|
||||
element(Name, A, \all_ws),
|
||||
{ !,
|
||||
rewrite(\emptyPropertyElt(Id, Value, Options), A)
|
||||
}.
|
||||
|
||||
propertyElt(_, Name, description(description, Id, _, Properties), Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \parseResource,
|
||||
\?idAboutAttr(Id, Options)
|
||||
]),
|
||||
\propertyElts(Properties, Options)),
|
||||
!.
|
||||
propertyElt(_, Name, Literal, Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \parseLiteral
|
||||
]),
|
||||
Content),
|
||||
{ !,
|
||||
literal_value(Content, Literal, Options)
|
||||
}.
|
||||
propertyElt(Id, Name, collection(Elements), Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \parseCollection,
|
||||
\?idAttr(Id, Options)
|
||||
]),
|
||||
\nodeElementList(Elements, Options)).
|
||||
propertyElt(Id, Name, Literal, Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \typeAttr(Type, Options),
|
||||
\?idAttr(Id, Options)
|
||||
]),
|
||||
Content),
|
||||
{ typed_literal(Type, Content, Literal, Options)
|
||||
}.
|
||||
propertyElt(Id, Name, Literal, Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \?idAttr(Id, Options)
|
||||
]),
|
||||
[ Value ]),
|
||||
{ atom(Value), !,
|
||||
mkliteral(Value, Literal, Options)
|
||||
}.
|
||||
propertyElt(Id, Name, Value, Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \?idAttr(Id, Options)
|
||||
]),
|
||||
\an_rdf_object(Value, Options)), !.
|
||||
propertyElt(Id, Name, unparsed(Value), Options) ::=
|
||||
element(Name,
|
||||
\attrs([ \?idAttr(Id, Options)
|
||||
]),
|
||||
Value).
|
||||
|
||||
emptyPropertyElt(Id, Literal, Options) ::=
|
||||
\attrs([ \?idAttr(Id, Options),
|
||||
\?parseLiteral
|
||||
| \noMoreAttrs
|
||||
]),
|
||||
{ !,
|
||||
mkliteral('', Literal, Options)
|
||||
}.
|
||||
emptyPropertyElt(Id,
|
||||
description(description, About, BagID, Properties),
|
||||
Options) ::=
|
||||
\attrs([ \?idAttr(Id, Options),
|
||||
\?aboutResourceEmptyElt(About, Options),
|
||||
\?bagIdAttr(BagID, Options),
|
||||
\?parseResource
|
||||
| \propAttrs(Properties, Options)
|
||||
]), !.
|
||||
|
||||
aboutResourceEmptyElt(about(URI), Options) ::=
|
||||
\resourceAttr(URI, Options), !.
|
||||
aboutResourceEmptyElt(node(URI), _Options) ::=
|
||||
\nodeIDAttr(URI).
|
||||
|
||||
%% literal_value(+In, -Value, +Options)
|
||||
%
|
||||
% Create the literal value for rdf:parseType="Literal" attributes.
|
||||
% The content is the Prolog XML DOM tree for the literal.
|
||||
%
|
||||
% @tbd Note that the specs demand a canonical textual representation
|
||||
% of the XML data as a Unicode string. For now the user can
|
||||
% achieve this using the convert_typed_literal hook.
|
||||
|
||||
literal_value(Value, literal(type(rdf:'XMLLiteral', Value)), _).
|
||||
|
||||
%% mkliteral(+Atom, -Object, +Options)
|
||||
%
|
||||
% Translate attribute value Atom into an RDF object using the
|
||||
% lang(Lang) option from Options.
|
||||
|
||||
mkliteral(Text, literal(Val), Options) :-
|
||||
atom(Text),
|
||||
( memberchk(lang(Lang), Options),
|
||||
Lang \== ''
|
||||
-> Val = lang(Lang, Text)
|
||||
; Val = Text
|
||||
).
|
||||
|
||||
%% typed_literal(+Type, +Content, -Literal, +Options)
|
||||
%
|
||||
% Handle a literal attribute with rdf:datatype=Type qualifier. NB:
|
||||
% possibly it is faster to use a global variable for the
|
||||
% conversion hook.
|
||||
|
||||
typed_literal(Type, Content, literal(Object), Options) :-
|
||||
memberchk(convert_typed_literal(Convert), Options), !,
|
||||
( catch(call(Convert, Type, Content, Object), E, true)
|
||||
-> ( var(E)
|
||||
-> true
|
||||
; Object = E
|
||||
)
|
||||
; Object = error(cannot_convert(Type, Content), _)
|
||||
).
|
||||
typed_literal(Type, [Text], literal(type(Type, Text)), _Options) :- !.
|
||||
typed_literal(Type, Content, literal(type(Type, Content)), _Options).
|
||||
|
||||
|
||||
idAboutAttr(id(Id), Options) ::=
|
||||
\idAttr(Id, Options), !.
|
||||
idAboutAttr(about(About), Options) ::=
|
||||
\aboutAttr(About, Options), !.
|
||||
idAboutAttr(node(About), _Options) ::=
|
||||
\nodeIDAttr(About), !.
|
||||
idAboutAttr(AboutEach, Options) ::=
|
||||
\aboutEachAttr(AboutEach, Options).
|
||||
|
||||
%% an_rdf_object(-Object, +OptionsURI)
|
||||
%
|
||||
% Deals with an object, but there may be spaces around. I'm still
|
||||
% not sure where to deal with these. Best is to ask the XML parser
|
||||
% to get rid of them, So most likely this code will change if this
|
||||
% happens.
|
||||
|
||||
an_rdf_object(Object, Options) ::=
|
||||
[ \nodeElement(Object, Options)
|
||||
], !.
|
||||
an_rdf_object(Object, Options) ::=
|
||||
[ (\ws, !)
|
||||
| \an_rdf_object(Object, Options)
|
||||
].
|
||||
an_rdf_object(Object, Options) ::=
|
||||
[ \nodeElement(Object, Options),
|
||||
\ws
|
||||
], !.
|
||||
|
||||
ws ::=
|
||||
A,
|
||||
{ atom(A),
|
||||
atom_chars(A, Chars),
|
||||
all_blank(Chars), !
|
||||
}.
|
||||
ws ::=
|
||||
pi(_).
|
||||
|
||||
all_ws ::=
|
||||
[], !.
|
||||
all_ws ::=
|
||||
[\ws | \all_ws].
|
||||
|
||||
all_blank([]).
|
||||
all_blank([H|T]) :-
|
||||
char_type(H, space), % SWI-Prolog specific
|
||||
all_blank(T).
|
||||
|
||||
|
||||
/*******************************
|
||||
* RDF ATTRIBUTES *
|
||||
*******************************/
|
||||
|
||||
idAttr(Id, Options) ::=
|
||||
\rdf_or_unqualified('ID') = \uniqueid(Id, Options).
|
||||
|
||||
bagIdAttr(Id, Options) ::=
|
||||
\rdf_or_unqualified(bagID) = \globalid(Id, Options).
|
||||
|
||||
aboutAttr(About, Options) ::=
|
||||
\rdf_or_unqualified(about) = \uri(About, Options).
|
||||
|
||||
nodeIDAttr(About) ::=
|
||||
\rdf_or_unqualified(nodeID) = About.
|
||||
|
||||
% Not allowed in current RDF!
|
||||
|
||||
aboutEachAttr(each(AboutEach), Options) ::=
|
||||
\rdf_or_unqualified(aboutEach) = \uri(AboutEach, Options), !.
|
||||
aboutEachAttr(prefix(Prefix), Options) ::=
|
||||
\rdf_or_unqualified(aboutEachPrefix) = \uri(Prefix, Options), !.
|
||||
|
||||
resourceAttr(URI, Options) ::=
|
||||
\rdf_or_unqualified(resource) = \uri(URI, Options).
|
||||
|
||||
typeAttr(Type, Options) ::=
|
||||
\rdf_or_unqualified(datatype) = \uri(Type, Options).
|
||||
|
||||
uri(URI, Options) ::=
|
||||
A,
|
||||
{ memberchk(base_uri(Base), Options),
|
||||
Base \== []
|
||||
-> canonical_uri(A, Base, URI)
|
||||
; sub_atom(A, 0, _, _, #)
|
||||
-> sub_atom(A, 1, _, 0, URI)
|
||||
; url_iri(A, URI)
|
||||
}.
|
||||
|
||||
globalid(Id, Options) ::=
|
||||
A,
|
||||
{ make_globalid(A, Options, Id)
|
||||
}.
|
||||
|
||||
uniqueid(Id, Options) ::=
|
||||
A,
|
||||
{ unique_xml_name(A),
|
||||
make_globalid(A, Options, Id)
|
||||
}.
|
||||
|
||||
unique_xml_name(Name) :-
|
||||
( xml_name(Name)
|
||||
-> true
|
||||
; print_message(warning, rdf(not_a_name(Name)))
|
||||
).
|
||||
|
||||
make_globalid(In, Options, Id) :-
|
||||
( memberchk(base_uri(Base), Options),
|
||||
Base \== []
|
||||
-> ( is_absolute_url(In)
|
||||
-> url_iri(In, Id)
|
||||
; concat_atom([Base, In], #, Id0),
|
||||
url_iri(Id0, Id)
|
||||
)
|
||||
; sub_atom(In, 0, _, _, #)
|
||||
-> sub_atom(In, 1, _, 0, Id)
|
||||
; url_iri(In, Id)
|
||||
).
|
||||
|
||||
|
||||
%% canonical_uri(+In, +Base, -Absolute)
|
||||
%
|
||||
% Make the URI absolute and decode special sequences. For the last
|
||||
% clause, which is the correct order?
|
||||
|
||||
canonical_uri('', Base, Base) :- !. % '' expands to xml:base
|
||||
canonical_uri(URI0, [], URI) :- !, % do not use one
|
||||
url_iri(URI0, URI).
|
||||
canonical_uri(URI, Base, Global) :- % use our generic library
|
||||
global_url(URI, Base, Global0),
|
||||
url_iri(Global0, Global).
|
||||
|
||||
|
||||
/*******************************
|
||||
* CONTAINERS *
|
||||
*******************************/
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Note that containers are no longer part of the definition. We'll keep
|
||||
the code and call it conditionally if we must.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
container(_, _, _, _) ::=
|
||||
_,
|
||||
{ \+ current_prolog_flag(rdf_container, true),
|
||||
!, fail
|
||||
}.
|
||||
container(Type, Id, Elements, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\container(Type, Id, Elements, Options), E)
|
||||
}.
|
||||
container(Type, Id, Elements, Options) ::=
|
||||
element(\containertype(Type),
|
||||
\attrs([ \?idAttr(Id, Options)
|
||||
| \memberAttrs(Elements)
|
||||
]),
|
||||
[]), !.
|
||||
container(Type, Id, Elements, Options) ::=
|
||||
element(\containertype(Type),
|
||||
\attrs([ \?idAttr(Id, Options)
|
||||
]),
|
||||
\memberElts(Elements, Options)).
|
||||
|
||||
containertype(Type) ::=
|
||||
\rdf(Type),
|
||||
{ containertype(Type)
|
||||
}.
|
||||
|
||||
containertype('Bag').
|
||||
containertype('Seq').
|
||||
containertype('Alt').
|
||||
|
||||
memberElts([], _) ::=
|
||||
[].
|
||||
memberElts([H|T], Options) ::=
|
||||
[ \memberElt(H, Options)
|
||||
| \memberElts(T, Options)
|
||||
].
|
||||
|
||||
memberElt(LI, Options) ::=
|
||||
\referencedItem(LI, Options).
|
||||
memberElt(LI, Options) ::=
|
||||
\inlineItem(LI, Options).
|
||||
|
||||
referencedItem(LI, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\referencedItem(LI, Options), E)
|
||||
}.
|
||||
referencedItem(LI, Options) ::=
|
||||
element(\rdf_or_unqualified(li),
|
||||
[ \resourceAttr(LI, Options) ],
|
||||
[]).
|
||||
|
||||
inlineItem(Item, Options0) ::=
|
||||
E0,
|
||||
{ modify_state(E0, Options0, E, Options), !,
|
||||
rewrite(\inlineItem(Item, Options), E)
|
||||
}.
|
||||
inlineItem(Literal, Options) ::=
|
||||
element(\rdf_or_unqualified(li),
|
||||
[ \parseLiteral ],
|
||||
Value),
|
||||
literal_value(Value, Literal, Options).
|
||||
inlineItem(description(description, _, _, Properties), Options) ::=
|
||||
element(\rdf_or_unqualified(li),
|
||||
[ \parseResource ],
|
||||
\propertyElts(Properties, Options)).
|
||||
inlineItem(LI, Options) ::=
|
||||
element(\rdf_or_unqualified(li),
|
||||
[],
|
||||
[\nodeElement(LI, Options)]), !. % inlined object
|
||||
inlineItem(Literal, Options) ::=
|
||||
element(\rdf_or_unqualified(li),
|
||||
[],
|
||||
[Text]),
|
||||
{ mkliteral(Text, Literal, Options)
|
||||
}.
|
||||
|
||||
memberAttrs([]) ::=
|
||||
[].
|
||||
memberAttrs([H|T]) ::=
|
||||
[ \memberAttr(H)
|
||||
| \memberAttrs(T)
|
||||
].
|
||||
|
||||
memberAttr(li(Id, Value)) ::= % Id should be _<n>
|
||||
\rdf(Id) = Value.
|
||||
|
||||
parseLiteral ::= \rdf_or_unqualified(parseType) = 'Literal'.
|
||||
parseResource ::= \rdf_or_unqualified(parseType) = 'Resource'.
|
||||
parseCollection ::= \rdf_or_unqualified(parseType) = 'Collection'.
|
||||
|
||||
|
||||
/*******************************
|
||||
* PRIMITIVES *
|
||||
*******************************/
|
||||
|
||||
rdf(Tag) ::=
|
||||
NS:Tag,
|
||||
{ rdf_name_space(NS), !
|
||||
}.
|
||||
|
||||
rdf_or_unqualified(Tag) ::=
|
||||
Tag.
|
||||
rdf_or_unqualified(Tag) ::=
|
||||
NS:Tag,
|
||||
{ rdf_name_space(NS), !
|
||||
}.
|
||||
|
||||
|
||||
/*******************************
|
||||
* BASICS *
|
||||
*******************************/
|
||||
|
||||
attrs(Bag) ::=
|
||||
L0,
|
||||
{ do_attrs(Bag, L0)
|
||||
}.
|
||||
|
||||
do_attrs([], _) :- !.
|
||||
do_attrs([\?H|T], L0) :- !, % optional
|
||||
( select(X, L0, L),
|
||||
rewrite(\H, X)
|
||||
-> true
|
||||
; L = L0
|
||||
),
|
||||
do_attrs(T, L).
|
||||
do_attrs([H|T], L0) :-
|
||||
select(X, L0, L),
|
||||
rewrite(H, X), !,
|
||||
do_attrs(T, L).
|
||||
do_attrs(C, L) :-
|
||||
rewrite(C, L).
|
||||
|
||||
% \noMoreAttrs
|
||||
%
|
||||
% Check attribute-list is empty. Reserved xml: attributes are
|
||||
% excluded from this test.
|
||||
|
||||
noMoreAttrs ::=
|
||||
[], !.
|
||||
noMoreAttrs ::=
|
||||
[ xml:_=_
|
||||
| \noMoreAttrs
|
||||
].
|
||||
|
||||
%% modify_state(+Element0, +Options0, -Element, -Options)
|
||||
%
|
||||
% If Element0 contains xml:base = Base, strip it from the
|
||||
% attributes list and update base_uri(_) in the Options
|
||||
%
|
||||
% It Element0 contains xml:lang = Lang, strip it from the
|
||||
% attributes list and update lang(_) in the Options
|
||||
%
|
||||
% Remove all xmlns=_, xmlns:_=_ and xml:_=_. Only succeed
|
||||
% if something changed.
|
||||
|
||||
modify_state(E0, O0, E, O) :-
|
||||
modify_states([base, lang, xmlns], M, E0, O0, E, O),
|
||||
M \== [].
|
||||
|
||||
modify_states([], [], E, O, E, O).
|
||||
modify_states([How|TH0], [How|TH], E0, O0, E, O) :-
|
||||
modify_state(How, E0, O0, E1, O1), !,
|
||||
modify_states(TH0, TH, E1, O1, E, O).
|
||||
modify_states([_|TH0], TH, E0, O0, E, O) :-
|
||||
modify_states(TH0, TH, E0, O0, E, O).
|
||||
|
||||
|
||||
modify_state(base,
|
||||
element(Name, Attrs0, Content), Options0,
|
||||
element(Name, Attrs, Content), Options) :-
|
||||
select(xml:base=Base1, Attrs0, Attrs), !,
|
||||
( select(base_uri(Base0), Options0, Options1)
|
||||
-> true
|
||||
; Base0 = [],
|
||||
Options1 = Options0
|
||||
),
|
||||
remove_fragment(Base1, Base2),
|
||||
canonical_uri(Base2, Base0, Base),
|
||||
Options = [base_uri(Base)|Options1].
|
||||
modify_state(lang, element(Name, Attrs0, Content), Options0,
|
||||
element(Name, Attrs, Content), Options) :-
|
||||
select(xml:lang=Lang, Attrs0, Attrs),
|
||||
\+ memberchk(ignore_lang(true), Options0), !,
|
||||
delete(Options0, lang(_), Options1),
|
||||
( Lang == ''
|
||||
-> Options = Options1
|
||||
; Options = [lang(Lang)|Options1]
|
||||
).
|
||||
modify_state(xmlns,
|
||||
element(Name, Attrs0, Content), Options,
|
||||
element(Name, Attrs, Content), Options) :-
|
||||
clean_xmlns_attr(Attrs0, Attrs),
|
||||
Attrs \== Attrs0.
|
||||
|
||||
clean_xmlns_attr([], []).
|
||||
clean_xmlns_attr([H=_|T0], T) :-
|
||||
xml_attr(H), !,
|
||||
clean_xmlns_attr(T0, T).
|
||||
clean_xmlns_attr([H|T0], [H|T]) :-
|
||||
clean_xmlns_attr(T0, T).
|
||||
|
||||
xml_attr(xmlns).
|
||||
xml_attr(xmlns:_).
|
||||
xml_attr(xml:_).
|
||||
|
||||
|
||||
%% remove_fragment(+URI, -WithoutFragment)
|
||||
%
|
||||
% When handling xml:base, we must delete the possible fragment.
|
||||
|
||||
remove_fragment(URI, Plain) :-
|
||||
sub_atom(URI, B, _, _, #), !,
|
||||
sub_atom(URI, 0, B, _, Plain).
|
||||
remove_fragment(URI, URI).
|
||||
|
||||
|
||||
/*******************************
|
||||
* HELP PCE-EMACS A BIT *
|
||||
*******************************/
|
||||
|
||||
:- multifile
|
||||
emacs_prolog_colours:term_colours/2,
|
||||
emacs_prolog_colours:goal_classification/2.
|
||||
|
||||
expand(c(X), _, X) :- !.
|
||||
expand(In, Pattern, Colours) :-
|
||||
compound(In), !,
|
||||
In =.. [F|Args],
|
||||
expand_list(Args, PatternArgs, ColourArgs),
|
||||
Pattern =.. [F|PatternArgs],
|
||||
Colours = functor(F) - ColourArgs.
|
||||
expand(X, X, classify).
|
||||
|
||||
expand_list([], [], []).
|
||||
expand_list([H|T], [PH|PT], [CH|CT]) :-
|
||||
expand(H, PH, CH),
|
||||
expand_list(T, PT, CT).
|
||||
|
||||
:- discontiguous
|
||||
term_expansion/2.
|
||||
|
||||
term_expansion(term_colours(C),
|
||||
emacs_prolog_colours:term_colours(Pattern, Colours)) :-
|
||||
expand(C, Pattern, Colours).
|
||||
|
||||
term_colours((c(head(+(1))) ::= c(match), {c(body)})).
|
||||
term_colours((c(head(+(1))) ::= c(match))).
|
||||
|
||||
emacs_prolog_colours:goal_classification(\_, expanded).
|
||||
|
||||
:- dynamic
|
||||
prolog:meta_goal/2.
|
||||
:- multifile
|
||||
prolog:meta_goal/2,
|
||||
prolog:called_by/2.
|
||||
|
||||
prolog:meta_goal(rewrite(A, _), [A]).
|
||||
prolog:meta_goal(\A, [A+1]).
|
||||
|
||||
prolog:called_by(attrs(Attrs, _Term), Called) :-
|
||||
findall(G+1, sub_term(\?G, Attrs), Called, Tail),
|
||||
findall(G+1, sub_term(\G, Attrs), Tail).
|
||||
|
||||
|
347
packages/sgml/RDF/rdf_test.pl
Normal file
347
packages/sgml/RDF/rdf_test.pl
Normal file
@ -0,0 +1,347 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog SGML/XML parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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(rdf_test,
|
||||
[ suite/1, % +Test-number
|
||||
test_dir/1, % +Directory
|
||||
test_file/1, % +File
|
||||
time_file/1, % +File
|
||||
passed/1, % +Test-numberOrFile
|
||||
test/0, % run whole suite
|
||||
show_ok/1 % +Test
|
||||
]).
|
||||
|
||||
:- multifile
|
||||
user:file_search_path/2.
|
||||
|
||||
user:file_search_path(library, ..).
|
||||
user:file_search_path(foreign, ..).
|
||||
|
||||
:- use_module(library(sgml)).
|
||||
:- use_module(rdf_parser).
|
||||
:- use_module(rdf_triple).
|
||||
:- use_module(rdf).
|
||||
:- use_module(pretty_print).
|
||||
|
||||
:- set_prolog_flag(rdf_container, true).
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Test file for the SWI-Prolog RDF parser. Toplevel predicates:
|
||||
|
||||
# test/0
|
||||
Run all tests from the `suite' directory and validate the
|
||||
the result if the correct result is stored in a .ok file.
|
||||
|
||||
# suite(N)
|
||||
Run test on suite/t<N>.rdf, showing RDF, intermediate
|
||||
representation and triples on the console.
|
||||
|
||||
# passed(N)
|
||||
Parse suite/t<N>.rdf and save the result in suite/t<N>.ok
|
||||
|
||||
The intention is to write tests, use suite/1 to make sure they are
|
||||
parsed correctly and then run passed/1 to save the correct answer, so
|
||||
running test/0 can validate all results.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
suite(N) :-
|
||||
concat_atom(['suite/t', N, '.rdf'], File),
|
||||
test_file(File).
|
||||
|
||||
test_file(File) :-
|
||||
rdf_reset_ids,
|
||||
format('************* Test ~w ***~n', [File]),
|
||||
cat(File),
|
||||
load_structure(File,
|
||||
[ RDFElement ],
|
||||
[ dialect(xmlns),
|
||||
space(sgml)
|
||||
]),
|
||||
rdf_start_file([], Cleanup),
|
||||
xml_to_plrdf(RDFElement, RDF, []),
|
||||
rdf_end_file(Cleanup),
|
||||
format('============= Prolog term ==============~n', []),
|
||||
pretty_print(RDF),
|
||||
rdf_triples(RDF, Triples),
|
||||
format('============= Triples ==================~n', []),
|
||||
write_triples(Triples).
|
||||
|
||||
time_file(File) :-
|
||||
time(load_rdf(File, Triples)),
|
||||
length(Triples, Len),
|
||||
format('Created ~w triples~n', [Len]).
|
||||
|
||||
passed(Id) :-
|
||||
integer(Id), !,
|
||||
concat_atom(['suite/t', Id, '.rdf'], File),
|
||||
passed(File).
|
||||
passed(File) :-
|
||||
rdf_reset_ids,
|
||||
ok_file(File, OkFile),
|
||||
load_rdf(File, Triples),
|
||||
open(OkFile, write, Fd, [encoding(utf8)]),
|
||||
save_triples(Triples, Fd),
|
||||
close(Fd),
|
||||
length(Triples, N),
|
||||
format('Saved ~d triples to ~w~n', [N, OkFile]).
|
||||
|
||||
:- dynamic failed/1.
|
||||
|
||||
test :-
|
||||
test(load_rdf),
|
||||
test(process_rdf).
|
||||
|
||||
test(How) :-
|
||||
retractall(failed(_)),
|
||||
test_dir(suite, How),
|
||||
findall(F, failed(F), Failed),
|
||||
( Failed == []
|
||||
-> true
|
||||
; length(Failed, N),
|
||||
format('ERROR: ~w tests failed~n', [N]),
|
||||
fail
|
||||
).
|
||||
|
||||
|
||||
test_dir(Dir) :-
|
||||
test_dir(Dir, load_rdf).
|
||||
|
||||
test_dir(Dir, How) :-
|
||||
format('Tests from "~w" [~w]: ', [Dir, How]),
|
||||
atom_concat(Dir, '/*.rdf', Pattern),
|
||||
expand_file_name(Pattern, TestFiles),
|
||||
maplist(test(How), TestFiles),
|
||||
format(' done~n').
|
||||
|
||||
test(How, File) :-
|
||||
format('.'), flush_output,
|
||||
rdf_reset_ids,
|
||||
ok_file(File, OkFile),
|
||||
( call(How, File, Triples)
|
||||
-> ( catch(open(OkFile, read, Fd, [encoding(utf8)]), _, fail)
|
||||
-> ( read_triples(Fd, OkTriples),
|
||||
close(Fd),
|
||||
compare_triples(Triples, OkTriples, _Subst)
|
||||
-> true
|
||||
; assert(failed(File)),
|
||||
format('~N~w: WRONG ANSWER~n', [File])
|
||||
)
|
||||
; format('~N~w: (no .ok file)~n', [File])
|
||||
)
|
||||
; assert(failed(File)),
|
||||
format('~N~w: PARSE FAILED~n', [File])
|
||||
).
|
||||
|
||||
ok_file(File, OkFile) :-
|
||||
file_base_name(File, BaseFile),
|
||||
file_name_extension(Base, _, BaseFile),
|
||||
file_directory_name(File, Dir),
|
||||
concat_atom([Dir, /, ok, /, Base, '.ok'], OkFile).
|
||||
|
||||
|
||||
save_triples([], _).
|
||||
save_triples([H|T], Fd) :-
|
||||
format(Fd, '~q.~n', [H]),
|
||||
save_triples(T, Fd).
|
||||
|
||||
read_triples(Fd, Terms) :-
|
||||
read(Fd, T0),
|
||||
read_triples(T0, Fd, Terms).
|
||||
|
||||
read_triples(end_of_file, _, []) :- !.
|
||||
read_triples(rdf(S0,P0,O0), Fd, [rdf(S,P,O)|R]) :-
|
||||
global_ref(S0, S),
|
||||
global_ref(P0, P),
|
||||
global_obj(O0, O),
|
||||
read(Fd, T1),
|
||||
read_triples(T1, Fd, R).
|
||||
|
||||
global_ref(rdf:Local, Global) :-
|
||||
rdf_name_space(NS), !,
|
||||
atom_concat(NS, Local, Global).
|
||||
global_ref(NS:Local, Global) :- !,
|
||||
atom_concat(NS, Local, Global).
|
||||
global_ref(URI, URI).
|
||||
|
||||
global_obj(literal(X), literal(X)) :- !.
|
||||
global_obj(Local, Global) :-
|
||||
global_ref(Local, Global).
|
||||
|
||||
|
||||
write_triples([]) :- !.
|
||||
write_triples([H|T]) :- !,
|
||||
write_triple(H),
|
||||
write_triples(T).
|
||||
|
||||
write_triple(Triple) :-
|
||||
is_rdf_triple(Triple), !,
|
||||
Triple = rdf(S,P,O),
|
||||
format('{~p, ~p, ~p}~n', [S,P,O]).
|
||||
write_triple(Triple) :-
|
||||
format('@@@@@ Bad Triple: ~p~n', [Triple]),
|
||||
fail.
|
||||
|
||||
cat(File) :-
|
||||
open(File, read, Fd),
|
||||
copy_stream_data(Fd, user_output),
|
||||
close(Fd).
|
||||
|
||||
:- dynamic triple/1.
|
||||
|
||||
process_rdf(File, Triples) :-
|
||||
retractall(triple(_)),
|
||||
process_rdf(File, assert_triples, []),
|
||||
findall(T, retract(triple(T)), Triples).
|
||||
|
||||
assert_triples([], _).
|
||||
assert_triples([H|T], Loc) :-
|
||||
assert(triple(H)),
|
||||
assert_triples(T, Loc).
|
||||
|
||||
|
||||
/*******************************
|
||||
* VALIDATE *
|
||||
*******************************/
|
||||
|
||||
is_rdf_triple(rdf(Subject, Predicate, Object)) :-
|
||||
is_subject(Subject),
|
||||
is_predicate(Predicate),
|
||||
is_object(Object).
|
||||
|
||||
is_subject(0) :- !, fail. % Variables
|
||||
is_subject(URI) :- is_uri(URI), !.
|
||||
is_subject(each(URI)) :- is_uri(URI), !.
|
||||
is_subject(prefix(Pattern)) :-
|
||||
atom(Pattern), !.
|
||||
|
||||
is_predicate(0) :- !, fail.
|
||||
is_predicate(rdf:RdfPred) :- !,
|
||||
is_rdf_predicate(RdfPred).
|
||||
is_predicate(NS:Pred) :- !,
|
||||
atom(NS),
|
||||
atom(Pred).
|
||||
is_predicate(Pred) :-
|
||||
atom(Pred).
|
||||
|
||||
is_object(0) :- !,
|
||||
fail.
|
||||
is_object(literal(XML)) :- !,
|
||||
is_xml(XML).
|
||||
is_object(rdf:RdfType) :- !,
|
||||
is_rdf_type(RdfType).
|
||||
is_object(URI) :-
|
||||
is_uri(URI).
|
||||
|
||||
is_object(Subject) :-
|
||||
is_subject(Subject), !.
|
||||
is_object(Pred) :-
|
||||
is_predicate(Pred), !.
|
||||
|
||||
is_uri(URI) :- atom(URI).
|
||||
|
||||
is_xml(_XML). % for now
|
||||
|
||||
is_rdf_predicate(RdfPred) :- atom(RdfPred).
|
||||
|
||||
is_rdf_type(RdfType) :- atom(RdfType).
|
||||
|
||||
/*******************************
|
||||
* UTIL *
|
||||
*******************************/
|
||||
|
||||
% find_rdf(+XMLTerm, -RDFTerm)
|
||||
%
|
||||
% If the document contains an embedded RDF term, return it, else
|
||||
% return the whole document. The latter is a bit dubious, but good
|
||||
% for the purpose of this test-file
|
||||
|
||||
find_rdf(Term, RDFTerm) :-
|
||||
RDFTerm = element(NS:'RDF', _, _),
|
||||
term_member(RDFTerm, Term), !,
|
||||
( rdf_name_space(NS)
|
||||
-> true
|
||||
; assert(rdf_parser:rdf_name_space(NS)),
|
||||
assert(new_rdf_namespace(NS))
|
||||
).
|
||||
find_rdf(Term, Term).
|
||||
|
||||
term_member(X, X).
|
||||
term_member(X, Compound) :-
|
||||
compound(Compound),
|
||||
arg(_, Compound, Arg),
|
||||
term_member(X, Arg).
|
||||
|
||||
/*******************************
|
||||
* COMPARING *
|
||||
*******************************/
|
||||
|
||||
% compare_triples(+PlRDF, +NTRDF, -Substitions)
|
||||
%
|
||||
% Compare two models and if they are equal, return a list of
|
||||
% PlID = NTID, mapping NodeID elements.
|
||||
|
||||
|
||||
compare_triples(A, B, Substitutions) :-
|
||||
compare_list(A, B, [], Substitutions), !.
|
||||
|
||||
compare_list([], [], S, S).
|
||||
compare_list([H1|T1], In2, S0, S) :-
|
||||
select(H2, In2, T2),
|
||||
compare_triple(H1, H2, S0, S1),
|
||||
compare_list(T1, T2, S1, S).
|
||||
|
||||
compare_triple(rdf(Subj1,P1,O1), rdf(Subj2, P2, O2), S0, S) :-
|
||||
compare_field(Subj1, Subj2, S0, S1),
|
||||
compare_field(P1, P2, S1, S2),
|
||||
compare_field(O1, O2, S2, S).
|
||||
|
||||
compare_field(X, X, S, S) :- !.
|
||||
compare_field(literal(X), xml(X), S, S) :- !. % TBD
|
||||
compare_field(rdf:Name, Atom, S, S) :-
|
||||
atom(Atom),
|
||||
rdf_parser:rdf_name_space(NS),
|
||||
atom_concat(NS, Name, Atom), !.
|
||||
compare_field(NS:Name, Atom, S, S) :-
|
||||
atom(Atom),
|
||||
atom_concat(NS, Name, Atom), !.
|
||||
compare_field(X, Id, S, S) :-
|
||||
memberchk(X=Id, S), !.
|
||||
compare_field(X, Y, S, [X=Y|S]) :-
|
||||
\+ memberchk(X=_, S),
|
||||
node_id(X),
|
||||
node_id(Y),
|
||||
format('Assume ~w = ~w~n', [X, Y]).
|
||||
|
||||
node_id(node(_)) :- !.
|
||||
node_id(X) :-
|
||||
atom(X),
|
||||
generated_prefix(Prefix),
|
||||
sub_atom(X, 0, _, _, Prefix), !.
|
||||
|
||||
generated_prefix('Bag__').
|
||||
generated_prefix('Seq__').
|
||||
generated_prefix('Alt__').
|
||||
generated_prefix('Description__').
|
||||
generated_prefix('Statement__').
|
||||
|
||||
/*******************************
|
||||
* SHOW DIAGRAM *
|
||||
*******************************/
|
||||
|
||||
show_ok(Test) :-
|
||||
ok_file(Test, File),
|
||||
open(File, read, Fd, [encoding(utf8)]),
|
||||
read_triples(Fd, OkTriples),
|
||||
close(Fd),
|
||||
new(D, rdf_diagram(string('Ok for %s', File))),
|
||||
send(D, triples, OkTriples),
|
||||
send(D, open).
|
461
packages/sgml/RDF/rdf_triple.pl
Normal file
461
packages/sgml/RDF/rdf_triple.pl
Normal file
@ -0,0 +1,461 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog RDF parser
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
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(rdf_triple,
|
||||
[ rdf_triples/2, % +Parsed, -Tripples
|
||||
rdf_triples/3, % +Parsed, -Tripples, +Tail
|
||||
rdf_reset_ids/0, % Reset gensym id's
|
||||
rdf_start_file/2, % +Options, -Cleanup
|
||||
rdf_end_file/1, % +Cleanup
|
||||
anon_prefix/1 % Prefix for anonynmous resources
|
||||
]).
|
||||
:- use_module(library(gensym)).
|
||||
:- use_module(rdf_parser).
|
||||
|
||||
/** <module> Create triples from intermediate representation
|
||||
|
||||
Convert the output of xml_to_rdf/3 from library(rdf) into a list of
|
||||
triples of the format described below. The intermediate representation
|
||||
should be regarded a proprietary representation.
|
||||
|
||||
rdf(Subject, Predicate, Object).
|
||||
|
||||
Where `Subject' is
|
||||
|
||||
* Atom
|
||||
The subject is a resource
|
||||
|
||||
* each(URI)
|
||||
URI is the URI of an RDF Bag
|
||||
|
||||
* prefix(Pattern)
|
||||
Pattern is the prefix of a fully qualified Subject URI
|
||||
|
||||
And `Predicate' is
|
||||
|
||||
* Atom
|
||||
The predicate is always a resource
|
||||
|
||||
And `Object' is
|
||||
|
||||
* Atom
|
||||
URI of Object resource
|
||||
|
||||
* literal(Value)
|
||||
Literal value (Either a single atom or parsed XML data)
|
||||
*/
|
||||
|
||||
%% rdf_triples(+Term, -Triples) is det.
|
||||
%% rdf_triples(+Term, -Tridpples, +Tail) is det.
|
||||
%
|
||||
% Convert an object as parsed by rdf.pl into a list of rdf/3
|
||||
% triples. The identifier of the main object created is returned
|
||||
% by rdf_triples/3.
|
||||
%
|
||||
% Input is the `content' of the RDF element in the format as
|
||||
% generated by load_structure(File, Term, [dialect(xmlns)]).
|
||||
% rdf_triples/3 can process both individual descriptions as
|
||||
% well as the entire content-list of an RDF element. The first
|
||||
% mode is suitable when using library(sgml) in `call-back' mode.
|
||||
|
||||
rdf_triples(RDF, Tripples) :-
|
||||
rdf_triples(RDF, Tripples, []).
|
||||
|
||||
rdf_triples([]) --> !,
|
||||
[].
|
||||
rdf_triples([H|T]) --> !,
|
||||
rdf_triples(H),
|
||||
rdf_triples(T).
|
||||
rdf_triples(Term) -->
|
||||
triples(Term, _).
|
||||
|
||||
%% triples(-Triples, -Id, +In, -Tail)
|
||||
%
|
||||
% DGC set processing the output of xml_to_rdf/3. In Id, the identifier
|
||||
% of the main description or container is returned.
|
||||
|
||||
triples(container(Type, Id, Elements), Id) --> !,
|
||||
{ container_id(Type, Id)
|
||||
},
|
||||
rdf(Id, rdf:type, rdf:Type),
|
||||
container(Elements, 1, Id).
|
||||
triples(description(Type, About, BagId, Props), Subject) -->
|
||||
{ var(About),
|
||||
var(BagId),
|
||||
share_blank_nodes(true)
|
||||
}, !,
|
||||
( { shared_description(description(Type, Props), Subject)
|
||||
}
|
||||
-> []
|
||||
; { make_id('__Description', Id)
|
||||
},
|
||||
triples(description(Type, about(Id), BagId, Props), Subject),
|
||||
{ assert_shared_description(description(Type, Props), Subject)
|
||||
}
|
||||
).
|
||||
triples(description(description, IdAbout, BagId, Props), Subject) --> !,
|
||||
{ description_id(IdAbout, Subject)
|
||||
},
|
||||
properties(Props, BagId, Subject).
|
||||
triples(description(Type, IdAbout, BagId, Props), Subject) -->
|
||||
{ description_id(IdAbout, Subject),
|
||||
name_to_type_uri(Type, TypeURI)
|
||||
},
|
||||
properties([ rdf:type = TypeURI
|
||||
| Props
|
||||
], BagId, Subject).
|
||||
triples(unparsed(Data), Id) -->
|
||||
{ make_id('__Error', Id),
|
||||
print_message(error, rdf(unparsed(Data)))
|
||||
},
|
||||
[].
|
||||
|
||||
|
||||
name_to_type_uri(NS:Local, URI) :- !,
|
||||
atom_concat(NS, Local, URI).
|
||||
name_to_type_uri(URI, URI).
|
||||
|
||||
/*******************************
|
||||
* CONTAINERS *
|
||||
*******************************/
|
||||
|
||||
container([], _, _) -->
|
||||
[].
|
||||
container([H0|T0], N, Id) -->
|
||||
li(H0, N, Id),
|
||||
{ NN is N + 1
|
||||
},
|
||||
container(T0, NN, Id).
|
||||
|
||||
li(li(Nid, V), _, Id) --> !,
|
||||
rdf(Id, rdf:Nid, V).
|
||||
li(V, N, Id) -->
|
||||
triples(V, VId), !,
|
||||
{ atom_concat('_', N, Nid)
|
||||
},
|
||||
rdf(Id, rdf:Nid, VId).
|
||||
li(V, N, Id) -->
|
||||
{ atom_concat('_', N, Nid)
|
||||
},
|
||||
rdf(Id, rdf:Nid, V).
|
||||
|
||||
container_id(_, Id) :-
|
||||
nonvar(Id), !.
|
||||
container_id(Type, Id) :-
|
||||
container_base(Type, Base),
|
||||
make_id(Base, Id).
|
||||
|
||||
container_base('Bag', '__Bag').
|
||||
container_base('Seq', '__Seq').
|
||||
container_base('Alt', '__Alt').
|
||||
|
||||
|
||||
/*******************************
|
||||
* DESCRIPTIONS *
|
||||
*******************************/
|
||||
|
||||
:- thread_local
|
||||
node_id/2, % nodeID --> ID
|
||||
unique_id/1. % known rdf:ID
|
||||
|
||||
rdf_reset_node_ids :-
|
||||
retractall(node_id(_,_)),
|
||||
retractall(unique_id(_)).
|
||||
|
||||
description_id(Id, Id) :-
|
||||
var(Id), !,
|
||||
make_id('__Description', Id).
|
||||
description_id(about(Id), Id).
|
||||
description_id(id(Id), Id) :-
|
||||
( unique_id(Id)
|
||||
-> print_message(error, rdf(redefined_id(Id)))
|
||||
; assert(unique_id(Id))
|
||||
).
|
||||
description_id(each(Id), each(Id)).
|
||||
description_id(prefix(Id), prefix(Id)).
|
||||
description_id(node(NodeID), Id) :-
|
||||
( node_id(NodeID, Id)
|
||||
-> true
|
||||
; make_id('__Node', Id),
|
||||
assert(node_id(NodeID, Id))
|
||||
).
|
||||
|
||||
properties(PlRDF, BagId, Subject) -->
|
||||
{ nonvar(BagId)
|
||||
}, !,
|
||||
rdf(BagId, rdf:type, rdf:'Bag'),
|
||||
properties(PlRDF, 1, Statements, [], Subject),
|
||||
fill_bag(Statements, 1, BagId).
|
||||
properties(PlRDF, _BagId, Subject) -->
|
||||
properties(PlRDF, 1, [], [], Subject).
|
||||
|
||||
|
||||
fill_bag([], _, _) -->
|
||||
[].
|
||||
fill_bag([H|T], N, BagId) -->
|
||||
{ NN is N + 1,
|
||||
atom_concat('_', N, ElemId)
|
||||
},
|
||||
rdf(BagId, rdf:ElemId, H),
|
||||
fill_bag(T, NN, BagId).
|
||||
|
||||
|
||||
properties([], _, Bag, Bag, _) -->
|
||||
[].
|
||||
properties([H0|T0], N, Bag0, Bag, Subject) -->
|
||||
property(H0, N, NN, Bag0, Bag1, Subject),
|
||||
properties(T0, NN, Bag1, Bag, Subject).
|
||||
|
||||
%% property(Property, N, NN, Subject)// is det.
|
||||
%
|
||||
% Generate triples for {Subject, Pred, Object}. Also generates
|
||||
% triples for Object if necessary.
|
||||
%
|
||||
% @param Property One of
|
||||
%
|
||||
% * Pred = Object
|
||||
% Used for normal statements
|
||||
% * id(Id, Pred = Object)
|
||||
% Used for reified statements
|
||||
|
||||
property(Pred0 = Object, N, NN, BagH, BagT, Subject) --> % inlined object
|
||||
triples(Object, Id), !,
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, Id, _, BagH, BagT).
|
||||
property(Pred0 = collection(Elems), N, NN, BagH, BagT, Subject) --> !,
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, Object, _Id, BagH, BagT),
|
||||
collection(Elems, Object).
|
||||
property(Pred0 = Object, N, NN, BagH, BagT, Subject) --> !,
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, Object, _Id, BagH, BagT).
|
||||
property(id(Id, Pred0 = Object), N, NN, BagH, BagT, Subject) -->
|
||||
triples(Object, ObjectId), !,
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, ObjectId, Id, BagH, BagT).
|
||||
property(id(Id, Pred0 = collection(Elems)), N, NN, BagH, BagT, Subject) --> !,
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, Object, Id, BagH, BagT),
|
||||
collection(Elems, Object).
|
||||
property(id(Id, Pred0 = Object), N, NN, BagH, BagT, Subject) -->
|
||||
{ li_pred(Pred0, Pred, N, NN)
|
||||
},
|
||||
statement(Subject, Pred, Object, Id, BagH, BagT).
|
||||
|
||||
%% statement(+Subject, +Pred, +Object, +Id, +BagH, -BagT)
|
||||
%
|
||||
% Add a statement to the model. If nonvar(Id), we reinify the
|
||||
% statement using the given Id.
|
||||
|
||||
statement(Subject, Pred, Object, Id, BagH, BagT) -->
|
||||
rdf(Subject, Pred, Object),
|
||||
{ BagH = [Id|BagT]
|
||||
-> statement_id(Id)
|
||||
; BagT = BagH
|
||||
},
|
||||
( { nonvar(Id)
|
||||
}
|
||||
-> rdf(Id, rdf:type, rdf:'Statement'),
|
||||
rdf(Id, rdf:subject, Subject),
|
||||
rdf(Id, rdf:predicate, Pred),
|
||||
rdf(Id, rdf:object, Object)
|
||||
; []
|
||||
).
|
||||
|
||||
|
||||
statement_id(Id) :-
|
||||
nonvar(Id), !.
|
||||
statement_id(Id) :-
|
||||
make_id('__Statement', Id).
|
||||
|
||||
%% li_pred(+Pred, -Pred, +Nth, -NextNth)
|
||||
%
|
||||
% Transform rdf:li predicates into _1, _2, etc.
|
||||
|
||||
li_pred(rdf:li, rdf:Pred, N, NN) :- !,
|
||||
NN is N + 1,
|
||||
atom_concat('_', N, Pred).
|
||||
li_pred(Pred, Pred, N, N).
|
||||
|
||||
%% collection(+Elems, -Id)
|
||||
%
|
||||
% Handle the elements of a collection and return the identifier
|
||||
% for the whole collection in Id.
|
||||
|
||||
collection([], Nil) -->
|
||||
{ global_ref(rdf:nil, Nil)
|
||||
}.
|
||||
collection([H|T], Id) -->
|
||||
triples(H, HId),
|
||||
{ make_id('__List', Id)
|
||||
},
|
||||
rdf(Id, rdf:type, rdf:'List'),
|
||||
rdf(Id, rdf:first, HId),
|
||||
rdf(Id, rdf:rest, TId),
|
||||
collection(T, TId).
|
||||
|
||||
|
||||
rdf(S0, P0, O0) -->
|
||||
{ global_ref(S0, S),
|
||||
global_ref(P0, P),
|
||||
global_obj(O0, O)
|
||||
},
|
||||
[ rdf(S, P, O) ].
|
||||
|
||||
|
||||
global_ref(URI, URI) :-
|
||||
var(URI), !.
|
||||
global_ref(rdf:Local, Global) :-
|
||||
rdf_name_space(NS), !,
|
||||
atom_concat(NS, Local, Global).
|
||||
global_ref(NS:Local, Global) :- !,
|
||||
atom_concat(NS, Local, Global).
|
||||
global_ref(URI, URI).
|
||||
|
||||
global_obj(V, V) :-
|
||||
var(V), !.
|
||||
global_obj(literal(type(Local, X)), literal(type(Global, X))) :- !,
|
||||
global_ref(Local, Global).
|
||||
global_obj(literal(X), literal(X)) :- !.
|
||||
global_obj(Local, Global) :-
|
||||
global_ref(Local, Global).
|
||||
|
||||
|
||||
/*******************************
|
||||
* SHARING *
|
||||
*******************************/
|
||||
|
||||
:- thread_local
|
||||
shared_description/3, % +Hash, +Term, -Subject
|
||||
share_blank_nodes/1, % Boolean
|
||||
shared_nodes/1. % counter
|
||||
|
||||
reset_shared_descriptions :-
|
||||
retractall(shared_description(_,_,_)),
|
||||
retractall(shared_nodes(_)).
|
||||
|
||||
shared_description(Term, Subject) :-
|
||||
term_hash(Term, Hash),
|
||||
shared_description(Hash, Term, Subject),
|
||||
( retract(shared_nodes(N))
|
||||
-> N1 is N + 1
|
||||
; N1 = 1
|
||||
),
|
||||
assert(shared_nodes(N1)).
|
||||
|
||||
|
||||
assert_shared_description(Term, Subject) :-
|
||||
term_hash(Term, Hash),
|
||||
assert(shared_description(Hash, Term, Subject)).
|
||||
|
||||
|
||||
/*******************************
|
||||
* START/END *
|
||||
*******************************/
|
||||
|
||||
%% rdf_start_file(+Options, -Cleanup) is det.
|
||||
%
|
||||
% Initialise for the translation of a file.
|
||||
|
||||
rdf_start_file(Options, Cleanup) :-
|
||||
rdf_reset_node_ids, % play safe
|
||||
reset_shared_descriptions,
|
||||
set_bnode_sharing(Options, C1),
|
||||
set_anon_prefix(Options, C2),
|
||||
add_cleanup(C1, C2, Cleanup).
|
||||
|
||||
%% rdf_end_file(:Cleanup) is det.
|
||||
%
|
||||
% Cleanup reaching the end of an RDF file.
|
||||
|
||||
rdf_end_file(Cleanup) :-
|
||||
rdf_reset_node_ids,
|
||||
( shared_nodes(N)
|
||||
-> print_message(informational, rdf(shared_blank_nodes(N)))
|
||||
; true
|
||||
),
|
||||
reset_shared_descriptions,
|
||||
Cleanup.
|
||||
|
||||
set_bnode_sharing(Options, erase(Ref)) :-
|
||||
option(blank_nodes(Share), Options, noshare),
|
||||
( Share == share
|
||||
-> assert(share_blank_nodes(true), Ref), !
|
||||
; Share == noshare
|
||||
-> fail % next clause
|
||||
; throw(error(domain_error(share, Share), _))
|
||||
).
|
||||
set_bnode_sharing(_, true).
|
||||
|
||||
set_anon_prefix(Options, erase(Ref)) :-
|
||||
option(base_uri(BaseURI), Options, []),
|
||||
BaseURI \== [], !,
|
||||
concat_atom(['__', BaseURI, '#'], AnonBase),
|
||||
asserta(anon_prefix(AnonBase), Ref).
|
||||
set_anon_prefix(_, true).
|
||||
|
||||
add_cleanup(true, X, X) :- !.
|
||||
add_cleanup(X, true, X) :- !.
|
||||
add_cleanup(X, Y, (X, Y)).
|
||||
|
||||
|
||||
/*******************************
|
||||
* UTIL *
|
||||
*******************************/
|
||||
|
||||
%% anon_prefix(-Prefix) is semidet.
|
||||
%
|
||||
% If defined, it is the prefix used to generate a blank node.
|
||||
|
||||
:- thread_local
|
||||
anon_prefix/1.
|
||||
|
||||
make_id(For, ID) :-
|
||||
anon_prefix(Prefix), !,
|
||||
atom_concat(Prefix, For, Base),
|
||||
gensym(Base, ID).
|
||||
make_id(For, ID) :-
|
||||
gensym(For, ID).
|
||||
|
||||
anon_base('__Bag').
|
||||
anon_base('__Seq').
|
||||
anon_base('__Alt').
|
||||
anon_base('__Description').
|
||||
anon_base('__Statement').
|
||||
anon_base('__List').
|
||||
anon_base('__Node').
|
||||
|
||||
%% rdf_reset_ids is det.
|
||||
%
|
||||
% Utility predicate to reset the gensym counters for the various
|
||||
% generated identifiers. This simplifies debugging and matching
|
||||
% output with the stored desired output (see rdf_test.pl).
|
||||
|
||||
rdf_reset_ids :-
|
||||
anon_prefix(Prefix), !,
|
||||
( anon_base(Base),
|
||||
atom_concat(Prefix, Base, X),
|
||||
reset_gensym(X),
|
||||
fail
|
||||
; true
|
||||
).
|
||||
rdf_reset_ids :-
|
||||
( anon_base(Base),
|
||||
reset_gensym(Base),
|
||||
fail
|
||||
; true
|
||||
).
|
635
packages/sgml/RDF/rdf_write.pl
Normal file
635
packages/sgml/RDF/rdf_write.pl
Normal file
@ -0,0 +1,635 @@
|
||||
/* $Id$
|
||||
|
||||
Part of SWI-Prolog
|
||||
|
||||
Author: Jan Wielemaker
|
||||
E-mail: J.Wielemak@uva.nl
|
||||
WWW: http://www.swi-prolog.org
|
||||
Copyright (C): 2004-2009, University of Amsterdam
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
As a special exception, if you link this library with other files,
|
||||
compiled with a Free Software compiler, to produce an executable, this
|
||||
library does not by itself cause the resulting executable to be covered
|
||||
by the GNU General Public License. This exception does not however
|
||||
invalidate any other reasons why the executable file might be covered by
|
||||
the GNU General Public License.
|
||||
*/
|
||||
|
||||
:- module(rdf_write,
|
||||
[ rdf_write_xml/2 % +Stream, +Triples
|
||||
]).
|
||||
:- use_module(library('semweb/rdf_db')).
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(library(sgml)).
|
||||
:- use_module(library(sgml_write)).
|
||||
:- use_module(library(assoc)).
|
||||
:- use_module(library(pairs)).
|
||||
:- use_module(library(debug)).
|
||||
|
||||
|
||||
/** <module> Write RDF/XML from a list of triples
|
||||
|
||||
This module writes an RDF/XML document from a list of triples of the
|
||||
format rdf(Subject, Predicate, Object). It is primarily intended for
|
||||
communicating computed RDF model fragments to external programs using
|
||||
RDF/XML.
|
||||
|
||||
When used from the HTTP library, use the following code:
|
||||
|
||||
==
|
||||
reply_graph(RDF) :-
|
||||
format('Content-type: application/rdf+xml; charset=UTF-8~n~n'),
|
||||
rdf_write_xml(current_output, RDF).
|
||||
==
|
||||
|
||||
@author Jan Wielemaker
|
||||
@see library(semweb/rdf_db) offers saving a named graph directly from
|
||||
the RDF database.
|
||||
*/
|
||||
|
||||
|
||||
/*******************************
|
||||
* WRITE RDFXML *
|
||||
*******************************/
|
||||
|
||||
%% rdf_write_xml(+Out:stream, +Triples:list(rdf(S,P,O))) is det.
|
||||
%
|
||||
% Write an RDF/XML serialization of Triples to Out.
|
||||
|
||||
rdf_write_xml(Out, Triples) :-
|
||||
sort(Triples, Unique),
|
||||
rdf_write_header(Out, Unique),
|
||||
node_id_map(Unique, AnonIDs),
|
||||
rdf_write_triples(Unique, AnonIDs, Out),
|
||||
rdf_write_footer(Out).
|
||||
|
||||
|
||||
/*******************************
|
||||
* HEADER/FOOTER *
|
||||
*******************************/
|
||||
|
||||
%% rdf_write_header(+Out, +Triples)
|
||||
%
|
||||
% Save XML document header, doctype and open the RDF environment.
|
||||
% This predicate also sets up the namespace notation.
|
||||
|
||||
rdf_write_header(Out, Triples) :-
|
||||
xml_encoding(Out, Enc, Encoding),
|
||||
format(Out, '<?xml version=\'1.0\' encoding=\'~w\'?>~n', [Encoding]),
|
||||
format(Out, '<!DOCTYPE rdf:RDF [', []),
|
||||
used_namespaces(Triples, NSList),
|
||||
( member(Id, NSList),
|
||||
ns(Id, NS),
|
||||
rdf_quote_uri(NS, QNS),
|
||||
xml_quote_attribute(QNS, NSText0, Enc),
|
||||
xml_escape_parameter_entity(NSText0, NSText),
|
||||
format(Out, '~N <!ENTITY ~w \'~w\'>', [Id, NSText]),
|
||||
fail
|
||||
; true
|
||||
),
|
||||
format(Out, '~N]>~n~n', []),
|
||||
format(Out, '<rdf:RDF', []),
|
||||
( member(Id, NSList),
|
||||
format(Out, '~N xmlns:~w="&~w;"~n', [Id, Id]),
|
||||
fail
|
||||
; true
|
||||
),
|
||||
format(Out, '>~n', []).
|
||||
|
||||
|
||||
xml_encoding(Out, Enc, Encoding) :-
|
||||
stream_property(Out, encoding(Enc)),
|
||||
( xml_encoding_name(Enc, Encoding)
|
||||
-> true
|
||||
; throw(error(domain_error(rdf_encoding, Enc), _))
|
||||
).
|
||||
|
||||
xml_encoding_name(ascii, 'US-ASCII').
|
||||
xml_encoding_name(iso_latin_1, 'ISO-8859-1').
|
||||
xml_encoding_name(utf8, 'UTF-8').
|
||||
|
||||
%% xml_escape_parameter_entity(+In, -Out) is det.
|
||||
%
|
||||
% Escape % as % for entity declarations.
|
||||
|
||||
xml_escape_parameter_entity(In, Out) :-
|
||||
sub_atom(In, _, _, _, '%'), !,
|
||||
atom_codes(In, Codes),
|
||||
phrase(escape_parent(Codes), OutCodes),
|
||||
atom_codes(Out, OutCodes).
|
||||
xml_escape_parameter_entity(In, In).
|
||||
|
||||
escape_parent([]) --> [].
|
||||
escape_parent([H|T]) -->
|
||||
( { H == 37 }
|
||||
-> "%"
|
||||
; [H]
|
||||
),
|
||||
escape_parent(T).
|
||||
|
||||
%% used_namespaces(+Triples:list(rdf(S,P,O)), -List:atom) is det.
|
||||
%
|
||||
% Return the list of namespace abbreviations used in a set of
|
||||
% triples.
|
||||
|
||||
used_namespaces(Triples, NSList) :-
|
||||
decl_used_predicate_ns(Triples),
|
||||
resources(Triples, Resources),
|
||||
empty_assoc(A0),
|
||||
put_assoc(rdf, A0, *, A1), % needed for rdf:RDF
|
||||
res_used_namespaces(Resources, _NoNS, A1, A),
|
||||
assoc_to_keys(A, NSList).
|
||||
|
||||
|
||||
res_used_namespaces([], [], A, A).
|
||||
res_used_namespaces([Resource|T], NoNS, A0, A) :-
|
||||
ns(NS, Full),
|
||||
Full \== '',
|
||||
atom_concat(Full, _Local, Resource), !,
|
||||
put_assoc(NS, A0, *, A1),
|
||||
res_used_namespaces(T, NoNS, A1, A).
|
||||
res_used_namespaces([R|T0], [R|T], A0, A) :-
|
||||
res_used_namespaces(T0, T, A0, A).
|
||||
|
||||
%% resources(+Triples:list(rdf(S,P,O)), -Resources:list(atom)) is det.
|
||||
%
|
||||
% Resources is the set of resources referenced in Triples.
|
||||
|
||||
resources(Triples, Resources) :-
|
||||
phrase(resources(Triples), Raw),
|
||||
sort(Raw, Resources).
|
||||
|
||||
resources([]) -->
|
||||
[].
|
||||
resources([rdf(S,P,O)|T]) -->
|
||||
[S,P],
|
||||
object_resources(O),
|
||||
resources(T).
|
||||
|
||||
object_resources(Atom) -->
|
||||
{ atom(Atom) }, !,
|
||||
[ Atom ].
|
||||
object_resources(literal(type(Type, _))) --> !,
|
||||
[ Type ].
|
||||
object_resources(_) -->
|
||||
[].
|
||||
|
||||
%% decl_used_predicate_ns(+Triples:list(rdf(S,P,O)))
|
||||
%
|
||||
% For every URL used as a predicate we *MUST* define a namespace
|
||||
% as we cannot use names holding /, :, etc. as XML identifiers.
|
||||
|
||||
:- thread_local
|
||||
predicate_ns/2.
|
||||
|
||||
decl_used_predicate_ns(Triples) :-
|
||||
retractall(predicate_ns(_,_)),
|
||||
( member(rdf(_,P,_), Triples),
|
||||
decl_predicate_ns(P),
|
||||
fail
|
||||
; true
|
||||
).
|
||||
|
||||
decl_predicate_ns(Pred) :-
|
||||
predicate_ns(Pred, _), !.
|
||||
decl_predicate_ns(Pred) :-
|
||||
rdf_global_id(NS:_Local, Pred),
|
||||
assert(predicate_ns(Pred, NS)), !.
|
||||
decl_predicate_ns(Pred) :-
|
||||
is_bag_li_predicate(Pred), !.
|
||||
decl_predicate_ns(Pred) :-
|
||||
atom_codes(Pred, Codes),
|
||||
append(NSCodes, LocalCodes, Codes),
|
||||
xml_codes(LocalCodes), !,
|
||||
( NSCodes \== []
|
||||
-> atom_codes(NS, NSCodes),
|
||||
( ns(Id, NS)
|
||||
-> assert(predicate_ns(Pred, Id))
|
||||
; between(1, infinite, N),
|
||||
atom_concat(ns, N, Id),
|
||||
\+ ns(Id, _)
|
||||
-> rdf_register_ns(Id, NS),
|
||||
print_message(informational,
|
||||
rdf(using_namespace(Id, NS)))
|
||||
),
|
||||
assert(predicate_ns(Pred, Id))
|
||||
; assert(predicate_ns(Pred, -)) % no namespace used
|
||||
).
|
||||
|
||||
xml_codes([]).
|
||||
xml_codes([H|T]) :-
|
||||
xml_code(H),
|
||||
xml_codes(T).
|
||||
|
||||
xml_code(X) :-
|
||||
code_type(X, csym), !.
|
||||
xml_code(0'-). % '
|
||||
|
||||
|
||||
rdf_write_footer(Out) :-
|
||||
format(Out, '</rdf:RDF>~n', []).
|
||||
|
||||
|
||||
/*******************************
|
||||
* ANONYMOUS IDS *
|
||||
*******************************/
|
||||
|
||||
%% node_id_map(+Triples, -IdMap) is det.
|
||||
%
|
||||
% Create an assoc Resource -> NodeID for those anonymous resources
|
||||
% in Triples that need a NodeID. This implies all anonymous
|
||||
% resources that are used multiple times as object value.
|
||||
|
||||
node_id_map(Triples, IdMap) :-
|
||||
anonymous_objects(Triples, Objs),
|
||||
msort(Objs, Sorted),
|
||||
empty_assoc(IdMap0),
|
||||
nodeid_map(Sorted, 0, IdMap0, IdMap).
|
||||
|
||||
anonymous_objects([], []).
|
||||
anonymous_objects([rdf(_,_,O)|T0], Anon) :-
|
||||
rdf_is_bnode(O), !,
|
||||
Anon = [O|T],
|
||||
anonymous_objects(T0, T).
|
||||
anonymous_objects([_|T0], T) :-
|
||||
anonymous_objects(T0, T).
|
||||
|
||||
nodeid_map([], _, Map, Map).
|
||||
nodeid_map([H,H|T0], Id, Map0, Map) :- !,
|
||||
remove_leading(H, T0, T),
|
||||
atom_concat(bn, Id, NodeId),
|
||||
put_assoc(H, Map0, NodeId, Map1),
|
||||
Id2 is Id + 1,
|
||||
nodeid_map(T, Id2, Map1, Map).
|
||||
nodeid_map([_|T], Id, Map0, Map) :-
|
||||
nodeid_map(T, Id, Map0, Map).
|
||||
|
||||
remove_leading(H, [H|T0], T) :- !,
|
||||
remove_leading(H, T0, T).
|
||||
remove_leading(_, T, T).
|
||||
|
||||
|
||||
/*******************************
|
||||
* TRIPLES *
|
||||
*******************************/
|
||||
|
||||
rdf_write_triples(Triples, NodeIDs, Out) :-
|
||||
rdf_write_triples(Triples, NodeIDs, Out, [], Anon),
|
||||
rdf_write_anon(Anon, NodeIDs, Out, Anon).
|
||||
|
||||
rdf_write_triples([], _, _, Anon, Anon).
|
||||
rdf_write_triples([H|T0], NodeIDs, Out, Anon0, Anon) :-
|
||||
arg(1, H, S),
|
||||
subject_triples(S, [H|T0], T, OnSubject),
|
||||
( rdf_is_bnode(S)
|
||||
-> rdf_write_triples(T, NodeIDs, Out, [anon(S,_,OnSubject)|Anon0], Anon)
|
||||
; rdf_write_subject(OnSubject, S, NodeIDs, Out, Anon0),
|
||||
rdf_write_triples(T, NodeIDs, Out, Anon0, Anon)
|
||||
).
|
||||
|
||||
subject_triples(S, [H|T0], T, [H|M]) :-
|
||||
arg(1, H, S), !,
|
||||
subject_triples(S, T0, T, M).
|
||||
subject_triples(_, T, T, []).
|
||||
|
||||
|
||||
rdf_write_anon([], _, _, _).
|
||||
rdf_write_anon([anon(Subject, Done, Triples)|T], NodeIDs, Out, Anon) :-
|
||||
Done \== true, !,
|
||||
Done = true,
|
||||
rdf_write_subject(Triples, Subject, NodeIDs, Out, Anon),
|
||||
rdf_write_anon(T, NodeIDs, Out, Anon).
|
||||
rdf_write_anon([_|T], NodeIDs, Out, Anon) :-
|
||||
rdf_write_anon(T, NodeIDs, Out, Anon).
|
||||
|
||||
rdf_write_subject(Triples, Subject, NodeIDs, Out, Anon) :-
|
||||
rdf_write_subject(Triples, Out, Subject, NodeIDs, -, 0, Anon), !,
|
||||
format(Out, '~n', []).
|
||||
rdf_write_subject(_, Subject, _, _, _) :-
|
||||
throw(error(rdf_save_failed(Subject), 'Internal error')).
|
||||
|
||||
rdf_write_subject(Triples, Out, Subject, NodeIDs, DefNS, Indent, Anon) :-
|
||||
rdf_equal(rdf:type, RdfType),
|
||||
select(rdf(_, RdfType,Type), Triples, Triples1),
|
||||
rdf_id(Type, DefNS, TypeId),
|
||||
xml_is_name(TypeId), !,
|
||||
format(Out, '~*|<', [Indent]),
|
||||
rdf_write_id(Out, TypeId),
|
||||
save_about(Out, Subject, NodeIDs),
|
||||
save_attributes(Triples1, DefNS, Out, NodeIDs, TypeId, Indent, Anon).
|
||||
rdf_write_subject(Triples, Out, Subject, NodeIDs, _DefNS, Indent, Anon) :-
|
||||
format(Out, '~*|<rdf:Description', [Indent]),
|
||||
save_about(Out, Subject, NodeIDs),
|
||||
save_attributes(Triples, rdf, Out, NodeIDs, rdf:'Description', Indent, Anon).
|
||||
|
||||
xml_is_name(_NS:Atom) :- !,
|
||||
xml_name(Atom).
|
||||
xml_is_name(Atom) :-
|
||||
xml_name(Atom).
|
||||
|
||||
save_about(Out, Subject, NodeIDs) :-
|
||||
rdf_is_bnode(Subject), !,
|
||||
( get_assoc(Subject, NodeIDs, NodeID)
|
||||
-> format(Out,' rdf:nodeID="~w"', [NodeID])
|
||||
; true
|
||||
).
|
||||
save_about(Out, Subject, _) :-
|
||||
stream_property(Out, encoding(Encoding)),
|
||||
rdf_value(Subject, QSubject, Encoding),
|
||||
format(Out, ' rdf:about="~w"', [QSubject]), !.
|
||||
save_about(_, _, _) :-
|
||||
assertion(fail).
|
||||
|
||||
%% save_attributes(+List, +DefNS, +Out, +NodeIDs, Element, +Indent, +Anon)
|
||||
%
|
||||
% Save the attributes. Short literal attributes are saved in the
|
||||
% tag. Others as the content of the description element. The
|
||||
% begin tag has already been filled.
|
||||
|
||||
save_attributes(Triples, DefNS, Out, NodeIDs, Element, Indent, Anon) :-
|
||||
split_attributes(Triples, InTag, InBody),
|
||||
SubIndent is Indent + 2,
|
||||
save_attributes2(InTag, DefNS, tag, Out, NodeIDs, SubIndent, Anon),
|
||||
( InBody == []
|
||||
-> format(Out, '/>~n', [])
|
||||
; format(Out, '>~n', []),
|
||||
save_attributes2(InBody, _, body, Out, NodeIDs, SubIndent, Anon),
|
||||
format(Out, '~N~*|</~w>~n', [Indent, Element])
|
||||
).
|
||||
|
||||
% split_attributes(+Triples, -HeadAttrs, -BodyAttr)
|
||||
%
|
||||
% Split attribute (Name=Value) list into attributes for the head
|
||||
% and body. Attributes can only be in the head if they are literal
|
||||
% and appear only one time in the attribute list.
|
||||
|
||||
split_attributes(Triples, HeadAttr, BodyAttr) :-
|
||||
duplicate_attributes(Triples, Dupls, Singles),
|
||||
simple_literal_attributes(Singles, HeadAttr, Rest),
|
||||
append(Dupls, Rest, BodyAttr).
|
||||
|
||||
% duplicate_attributes(+Attrs, -Duplicates, -Singles)
|
||||
%
|
||||
% Extract attributes that appear more than onces as we cannot
|
||||
% dublicate an attribute in the head according to the XML rules.
|
||||
|
||||
duplicate_attributes([], [], []).
|
||||
duplicate_attributes([H|T], Dupls, Singles) :-
|
||||
arg(2, H, Name),
|
||||
named_attributes(Name, T, D, R),
|
||||
D \== [],
|
||||
append([H|D], Dupls2, Dupls), !,
|
||||
duplicate_attributes(R, Dupls2, Singles).
|
||||
duplicate_attributes([H|T], Dupls2, [H|Singles]) :-
|
||||
duplicate_attributes(T, Dupls2, Singles).
|
||||
|
||||
named_attributes(_, [], [], []) :- !.
|
||||
named_attributes(Name, [H|T], D, R) :-
|
||||
( arg(2, H, Name)
|
||||
-> D = [H|DT],
|
||||
named_attributes(Name, T, DT, R)
|
||||
; R = [H|RT],
|
||||
named_attributes(Name, T, D, RT)
|
||||
).
|
||||
|
||||
% simple_literal_attributes(+Attributes, -Inline, -Body)
|
||||
%
|
||||
% Split attributes for (literal) attributes to be used in the
|
||||
% begin-tag and ones that have to go into the body of the description.
|
||||
|
||||
simple_literal_attributes([], [], []).
|
||||
simple_literal_attributes([H|TA], [H|TI], B) :-
|
||||
in_tag_attribute(H), !,
|
||||
simple_literal_attributes(TA, TI, B).
|
||||
simple_literal_attributes([H|TA], I, [H|TB]) :-
|
||||
simple_literal_attributes(TA, I, TB).
|
||||
|
||||
in_tag_attribute(rdf(_,P,literal(Text))) :-
|
||||
atom(Text), % may not have lang qualifier
|
||||
atom_length(Text, Len),
|
||||
Len < 60,
|
||||
\+ is_bag_li_predicate(P).
|
||||
|
||||
|
||||
% save_attributes(+List, +DefNS, +TagOrBody, +Out, +NodeIDs, +Indent, +Anon)
|
||||
%
|
||||
% Save a list of attributes.
|
||||
|
||||
save_attributes2([], _, _, _, _, _, _).
|
||||
save_attributes2([H|T], DefNS, Where, Out, NodeIDs, Indent, Anon) :-
|
||||
save_attribute(Where, H, DefNS, Out, NodeIDs, Indent, Anon),
|
||||
save_attributes2(T, DefNS, Where, Out, NodeIDs, Indent, Anon).
|
||||
|
||||
%% save_attribute(+Where, +Triple, +DefNS, +Out, +NodeIDs, +Indent, +Anon)
|
||||
|
||||
save_attribute(tag, rdf(_, Name, literal(Value)), DefNS, Out, _, Indent, _Anon) :-
|
||||
AttIndent is Indent + 2,
|
||||
rdf_att_id(Name, DefNS, NameText),
|
||||
stream_property(Out, encoding(Encoding)),
|
||||
xml_quote_attribute(Value, QVal, Encoding),
|
||||
format(Out, '~N~*|', [AttIndent]),
|
||||
rdf_write_id(Out, NameText),
|
||||
format(Out, '="~w"', [QVal]).
|
||||
save_attribute(body, rdf(_,Name,literal(Literal)), DefNS, Out, _, Indent, _) :- !,
|
||||
rdf_p_id(Name, DefNS, NameText),
|
||||
format(Out, '~N~*|<', [Indent]),
|
||||
rdf_write_id(Out, NameText),
|
||||
( Literal = lang(Lang, Value)
|
||||
-> rdf_id(Lang, DefNS, LangText),
|
||||
format(Out, ' xml:lang="~w">', [LangText])
|
||||
; Literal = type(Type, Value)
|
||||
-> ( rdf_equal(Type, rdf:'XMLLiteral')
|
||||
-> write(Out, ' rdf:parseType="Literal">'),
|
||||
Value = Literal
|
||||
; stream_property(Out, encoding(Encoding)),
|
||||
rdf_value(Type, QVal, Encoding),
|
||||
format(Out, ' rdf:datatype="~w">', [QVal])
|
||||
)
|
||||
; atomic(Literal)
|
||||
-> write(Out, '>'),
|
||||
Value = Literal
|
||||
; write(Out, ' rdf:parseType="Literal">'),
|
||||
Value = Literal
|
||||
),
|
||||
save_attribute_value(Value, Out, Indent),
|
||||
write(Out, '</'), rdf_write_id(Out, NameText), write(Out, '>').
|
||||
save_attribute(body, rdf(_, Name, Value), DefNS, Out, NodeIDs, Indent, Anon) :-
|
||||
rdf_is_bnode(Value),
|
||||
memberchk(anon(Value, Done, ValueTriples), Anon), !,
|
||||
rdf_p_id(Name, DefNS, NameText),
|
||||
format(Out, '~N~*|<', [Indent]),
|
||||
rdf_write_id(Out, NameText),
|
||||
( var(Done)
|
||||
-> Done = true,
|
||||
SubIndent is Indent + 2,
|
||||
( rdf_equal(RdfType, rdf:type),
|
||||
rdf_equal(ListClass, rdf:'List'),
|
||||
memberchk(rdf(_, RdfType, ListClass), ValueTriples)
|
||||
-> format(Out, ' rdf:parseType="Collection">~n', []),
|
||||
rdf_save_list(ValueTriples, Out, Value, NodeIDs, DefNS, SubIndent, Anon)
|
||||
; format(Out, '>~n', []),
|
||||
rdf_write_subject(ValueTriples, Out, Value, NodeIDs, DefNS, SubIndent, Anon)
|
||||
),
|
||||
format(Out, '~N~*|</', [Indent]),
|
||||
rdf_write_id(Out, NameText),
|
||||
format(Out, '>~n', [])
|
||||
; get_assoc(Value, NodeIDs, NodeID)
|
||||
-> format(Out, ' rdf:nodeID="~w"/>', [NodeID])
|
||||
; assertion(fail)
|
||||
).
|
||||
save_attribute(body, rdf(_, Name, Value), DefNS, Out, _, Indent, _Anon) :-
|
||||
stream_property(Out, encoding(Encoding)),
|
||||
rdf_value(Value, QVal, Encoding),
|
||||
rdf_p_id(Name, DefNS, NameText),
|
||||
format(Out, '~N~*|<', [Indent]),
|
||||
rdf_write_id(Out, NameText),
|
||||
format(Out, ' rdf:resource="~w"/>', [QVal]).
|
||||
|
||||
save_attribute_value(Value, Out, _) :- % strings
|
||||
atom(Value), !,
|
||||
stream_property(Out, encoding(Encoding)),
|
||||
xml_quote_cdata(Value, QVal, Encoding),
|
||||
write(Out, QVal).
|
||||
save_attribute_value(Value, Out, _) :- % numbers
|
||||
number(Value), !,
|
||||
writeq(Out, Value). % quoted: preserve floats
|
||||
save_attribute_value(Value, Out, Indent) :-
|
||||
xml_is_dom(Value), !,
|
||||
XMLIndent is Indent+2,
|
||||
xml_write(Out, Value,
|
||||
[ header(false),
|
||||
indent(XMLIndent)
|
||||
]).
|
||||
save_attribute_value(Value, _Out, _) :-
|
||||
throw(error(save_attribute_value(Value), _)).
|
||||
|
||||
rdf_save_list(_, _, List, _, _, _, _) :-
|
||||
rdf_equal(List, rdf:nil), !.
|
||||
rdf_save_list(ListTriples, Out, List, NodeIDs, DefNS, Indent, Anon) :-
|
||||
rdf_equal(RdfFirst, rdf:first),
|
||||
memberchk(rdf(List, RdfFirst, First), ListTriples),
|
||||
( rdf_is_bnode(First),
|
||||
memberchk(anon(First, true, FirstTriples), Anon)
|
||||
-> nl(Out),
|
||||
rdf_write_subject(FirstTriples, Out, First, NodeIDs, DefNS, Indent, Anon)
|
||||
; stream_property(Out, encoding(Encoding)),
|
||||
rdf_value(First, QVal, Encoding),
|
||||
format(Out, '~N~*|<rdf:Description about="~w"/>',
|
||||
[Indent, QVal])
|
||||
),
|
||||
( rdf_equal(RdfRest, rdf:rest),
|
||||
memberchk(rdf(List, RdfRest, List2), ListTriples),
|
||||
\+ rdf_equal(List2, rdf:nil),
|
||||
memberchk(anon(List2, true, List2Triples), Anon)
|
||||
-> rdf_save_list(List2Triples, Out, List2, NodeIDs, DefNS, Indent, Anon)
|
||||
; true
|
||||
).
|
||||
|
||||
%% rdf_p_id(+Resource, +DefNS, -NSLocal)
|
||||
%
|
||||
% As rdf_id/3 for predicate names. Maps _:<N> to rdf:li.
|
||||
%
|
||||
% @tbd Ensure we are talking about an rdf:Bag
|
||||
|
||||
rdf_p_id(LI, _, 'rdf:li') :-
|
||||
is_bag_li_predicate(LI), !.
|
||||
rdf_p_id(Resource, DefNS, NSLocal) :-
|
||||
rdf_id(Resource, DefNS, NSLocal).
|
||||
|
||||
%% is_bag_li_predicate(+Pred) is semidet.
|
||||
%
|
||||
% True if Pred is _:N, as used for members of an rdf:Bag, rdf:Seq
|
||||
% or rdf:Alt.
|
||||
|
||||
is_bag_li_predicate(Pred) :-
|
||||
atom_concat('_:', AN, Pred),
|
||||
catch(atom_number(AN, N), _, true), integer(N), N >= 0, !.
|
||||
|
||||
|
||||
%% rdf_id(+Resource, +DefNS, -NSLocal)
|
||||
%
|
||||
% Generate a NS:Local name for Resource given the indicated
|
||||
% default namespace. This call is used for elements.
|
||||
|
||||
rdf_id(Id, NS, NS:Local) :-
|
||||
ns(NS, Full),
|
||||
Full \== '',
|
||||
atom_concat(Full, Local, Id), !.
|
||||
rdf_id(Id, _, NS:Local) :-
|
||||
ns(NS, Full),
|
||||
Full \== '',
|
||||
atom_concat(Full, Local, Id), !.
|
||||
rdf_id(Id, _, Id).
|
||||
|
||||
|
||||
%% rdf_write_id(+Out, +NSLocal) is det.
|
||||
%
|
||||
% Write an identifier. We cannot use native write on it as both NS
|
||||
% and Local can be operators.
|
||||
|
||||
rdf_write_id(Out, NS:Local) :- !,
|
||||
format(Out, '~w:~w', [NS, Local]).
|
||||
rdf_write_id(Out, Atom) :-
|
||||
write(Out, Atom).
|
||||
|
||||
|
||||
rdf_att_id(Id, _, NS:Local) :-
|
||||
ns(NS, Full),
|
||||
Full \== '',
|
||||
atom_concat(Full, Local, Id), !.
|
||||
rdf_att_id(Id, _, Id).
|
||||
|
||||
|
||||
%% rdf_value(+Resource, -Text, +Encoding)
|
||||
%
|
||||
% According to "6.4 RDF URI References" of the RDF Syntax
|
||||
% specification, a URI reference is UNICODE string not containing
|
||||
% control sequences, represented as UTF-8 and then as escaped
|
||||
% US-ASCII.
|
||||
%
|
||||
% NOTE: the to_be_described/1 trick ensures entity rewrite in
|
||||
% resources that start with 'http://t-d-b.org?'. This is a of a
|
||||
% hack to save the artchive data in the MultimediaN project. We
|
||||
% should use a more general mechanism.
|
||||
|
||||
rdf_value(V, Text, Encoding) :-
|
||||
to_be_described(Prefix),
|
||||
atom_concat(Prefix, V1, V),
|
||||
ns(NS, Full),
|
||||
atom_concat(Full, Local, V1), !,
|
||||
rdf_quote_uri(Local, QLocal0),
|
||||
xml_quote_attribute(QLocal0, QLocal, Encoding),
|
||||
concat_atom([Prefix, '&', NS, (';'), QLocal], Text).
|
||||
rdf_value(V, Text, Encoding) :-
|
||||
ns(NS, Full),
|
||||
atom_concat(Full, Local, V), !,
|
||||
rdf_quote_uri(Local, QLocal0),
|
||||
xml_quote_attribute(QLocal0, QLocal, Encoding),
|
||||
concat_atom(['&', NS, (';'), QLocal], Text).
|
||||
rdf_value(V, Q, Encoding) :-
|
||||
rdf_quote_uri(V, Q0),
|
||||
xml_quote_attribute(Q0, Q, Encoding).
|
||||
|
||||
to_be_described('http://t-d-b.org?').
|
||||
|
||||
|
||||
/*******************************
|
||||
* UTIL *
|
||||
*******************************/
|
||||
|
||||
ns(Id, Full) :-
|
||||
rdf_db:ns(Id, Full).
|
237
packages/sgml/RDF/rdfs.rdfs
Normal file
237
packages/sgml/RDF/rdfs.rdfs
Normal file
@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<!DOCTYPE rdf:RDF [
|
||||
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
|
||||
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
||||
]>
|
||||
|
||||
<rdf:RDF
|
||||
xmlns:rdf="&rdf;"
|
||||
xmlns:rdfs="&rdfs;">
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;Resource">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">Resource</rdfs:label>
|
||||
<rdfs:comment>The class resource, everything.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:Property rdf:about="&rdf;type">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">type</rdfs:label>
|
||||
<rdfs:comment>Indicates membership of a class</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Class"/>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;Class">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">Class</rdfs:label>
|
||||
<rdfs:comment>The concept of Class</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Resource"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;subClassOf">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">subClassOf</rdfs:label>
|
||||
<rdfs:comment>Indicates membership of a class</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Class"/>
|
||||
<rdfs:domain rdf:resource="&rdfs;Class"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;subPropertyOf">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">subPropertyOf</rdfs:label>
|
||||
<rdfs:comment>Indicates specialization of properties</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdf;Property"/>
|
||||
<rdfs:domain rdf:resource="&rdf;Property"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;Property">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">Property</rdfs:label>
|
||||
<rdfs:comment>The concept of a property.</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Resource"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;comment">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">comment</rdfs:label>
|
||||
<rdfs:comment>Use this for descriptions</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:range rdf:resource="&rdfs;Literal"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;label">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">label</rdfs:label>
|
||||
<rdfs:comment>Provides a human-readable version of a resource name.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:range rdf:resource="&rdfs;Literal"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;domain">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">domain</rdfs:label>
|
||||
<rdfs:comment>A domain class for a property type</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Class"/>
|
||||
<rdfs:domain rdf:resource="&rdf;Property"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;range">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">range</rdfs:label>
|
||||
<rdfs:comment>A range class for a property type</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Class"/>
|
||||
<rdfs:domain rdf:resource="&rdf;Property"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;seeAlso">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">seeAlso</rdfs:label>
|
||||
<rdfs:comment>A resource that provides information about the subject resource</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;isDefinedBy">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdf:type resource="&rdf;Property"/>
|
||||
<rdfs:subPropertyOf rdf:resource="&rdfs;seeAlso"/>
|
||||
<rdfs:label xml:lang="en">isDefinedBy</rdfs:label>
|
||||
<rdfs:comment>Indicates the namespace of a resource</rdfs:comment>
|
||||
<rdfs:range rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;Literal">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">Literal</rdfs:label>
|
||||
<rdfs:comment>This represents the set of atomic values, eg. textual strings.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;Statement">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">Statement</rdfs:label>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:comment>The class of RDF statements.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:Property about="&rdf;subject">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">subject</rdfs:label>
|
||||
<rdfs:comment>The subject of an RDF statement.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdf;Statement"/>
|
||||
<rdfs:range rdf:resource="&rdfs;Resource"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property about="&rdf;predicate">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">predicate</rdfs:label>
|
||||
<rdfs:comment>the predicate of an RDF statement.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdf;Statement"/>
|
||||
<rdfs:range rdf:resource="&rdf;Property"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property about="&rdf;object">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">object</rdfs:label>
|
||||
<rdfs:comment>The object of an RDF statement.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdf;Statement"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;Container">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">Container</rdfs:label>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Resource"/>
|
||||
<rdfs:comment>This represents the set Containers.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;Bag">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">Bag</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">An unordered collection.</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Container"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;Seq">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">Seq</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">An ordered collection.</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Container"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;Alt">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">Alt</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">A collection of alternatives.</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdfs;Container"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;ContainerMembershipProperty">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">ContainerMembershipProperty</rdfs:label>
|
||||
<rdfs:comment>The container membership properties, rdf:1, rdf:2, ..., all of which are sub-properties of 'member'.</rdfs:comment>
|
||||
<rdfs:subClassOf rdf:resource="&rdf;Property"/>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:Property rdf:about="&rdfs;member">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">member</rdfs:label>
|
||||
<rdfs:comment>a member of a container</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdfs;Container"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdf;value">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">value</rdfs:label>
|
||||
<rdfs:comment>Identifies the principal value (usually a string) of a property when the property value is a structured resource</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdfs;Resource"/>
|
||||
</rdf:Property>
|
||||
|
||||
<!-- the following are new additions, Nov 2002 -->
|
||||
|
||||
<rdfs:Class rdf:about="&rdf;List">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">List</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">The class of RDF Lists</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdf:List rdf:about="&rdf;nil">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">nil</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it.</rdfs:comment>
|
||||
</rdf:List>
|
||||
|
||||
<rdf:Property rdf:about="&rdf;first">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">first</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">The first item in an RDF list. Also often called the head.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdf;List"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdf:Property rdf:about="&rdf;rest">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdf;"/>
|
||||
<rdfs:label xml:lang="en">rest</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">The rest of an RDF list after the first item. Also often called the tail.</rdfs:comment>
|
||||
<rdfs:domain rdf:resource="&rdf;List"/>
|
||||
<rdfs:range rdf:resource="&rdf;List"/>
|
||||
</rdf:Property>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;Datatype">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">Datatype</rdfs:label>
|
||||
<rdfs:comment xml:lang="en">The class of datatypes.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
<rdfs:Class rdf:about="&rdfs;XMLLiteral">
|
||||
<rdfs:isDefinedBy rdf:resource="&rdfs;"/>
|
||||
<rdfs:label xml:lang="en">XMLLiteral</rdfs:label>
|
||||
<rdfs:comment>The class of XML literals.</rdfs:comment>
|
||||
</rdfs:Class>
|
||||
|
||||
|
||||
<rdf:Description rdf:about="&rdfs;">
|
||||
<rdfs:seeAlso rdf:resource="http://www.w3.org/2000/01/rdf-schema-more"/>
|
||||
</rdf:Description>
|
||||
|
||||
</rdf:RDF>
|
144
packages/sgml/RDF/rewrite.pl
Normal file
144
packages/sgml/RDF/rewrite.pl
Normal file
@ -0,0 +1,144 @@
|
||||
/* $Id$
|
||||
|
||||
Part of XPCE
|
||||
Designed and implemented by Anjo Anjewierden and Jan Wielemaker
|
||||
E-mail: jan@swi.psy.uva.nl
|
||||
|
||||
Copyright (C) 2000 University of Amsterdam. All rights reserved.
|
||||
*/
|
||||
|
||||
:- module(rewrite,
|
||||
[ rewrite/2, % +Rule, +Input
|
||||
rew_term_expansion/2,
|
||||
rew_goal_expansion/2
|
||||
]).
|
||||
:- use_module(library(quintus)).
|
||||
|
||||
:- meta_predicate
|
||||
rewrite(:, +).
|
||||
:- op(1200, xfx, user:(::=)).
|
||||
|
||||
|
||||
/*******************************
|
||||
* COMPILATION *
|
||||
*******************************/
|
||||
|
||||
rew_term_expansion((Rule ::= RuleBody), (Head :- Body)) :-
|
||||
translate(RuleBody, Term, Body0),
|
||||
simplify(Body0, Body),
|
||||
Rule =.. List,
|
||||
append(List, [Term], L2),
|
||||
Head =.. L2.
|
||||
|
||||
rew_goal_expansion(rewrite(To, From), Goal) :-
|
||||
nonvar(To),
|
||||
To = \Rule,
|
||||
compound(Rule),
|
||||
Rule =.. List,
|
||||
append(List, [From], List2),
|
||||
Goal =.. List2.
|
||||
|
||||
|
||||
/*******************************
|
||||
* TOPLEVEL *
|
||||
*******************************/
|
||||
|
||||
%% rewrite(?To, +From)
|
||||
%
|
||||
% Invoke the term-rewriting system
|
||||
|
||||
rewrite(To, From) :-
|
||||
strip_module(To, M, T),
|
||||
( var(T)
|
||||
-> From = T
|
||||
; T = \Rule
|
||||
-> call(M:Rule, From)
|
||||
; match(To, M, From)
|
||||
).
|
||||
|
||||
match(Rule, M, From) :-
|
||||
translate(Rule, From, Code),
|
||||
M:Code.
|
||||
|
||||
translate(Var, Var, true) :-
|
||||
var(Var), !.
|
||||
translate((\Command, !), Var, (Goal, !)) :- !,
|
||||
( callable(Command),
|
||||
Command =.. List
|
||||
-> append(List, [Var], L2),
|
||||
Goal =.. L2
|
||||
; Goal = rewrite(\Command, Var)
|
||||
).
|
||||
translate(\Command, Var, Goal) :- !,
|
||||
( callable(Command),
|
||||
Command =.. List
|
||||
-> append(List, [Var], L2),
|
||||
Goal =.. L2
|
||||
; Goal = rewrite(\Command, Var)
|
||||
).
|
||||
translate(Atomic, Atomic, true) :-
|
||||
atomic(Atomic), !.
|
||||
translate(C, _, Cmd) :-
|
||||
command(C, Cmd), !.
|
||||
translate((A, B), T, Code) :-
|
||||
( command(A, Cmd)
|
||||
-> !, translate(B, T, C),
|
||||
Code = (Cmd, C)
|
||||
; command(B, Cmd)
|
||||
-> !, translate(A, T, C),
|
||||
Code = (C, Cmd)
|
||||
).
|
||||
translate(Term0, Term, Command) :-
|
||||
functor(Term0, Name, Arity),
|
||||
functor(Term, Name, Arity),
|
||||
translate_args(0, Arity, Term0, Term, Command).
|
||||
|
||||
translate_args(N, N, _, _, true) :- !.
|
||||
translate_args(I0, Arity, T0, T1, (C0,C)) :-
|
||||
I is I0 + 1,
|
||||
arg(I, T0, A0),
|
||||
arg(I, T1, A1),
|
||||
translate(A0, A1, C0),
|
||||
translate_args(I, Arity, T0, T1, C).
|
||||
|
||||
command(0, _) :- !, % catch variables
|
||||
fail.
|
||||
command({A}, A).
|
||||
command(!, !).
|
||||
|
||||
/*******************************
|
||||
* SIMPLIFY *
|
||||
*******************************/
|
||||
|
||||
%% simplify(+Raw, -Simplified)
|
||||
%
|
||||
% Get rid of redundant `true' goals generated by translate/3.
|
||||
|
||||
simplify(V, V) :-
|
||||
var(V), !.
|
||||
simplify((A0,B), A) :-
|
||||
B == true, !,
|
||||
simplify(A0, A).
|
||||
simplify((A,B0), B) :-
|
||||
A == true, !,
|
||||
simplify(B0, B).
|
||||
simplify((A0, B0), C) :- !,
|
||||
simplify(A0, A),
|
||||
simplify(B0, B),
|
||||
( ( A \== A0
|
||||
; B \== B0
|
||||
)
|
||||
-> simplify((A,B), C)
|
||||
; C = (A,B)
|
||||
).
|
||||
simplify(X, X).
|
||||
|
||||
/*******************************
|
||||
* XREF *
|
||||
*******************************/
|
||||
|
||||
:- multifile
|
||||
prolog:called_by/2.
|
||||
|
||||
prolog:called_by(rewrite(Spec, _Term), Called) :-
|
||||
findall(G+1, sub_term(\G, Spec), Called).
|
12
packages/sgml/RDF/suite/ex_19.rdf
Normal file
12
packages/sgml/RDF/suite/ex_19.rdf
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:ex="http://example.org/stuff/1.0/">
|
||||
<rdf:Description rdf:about="http://example.org/basket">
|
||||
<ex:hasFruit rdf:ID="l1" rdf:parseType="Collection">
|
||||
<rdf:Description rdf:about="http://example.org/banana"/>
|
||||
<rdf:Description rdf:about="http://example.org/apple"/>
|
||||
<rdf:Description rdf:about="http://example.org/pear"/>
|
||||
</ex:hasFruit>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
|
14
packages/sgml/RDF/suite/ok/ex_19.ok
Normal file
14
packages/sgml/RDF/suite/ok/ex_19.ok
Normal file
@ -0,0 +1,14 @@
|
||||
rdf('http://example.org/basket', 'http://example.org/stuff/1.0/':hasFruit, '__List1').
|
||||
rdf(l1, rdf:type, rdf:'Statement').
|
||||
rdf(l1, rdf:subject, 'http://example.org/basket').
|
||||
rdf(l1, rdf:predicate, 'http://example.org/stuff/1.0/':hasFruit).
|
||||
rdf(l1, rdf:object, '__List1').
|
||||
rdf('__List1', rdf:type, rdf:'List').
|
||||
rdf('__List1', rdf:first, 'http://example.org/banana').
|
||||
rdf('__List1', rdf:rest, '__List2').
|
||||
rdf('__List2', rdf:type, rdf:'List').
|
||||
rdf('__List2', rdf:first, 'http://example.org/apple').
|
||||
rdf('__List2', rdf:rest, '__List3').
|
||||
rdf('__List3', rdf:type, rdf:'List').
|
||||
rdf('__List3', rdf:first, 'http://example.org/pear').
|
||||
rdf('__List3', rdf:rest, rdf:nil).
|
1
packages/sgml/RDF/suite/ok/t1.ok
Normal file
1
packages/sgml/RDF/suite/ok/t1.ok
Normal file
@ -0,0 +1 @@
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', literal('Ora Lassila')).
|
4
packages/sgml/RDF/suite/ok/t10.ok
Normal file
4
packages/sgml/RDF/suite/ok/t10.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf(pages, rdf:type, rdf:'Bag').
|
||||
rdf(pages, rdf:'_1', 'http://foo.org/foo.html').
|
||||
rdf(pages, rdf:'_2', 'http://bar.org/bar.html').
|
||||
rdf(each(pages), 'http://purl.org/metadata/dublin_core/':'Creator', literal('Ora Lassila')).
|
1
packages/sgml/RDF/suite/ok/t11.ok
Normal file
1
packages/sgml/RDF/suite/ok/t11.ok
Normal file
@ -0,0 +1 @@
|
||||
rdf('http://www.swi.psy.uva.nl/projects/SWI-Prolog/', 'http://description.org/schema/':'Creator', literal('Jan Wielemaker')).
|
1
packages/sgml/RDF/suite/ok/t12.ok
Normal file
1
packages/sgml/RDF/suite/ok/t12.ok
Normal file
@ -0,0 +1 @@
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', literal('Ora Lassila')).
|
1
packages/sgml/RDF/suite/ok/t13.ok
Normal file
1
packages/sgml/RDF/suite/ok/t13.ok
Normal file
@ -0,0 +1 @@
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', literal('Ora Lassila')).
|
3
packages/sgml/RDF/suite/ok/t14.ok
Normal file
3
packages/sgml/RDF/suite/ok/t14.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Publisher', literal('World Wide Web Consortium')).
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Title', literal('W3C Home Page')).
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Date', literal('1998-10-03T02:27')).
|
3
packages/sgml/RDF/suite/ok/t15.ok
Normal file
3
packages/sgml/RDF/suite/ok/t15.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Publisher', literal('World Wide Web Consortium')).
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Title', literal('W3C Home Page')).
|
||||
rdf('http://www.w3.org', 'http://description.org/schema/':'Date', literal('1998-10-03T02:27')).
|
3
packages/sgml/RDF/suite/ok/t16.ok
Normal file
3
packages/sgml/RDF/suite/ok/t16.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', 'http://www.w3.org/staffId/85740').
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Name', literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Email', literal('lassila@w3.org')).
|
3
packages/sgml/RDF/suite/ok/t17.ok
Normal file
3
packages/sgml/RDF/suite/ok/t17.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Name', literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Email', literal('lassila@w3.org')).
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', 'http://www.w3.org/staffId/85740').
|
3
packages/sgml/RDF/suite/ok/t18.ok
Normal file
3
packages/sgml/RDF/suite/ok/t18.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Name', literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/schema/':'Email', literal('lassila@w3.org')).
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', 'http://www.w3.org/staffId/85740').
|
4
packages/sgml/RDF/suite/ok/t19.ok
Normal file
4
packages/sgml/RDF/suite/ok/t19.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('http://www.w3.org/staffId/85740', rdf:type, 'http://description.org/schema/Person').
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/view/':'Name', literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/view/':'Email', literal('lassila@w3.org')).
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', 'http://www.w3.org/staffId/85740').
|
3
packages/sgml/RDF/suite/ok/t2.ok
Normal file
3
packages/sgml/RDF/suite/ok/t2.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('JW', sex, literal(male)).
|
||||
rdf('JW', employed_at, literal('SWI')).
|
||||
rdf('SWI-prolog', 'http://description.org/schema/':'Creator', 'JW').
|
4
packages/sgml/RDF/suite/ok/t20.ok
Normal file
4
packages/sgml/RDF/suite/ok/t20.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('http://www.w3.org/staffId/85740', rdf:type, 'http://description.org/schema/Person').
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/view/':'Name', literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/staffId/85740', 'http://description.org/view/':'Email', literal('lassila@w3.org')).
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', 'http://www.w3.org/staffId/85740').
|
7
packages/sgml/RDF/suite/ok/t21.ok
Normal file
7
packages/sgml/RDF/suite/ok/t21.ok
Normal file
@ -0,0 +1,7 @@
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Bag1', rdf:'_1', 'http://mycollege.edu/students/Amy').
|
||||
rdf('__Bag1', rdf:'_2', 'http://mycollege.edu/students/Tim').
|
||||
rdf('__Bag1', rdf:'_3', 'http://mycollege.edu/students/John').
|
||||
rdf('__Bag1', rdf:'_4', 'http://mycollege.edu/students/Mary').
|
||||
rdf('__Bag1', rdf:'_5', 'http://mycollege.edu/students/Sue').
|
||||
rdf('http://mycollege.edu/courses/6.001', 'http://description.org/schema/':students, '__Bag1').
|
5
packages/sgml/RDF/suite/ok/t22.ok
Normal file
5
packages/sgml/RDF/suite/ok/t22.ok
Normal file
@ -0,0 +1,5 @@
|
||||
rdf('__Alt1', rdf:type, rdf:'Alt').
|
||||
rdf('__Alt1', rdf:'_1', 'ftp://ftp.x.org').
|
||||
rdf('__Alt1', rdf:'_2', 'ftp://ftp.cs.purdue.edu').
|
||||
rdf('__Alt1', rdf:'_3', 'ftp://ftp.eu.net').
|
||||
rdf('http://x.org/packages/X11', 'http://description.org/schema/':'DistributionSite', '__Alt1').
|
1
packages/sgml/RDF/suite/ok/t23.ok
Normal file
1
packages/sgml/RDF/suite/ok/t23.ok
Normal file
@ -0,0 +1 @@
|
||||
rdf(prefix('http://foo.org/doc'), 'http://description.org/schema/Copyright', literal('© 1998, The Foo Organization')).
|
5
packages/sgml/RDF/suite/ok/t24.ok
Normal file
5
packages/sgml/RDF/suite/ok/t24.ok
Normal file
@ -0,0 +1,5 @@
|
||||
rdf('__Description1', rdf:subject, 'http://www.w3.org/Home/Lassila').
|
||||
rdf('__Description1', rdf:predicate, 'http://description.org/schema/Creator').
|
||||
rdf('__Description1', rdf:object, literal('Ora Lassila')).
|
||||
rdf('__Description1', rdf:type, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement').
|
||||
rdf('__Description1', 'http://description.org/schema/':attributedTo, literal('Ralph Swick')).
|
13
packages/sgml/RDF/suite/ok/t25.ok
Normal file
13
packages/sgml/RDF/suite/ok/t25.ok
Normal file
@ -0,0 +1,13 @@
|
||||
rdf('D_001', rdf:type, rdf:'Bag').
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', literal('Ora Lassila')).
|
||||
rdf('__Statement1', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement1', rdf:subject, 'http://www.w3.org/Home/Lassila').
|
||||
rdf('__Statement1', rdf:predicate, 'http://description.org/schema/':'Creator').
|
||||
rdf('__Statement1', rdf:object, literal('Ora Lassila')).
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Title', literal('Ora\'s Home Page')).
|
||||
rdf('__Statement2', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement2', rdf:subject, 'http://www.w3.org/Home/Lassila').
|
||||
rdf('__Statement2', rdf:predicate, 'http://description.org/schema/':'Title').
|
||||
rdf('__Statement2', rdf:object, literal('Ora\'s Home Page')).
|
||||
rdf('D_001', rdf:'_1', '__Statement1').
|
||||
rdf('D_001', rdf:'_2', '__Statement2').
|
8
packages/sgml/RDF/suite/ok/t26.ok
Normal file
8
packages/sgml/RDF/suite/ok/t26.ok
Normal file
@ -0,0 +1,8 @@
|
||||
rdf('JSPapersByDate', rdf:type, rdf:'Seq').
|
||||
rdf('JSPapersByDate', rdf:'_1', 'http://www.dogworld.com/Aug96.doc').
|
||||
rdf('JSPapersByDate', rdf:'_2', 'http://www.webnuts.net/Jan97.html').
|
||||
rdf('JSPapersByDate', rdf:'_3', 'http://www.carchat.com/Sept97.html').
|
||||
rdf('JSPapersBySubj', rdf:type, rdf:'Seq').
|
||||
rdf('JSPapersBySubj', rdf:'_1', 'http://www.carchat.com/Sept97.html').
|
||||
rdf('JSPapersBySubj', rdf:'_2', 'http://www.dogworld.com/Aug96.doc').
|
||||
rdf('JSPapersBySubj', rdf:'_3', 'http://www.webnuts.net/Jan97.html').
|
12
packages/sgml/RDF/suite/ok/t27.ok
Normal file
12
packages/sgml/RDF/suite/ok/t27.ok
Normal file
@ -0,0 +1,12 @@
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:type, rdf:'Seq').
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:'_1', literal('Mary Andrew')).
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:'_2', literal('Jacky Crystal')).
|
||||
rdf('http://www.foo.com/cool.html', 'http://purl.org/metadata/dublin_core#':'Creator', 'CreatorsAlphabeticalBySurname').
|
||||
rdf('MirroredSites', rdf:type, rdf:'Bag').
|
||||
rdf('MirroredSites', rdf:'_1', 'http://www.foo.com.au/cool.html').
|
||||
rdf('MirroredSites', rdf:'_2', 'http://www.foo.com.it/cool.html').
|
||||
rdf('http://www.foo.com/cool.html', 'http://purl.org/metadata/dublin_core#':'Identifier', 'MirroredSites').
|
||||
rdf('__Alt1', rdf:type, rdf:'Alt').
|
||||
rdf('__Alt1', rdf:'_1', literal(lang(en, 'The Coolest Web Page'))).
|
||||
rdf('__Alt1', rdf:'_2', literal(lang(it, 'Il Pagio di Web Fuba'))).
|
||||
rdf('http://www.foo.com/cool.html', 'http://purl.org/metadata/dublin_core#':'Title', '__Alt1').
|
3
packages/sgml/RDF/suite/ok/t28.ok
Normal file
3
packages/sgml/RDF/suite/ok/t28.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('__Description1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#':value, literal('020 - Library Science')).
|
||||
rdf('__Description1', 'http://mycorp.com/schemas/my-schema#':'Classification', literal('Dewey Decimal Code')).
|
||||
rdf('http://www.webnuts.net/Jan97.html', 'http://purl.org/metadata/dublin_core#':'Subject', '__Description1').
|
3
packages/sgml/RDF/suite/ok/t29.ok
Normal file
3
packages/sgml/RDF/suite/ok/t29.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('__Description1', rdf:value, literal('200')).
|
||||
rdf('__Description1', 'http://www.nist.gov/units/':units, 'http://www.nist.gov/units/Pounds').
|
||||
rdf('John_Smith', 'http://www.nist.gov/units/':weight, '__Description1').
|
3
packages/sgml/RDF/suite/ok/t3.ok
Normal file
3
packages/sgml/RDF/suite/ok/t3.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('JW', name, literal('Jan Wielemaker')).
|
||||
rdf('JW', works_at, literal('SWI')).
|
||||
rdf('http://www.swi.psy.uva.nl/projects/SWI-Prolog/', 'http://description.org/schema/':'Creator', 'JW').
|
12
packages/sgml/RDF/suite/ok/t30.ok
Normal file
12
packages/sgml/RDF/suite/ok/t30.ok
Normal file
@ -0,0 +1,12 @@
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Title', literal('D-Lib Program - Research in Digital Libraries')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Description', literal('The D-Lib program supports the community of people\n with research interests in digital libraries and electronic\n publishing.')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Publisher', literal('Corporation For National Research Initiatives')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Date', literal('1995-01-07')).
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Bag1', rdf:'_1', literal('Research; statistical methods')).
|
||||
rdf('__Bag1', rdf:'_2', literal('Education, research, related topics')).
|
||||
rdf('__Bag1', rdf:'_3', literal('Library use Studies')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Subject', '__Bag1').
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Type', literal('World Wide Web Home Page')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Format', literal('text/html')).
|
||||
rdf('http://www.dlib.org', 'http://purl.org/metadata/dublin_core#':'Language', literal(en)).
|
17
packages/sgml/RDF/suite/ok/t31.ok
Normal file
17
packages/sgml/RDF/suite/ok/t31.ok
Normal file
@ -0,0 +1,17 @@
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Title', literal('DLIB Magazine - The Magazine for Digital Library Research\n - May 1998')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Description', literal('D-LIB magazine is a monthly compilation of\n contributed stories, commentary, and briefings.')).
|
||||
rdf('__Description1', 'http://purl.org/metadata/dublin_core_qualifiers#':'AgentType', 'http://purl.org/metadata/dublin_core_qualifiers#Editor').
|
||||
rdf('__Description1', rdf:value, literal('Amy Friedlander')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Contributor', '__Description1').
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Publisher', literal('Corporation for National Research Initiatives')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Date', literal('1998-01-05')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Type', literal('electronic journal')).
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Bag1', rdf:'_1', literal('library use studies')).
|
||||
rdf('__Bag1', rdf:'_2', literal('magazines and newspapers')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Subject', '__Bag1').
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Format', literal('text/html')).
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Identifier', literal('urn:issn:1082-9873')).
|
||||
rdf('__Description2', 'http://purl.org/metadata/dublin_core_qualifiers#':'RelationType', 'http://purl.org/metadata/dublin_core_qualifiers#IsPartOf').
|
||||
rdf('__Description2', rdf:value, 'http://www.dlib.org').
|
||||
rdf('http://www.dlib.org/dlib/may98/05contents.html', 'http://purl.org/metadata/dublin_core#':'Relation', '__Description2').
|
15
packages/sgml/RDF/suite/ok/t32.ok
Normal file
15
packages/sgml/RDF/suite/ok/t32.ok
Normal file
@ -0,0 +1,15 @@
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Title', literal('An Introduction to the Resource Description Framework')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Creator', literal('Eric J. Miller')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Description', literal('The Resource Description Framework (RDF) is an\n infrastructure that enables the encoding, exchange and reuse of\n structured metadata. rdf is an application of xml that imposes needed\n structural constraints to provide unambiguous methods of expressing\n semantics. rdf additionally provides a means for publishing both\n human-readable and machine-processable vocabularies designed to\n encourage the reuse and extension of metadata semantics among\n disparate information communities. the structural constraints rdf\n imposes to support the consistent encoding and exchange of\n standardized metadata provides for the interchangeability of separate\n packages of metadata defined by different resource description\n communities. ')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Publisher', literal('Corporation for National Research Initiatives')).
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Bag1', rdf:'_1', literal('machine-readable catalog record formats')).
|
||||
rdf('__Bag1', rdf:'_2', literal('applications of computer file organization and\n\t access methods')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Subject', '__Bag1').
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Rights', literal('Copyright @ 1998 Eric Miller')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Type', literal('Electronic Document')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Format', literal('text/html')).
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Language', literal(en)).
|
||||
rdf('__Description1', 'http://purl.org/metadata/dublin_core_qualifiers#':'RelationType', 'http://purl.org/metadata/dublin_core_qualifiers#IsPartOf').
|
||||
rdf('__Description1', rdf:value, 'http://www.dlib.org/dlib/may98/05contents.html').
|
||||
rdf('http://www.dlib.org/dlib/may98/miller/05miller.html', 'http://purl.org/metadata/dublin_core#':'Relation', '__Description1').
|
2
packages/sgml/RDF/suite/ok/t33.ok
Normal file
2
packages/sgml/RDF/suite/ok/t33.ok
Normal file
@ -0,0 +1,2 @@
|
||||
rdf('http://mycorp.com/papers/NobelPaper1', 'http://purl.org/metadata/dublin_core#Title', literal(type('http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral', ['Ramifications of ', element('http://www.w3.org/TR/REC-mathml':apply, [], [element('http://www.w3.org/TR/REC-mathml':power, [], []), element('http://www.w3.org/TR/REC-mathml':apply, [], [element('http://www.w3.org/TR/REC-mathml':plus, [], []), element('http://www.w3.org/TR/REC-mathml':ci, [], [a]), element('http://www.w3.org/TR/REC-mathml':ci, [], [b])]), element('http://www.w3.org/TR/REC-mathml':cn, [], ['2'])]), ' to World Peace\n ']))).
|
||||
rdf('http://mycorp.com/papers/NobelPaper1', 'http://purl.org/metadata/dublin_core#Creator', literal('David Hume')).
|
44
packages/sgml/RDF/suite/ok/t34.ok
Normal file
44
packages/sgml/RDF/suite/ok/t34.ok
Normal file
@ -0,0 +1,44 @@
|
||||
rdf('L01', rdf:type, rdf:'Bag').
|
||||
rdf('http://www.w3.org/PICS/Overview.html', 'http://www.gcf.org/v2.5':suds, literal('0.5')).
|
||||
rdf('__Statement1', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement1', rdf:subject, 'http://www.w3.org/PICS/Overview.html').
|
||||
rdf('__Statement1', rdf:predicate, 'http://www.gcf.org/v2.5':suds).
|
||||
rdf('__Statement1', rdf:object, literal('0.5')).
|
||||
rdf('http://www.w3.org/PICS/Overview.html', 'http://www.gcf.org/v2.5':density, literal('0')).
|
||||
rdf('__Statement2', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement2', rdf:subject, 'http://www.w3.org/PICS/Overview.html').
|
||||
rdf('__Statement2', rdf:predicate, 'http://www.gcf.org/v2.5':density).
|
||||
rdf('__Statement2', rdf:object, literal('0')).
|
||||
rdf('http://www.w3.org/PICS/Overview.html', 'http://www.gcf.org/v2.5':'color.hue', literal('1')).
|
||||
rdf('__Statement3', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement3', rdf:subject, 'http://www.w3.org/PICS/Overview.html').
|
||||
rdf('__Statement3', rdf:predicate, 'http://www.gcf.org/v2.5':'color.hue').
|
||||
rdf('__Statement3', rdf:object, literal('1')).
|
||||
rdf('L01', rdf:'_1', '__Statement1').
|
||||
rdf('L01', rdf:'_2', '__Statement2').
|
||||
rdf('L01', rdf:'_3', '__Statement3').
|
||||
rdf('L02', rdf:type, rdf:'Bag').
|
||||
rdf('http://www.w3.org/PICS/Underview.html', 'http://www.gcf.org/v2.5':subject, literal('2')).
|
||||
rdf('__Statement4', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement4', rdf:subject, 'http://www.w3.org/PICS/Underview.html').
|
||||
rdf('__Statement4', rdf:predicate, 'http://www.gcf.org/v2.5':subject).
|
||||
rdf('__Statement4', rdf:object, literal('2')).
|
||||
rdf('http://www.w3.org/PICS/Underview.html', 'http://www.gcf.org/v2.5':density, literal('1')).
|
||||
rdf('__Statement5', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement5', rdf:subject, 'http://www.w3.org/PICS/Underview.html').
|
||||
rdf('__Statement5', rdf:predicate, 'http://www.gcf.org/v2.5':density).
|
||||
rdf('__Statement5', rdf:object, literal('1')).
|
||||
rdf('http://www.w3.org/PICS/Underview.html', 'http://www.gcf.org/v2.5':'color.hue', literal('1')).
|
||||
rdf('__Statement6', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement6', rdf:subject, 'http://www.w3.org/PICS/Underview.html').
|
||||
rdf('__Statement6', rdf:predicate, 'http://www.gcf.org/v2.5':'color.hue').
|
||||
rdf('__Statement6', rdf:object, literal('1')).
|
||||
rdf('L02', rdf:'_1', '__Statement4').
|
||||
rdf('L02', rdf:'_2', '__Statement5').
|
||||
rdf('L02', rdf:'_3', '__Statement6').
|
||||
rdf(each('L01'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':by, literal('John Doe')).
|
||||
rdf(each('L01'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':on, literal('1994.11.05T08:15-0500')).
|
||||
rdf(each('L01'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':until, literal('1995.12.31T23:59-0000')).
|
||||
rdf(each('L02'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':by, literal('Jane Doe')).
|
||||
rdf(each('L02'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':on, literal('1994.11.05T08:15-0500')).
|
||||
rdf(each('L02'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':until, literal('1995.12.31T23:59-0000')).
|
8
packages/sgml/RDF/suite/ok/t35.ok
Normal file
8
packages/sgml/RDF/suite/ok/t35.ok
Normal file
@ -0,0 +1,8 @@
|
||||
rdf('L03', rdf:type, rdf:'Bag').
|
||||
rdf(prefix('http://www.w3.org/WWW/'), 'http://www.ages.org/our-service/v1.0/':age, literal('11')).
|
||||
rdf('__Statement1', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement1', rdf:subject, prefix('http://www.w3.org/WWW/')).
|
||||
rdf('__Statement1', rdf:predicate, 'http://www.ages.org/our-service/v1.0/':age).
|
||||
rdf('__Statement1', rdf:object, literal('11')).
|
||||
rdf('L03', rdf:'_1', '__Statement1').
|
||||
rdf(each('L03'), 'http://www.w3.org/TR/xxxx/WD-PICS-labels#':by, literal('abaird@w3.org')).
|
4
packages/sgml/RDF/suite/ok/t36.ok
Normal file
4
packages/sgml/RDF/suite/ok/t36.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:type, rdf:'Seq').
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:'_1', 'Mary Andrew').
|
||||
rdf('CreatorsAlphabeticalBySurname', rdf:'_2', 'Jacky Crystal').
|
||||
rdf('http://www.foo.com/cool.html', 'http://purl.org/metadata/dublin_core#':'Creator', 'CreatorsAlphabeticalBySurname').
|
7
packages/sgml/RDF/suite/ok/t37.ok
Normal file
7
packages/sgml/RDF/suite/ok/t37.ok
Normal file
@ -0,0 +1,7 @@
|
||||
rdf('JW', name, literal('Jan Wielemaker')).
|
||||
rdf('JW', works_at, literal('SWI')).
|
||||
rdf('http://www.swi.psy.uva.nl/projects/SWI-Prolog/', 'http://description.org/schema/':'Creator', 'JW').
|
||||
rdf('pl-creator', rdf:type, rdf:'Statement').
|
||||
rdf('pl-creator', rdf:subject, 'http://www.swi.psy.uva.nl/projects/SWI-Prolog/').
|
||||
rdf('pl-creator', rdf:predicate, 'http://description.org/schema/':'Creator').
|
||||
rdf('pl-creator', rdf:object, 'JW').
|
128
packages/sgml/RDF/suite/ok/t38.ok
Normal file
128
packages/sgml/RDF/suite/ok/t38.ok
Normal file
@ -0,0 +1,128 @@
|
||||
rdf('Resource', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('Resource', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Resource'))).
|
||||
rdf('Resource', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Ressource'))).
|
||||
rdf('Resource', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('The most general class')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, type))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, type))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Indicates membership of a class')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#range', 'Class').
|
||||
rdf(comment, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(comment, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, comment))).
|
||||
rdf(comment, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, commentaire))).
|
||||
rdf(comment, 'http://www.w3.org/2000/01/rdf-schema#domain', 'Resource').
|
||||
rdf(comment, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Use this for descriptions')).
|
||||
rdf(comment, 'http://www.w3.org/2000/01/rdf-schema#range', 'Literal').
|
||||
rdf(label, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(label, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(label, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, label))).
|
||||
rdf(label, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, label))).
|
||||
rdf(label, 'http://www.w3.org/2000/01/rdf-schema#domain', 'Resource').
|
||||
rdf(label, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Provides a human-readable version of a resource name.')).
|
||||
rdf(label, 'http://www.w3.org/2000/01/rdf-schema#range', 'Literal').
|
||||
rdf('Class', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('Class', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Class'))).
|
||||
rdf('Class', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Classe'))).
|
||||
rdf('Class', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('The concept of Class')).
|
||||
rdf('Class', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Resource').
|
||||
rdf(subClassOf, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(subClassOf, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, subClassOf))).
|
||||
rdf(subClassOf, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, sousClasseDe))).
|
||||
rdf(subClassOf, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Indicates membership of a class')).
|
||||
rdf(subClassOf, 'http://www.w3.org/2000/01/rdf-schema#range', 'Class').
|
||||
rdf(subClassOf, 'http://www.w3.org/2000/01/rdf-schema#domain', 'Class').
|
||||
rdf(subPropertyOf, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(subPropertyOf, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, subPropertyOf))).
|
||||
rdf(subPropertyOf, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, sousPropriétéDe))).
|
||||
rdf(subPropertyOf, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Indicates specialization of properties')).
|
||||
rdf(subPropertyOf, 'http://www.w3.org/2000/01/rdf-schema#range', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(subPropertyOf, 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(seeAlso, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(seeAlso, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, seeAlso))).
|
||||
rdf(seeAlso, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, voirAussi))).
|
||||
rdf(seeAlso, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Indicates a resource that provides information about the subject resource.')).
|
||||
rdf(seeAlso, 'http://www.w3.org/2000/01/rdf-schema#range', 'http://www.w3.org/2000/01/rdf-schema#Resource').
|
||||
rdf(seeAlso, 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/2000/01/rdf-schema#Resource').
|
||||
rdf(isDefinedBy, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(isDefinedBy, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#subPropertyOf', seeAlso).
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, isDefinedBy))).
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, esDéfiniPar))).
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Indicates a resource containing and defining the subject resource.')).
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#range', 'http://www.w3.org/2000/01/rdf-schema#Resource').
|
||||
rdf(isDefinedBy, 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/2000/01/rdf-schema#Resource').
|
||||
rdf('ConstraintResource', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('ConstraintResource', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'ConstraintResource'))).
|
||||
rdf('ConstraintResource', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'RessourceContrainte'))).
|
||||
rdf('ConstraintResource', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'Class').
|
||||
rdf('ConstraintResource', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Resource').
|
||||
rdf('ConstraintResource', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Resources used to express RDF Schema constraints.')).
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'ConstraintProperty'))).
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'PropriétéContrainte'))).
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'ConstraintResource').
|
||||
rdf('ConstraintProperty', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Properties used to express RDF Schema constraints.')).
|
||||
rdf(domain, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#ConstraintProperty').
|
||||
rdf(domain, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, domain))).
|
||||
rdf(domain, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, domaine))).
|
||||
rdf(domain, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('This is how we associate a class with\n properties that its instances can have')).
|
||||
rdf(range, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#ConstraintProperty').
|
||||
rdf(range, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, range))).
|
||||
rdf(range, 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, étendue))).
|
||||
rdf(range, 'http://www.w3.org/2000/01/rdf-schema#comment', literal('Properties that can be used in a\n schema to provide constraints')).
|
||||
rdf(range, 'http://www.w3.org/2000/01/rdf-schema#range', 'Class').
|
||||
rdf(range, 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Property'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Propriété'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('The concept of a property.')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Resource').
|
||||
rdf('Literal', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('Literal', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Literal'))).
|
||||
rdf('Literal', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Littéral'))).
|
||||
rdf('Literal', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'Class').
|
||||
rdf('Literal', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('This represents the set of atomic values, eg. textual strings.')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Statement'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Déclaration'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Resource').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('This represents the set of reified statements.')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#subject', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#subject', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, subject))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#subject', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, sujet))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#subject', 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#subject', 'http://www.w3.org/2000/01/rdf-schema#range', 'Resource').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, predicate))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, prédicat))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate', 'http://www.w3.org/2000/01/rdf-schema#range', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#object', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#object', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, object))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#object', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, objet))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#object', 'http://www.w3.org/2000/01/rdf-schema#domain', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement').
|
||||
rdf('Container', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('Container', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Container'))).
|
||||
rdf('Container', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Enveloppe'))).
|
||||
rdf('Container', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Resource').
|
||||
rdf('Container', 'http://www.w3.org/2000/01/rdf-schema#comment', literal('This represents the set Containers.')).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Bag'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Ensemble'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Container').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Sequence'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Séquence'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Container').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'Alt'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, 'Choix'))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'Container').
|
||||
rdf('ContainerMembershipProperty', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class').
|
||||
rdf('ContainerMembershipProperty', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, 'ContainerMembershipProperty'))).
|
||||
rdf('ContainerMembershipProperty', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#value', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property').
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#value', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(en, object))).
|
||||
rdf('http://www.w3.org/1999/02/22-rdf-syntax-ns#value', 'http://www.w3.org/2000/01/rdf-schema#label', literal(lang(fr, value))).
|
9
packages/sgml/RDF/suite/ok/t39.ok
Normal file
9
packages/sgml/RDF/suite/ok/t39.ok
Normal file
@ -0,0 +1,9 @@
|
||||
rdf('OntologyObjectMetaClass', rdf:type, 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#Class').
|
||||
rdf('OntologyObjectMetaClass', 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#':subClassOf, 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#Class').
|
||||
rdf('OntologyObjectMetaClass', 'http://smi-web.stanford.edu/projects/protege/protege-rdf/protege-19992012#':abstractProperty, literal(concrete)).
|
||||
rdf(identifier, rdf:type, 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#Property').
|
||||
rdf('__Description1', rdf:type, 'http://www.w3.org/rdfutil#facetResource').
|
||||
rdf('__Description1', 'http://www.w3.org/rdfutil#':domain, 'OntologyObjectMetaClass').
|
||||
rdf('__Description1', 'http://www.w3.org/rdfutil#':range, 'http://www.w3.org/TR/xmlschema-2/#string').
|
||||
rdf('__Description1', 'http://www.w3.org/rdfutil#':cardinality, literal('1')).
|
||||
rdf(identifier, 'http://www.w3.org/rdfutil#':facets, '__Description1').
|
6
packages/sgml/RDF/suite/ok/t4.ok
Normal file
6
packages/sgml/RDF/suite/ok/t4.ok
Normal file
@ -0,0 +1,6 @@
|
||||
rdf('http://www.w3.org/Home/Lassila', 'http://description.org/schema/':'Creator', literal('Ora Lassila')).
|
||||
rdf(statement1, rdf:type, rdf:'Statement').
|
||||
rdf(statement1, rdf:subject, 'http://www.w3.org/Home/Lassila').
|
||||
rdf(statement1, rdf:predicate, 'http://description.org/schema/':'Creator').
|
||||
rdf(statement1, rdf:object, literal('Ora Lassila')).
|
||||
rdf(statement1, 'http://description.org/schema/':believedBy, literal('Stefan Decker')).
|
4
packages/sgml/RDF/suite/ok/t40.ok
Normal file
4
packages/sgml/RDF/suite/ok/t40.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('__Description1', rdf:type, 'http://www.mytypes.org/schema/Bicycle').
|
||||
rdf('__Description1', wheels, literal('2')).
|
||||
rdf('__Description2', rdf:type, 'http://www.mytypes.org/schema/Bicycle').
|
||||
rdf('__Description2', 'http://www.mytypes.org/schema/':wheels, literal('2')).
|
3
packages/sgml/RDF/suite/ok/t41.ok
Normal file
3
packages/sgml/RDF/suite/ok/t41.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf('JohnWeight', rdf:value, literal('200')).
|
||||
rdf('JohnWeight', 'http://www.nist.gov/units/':units, 'http://www.nist.gov/units/Pounds').
|
||||
rdf('John_Smith', 'http://www.nist.gov/units/':weight, 'JohnWeight').
|
4
packages/sgml/RDF/suite/ok/t42.ok
Normal file
4
packages/sgml/RDF/suite/ok/t42.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('John_Smith', a1, literal('John')).
|
||||
rdf('__Description1', v, literal('200')).
|
||||
rdf('__Description1', t, literal(pounds)).
|
||||
rdf('John_Smith', a1, '__Description1').
|
7
packages/sgml/RDF/suite/ok/t5.ok
Normal file
7
packages/sgml/RDF/suite/ok/t5.ok
Normal file
@ -0,0 +1,7 @@
|
||||
rdf('__Description1', name, literal('Jan Wielemaker')).
|
||||
rdf('__Description1', works_at, literal('SWI')).
|
||||
rdf('http://www.swi.psy.uva.nl/projects/SWI-Prolog/', 'http://description.org/schema/':'Creator', '__Description1').
|
||||
rdf('JW', rdf:type, rdf:'Statement').
|
||||
rdf('JW', rdf:subject, 'http://www.swi.psy.uva.nl/projects/SWI-Prolog/').
|
||||
rdf('JW', rdf:predicate, 'http://description.org/schema/':'Creator').
|
||||
rdf('JW', rdf:object, '__Description1').
|
4
packages/sgml/RDF/suite/ok/t6.ok
Normal file
4
packages/sgml/RDF/suite/ok/t6.ok
Normal file
@ -0,0 +1,4 @@
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Bag1', rdf:'_1', literal('Jan Wielemaker')).
|
||||
rdf('__Bag1', rdf:'_2', literal('Anjo Anjewierden')).
|
||||
rdf('http://www.swi.psy.uva.nl/projects/xpce/', 'http://description.org/schema/':'Creator', '__Bag1').
|
5
packages/sgml/RDF/suite/ok/t7.ok
Normal file
5
packages/sgml/RDF/suite/ok/t7.ok
Normal file
@ -0,0 +1,5 @@
|
||||
rdf('__Bag1', rdf:type, rdf:'Bag').
|
||||
rdf('__Description1', name, literal('Jan Wielemaker')).
|
||||
rdf('__Description1', employed_at, literal('SWI')).
|
||||
rdf('__Bag1', rdf:'_1', '__Description1').
|
||||
rdf('http://www.swi.psy.uva.nl/projects/xpce/', 'http://description.org/schema/':'Creator', '__Bag1').
|
3
packages/sgml/RDF/suite/ok/t8.ok
Normal file
3
packages/sgml/RDF/suite/ok/t8.ok
Normal file
@ -0,0 +1,3 @@
|
||||
rdf(weight_001, 'http://www.nist.gov/RDFschema/':'Units', 'http://www.nist.gov/units/pounds').
|
||||
rdf(weight_001, value, literal('200')).
|
||||
rdf('John_Smith', 'http://www.nist.gov/RDFschema/':'Weight', weight_001).
|
9
packages/sgml/RDF/suite/ok/t9.ok
Normal file
9
packages/sgml/RDF/suite/ok/t9.ok
Normal file
@ -0,0 +1,9 @@
|
||||
rdf('Statement_001', rdf:type, rdf:'Bag').
|
||||
rdf('http://www.bar.com/some.doc', 'http://purl.org/metadata/dublin_core/':'Creator', literal('John Smith')).
|
||||
rdf('__Statement1', rdf:type, rdf:'Statement').
|
||||
rdf('__Statement1', rdf:subject, 'http://www.bar.com/some.doc').
|
||||
rdf('__Statement1', rdf:predicate, 'http://purl.org/metadata/dublin_core/':'Creator').
|
||||
rdf('__Statement1', rdf:object, literal('John Smith')).
|
||||
rdf('Statement_001', rdf:'_1', '__Statement1').
|
||||
rdf(each('Statement_001'), 'http://www.w3.org/Schemas/DS-Schema/':'CreatedOn', literal('1998-02-06T14:00Z')).
|
||||
rdf(each('Statement_001'), 'http://www.w3.org/Schemas/DS-Schema/':'CreatedBy', literal('Jane Cooper')).
|
6
packages/sgml/RDF/suite/ok/types.ok
Normal file
6
packages/sgml/RDF/suite/ok/types.ok
Normal file
@ -0,0 +1,6 @@
|
||||
rdf('__Description1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2002/07/owl#Restriction').
|
||||
rdf('http://www.w3.org/2002/03owlt/I5.8/inconsistent001#p', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2002/07/owl#DatatypeProperty').
|
||||
rdf('http://www.w3.org/2002/03owlt/I5.8/inconsistent001#p', 'http://www.w3.org/2000/01/rdf-schema#range', 'http://www.w3.org/2001/XMLSchema#byte').
|
||||
rdf('__Description1', 'http://www.w3.org/2002/07/owl#onProperty', 'http://www.w3.org/2002/03owlt/I5.8/inconsistent001#p').
|
||||
rdf('__Description1', 'http://www.w3.org/2002/07/owl#cardinality', literal(type('http://www.w3.org/2001/XMLSchema#nonNegativeInteger', '257'))).
|
||||
rdf('http://www.w3.org/2002/03owlt/I5.8/inconsistent001#john', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', '__Description1').
|
2
packages/sgml/RDF/suite/ok/xmllit.ok
Normal file
2
packages/sgml/RDF/suite/ok/xmllit.ok
Normal file
@ -0,0 +1,2 @@
|
||||
rdf(id1, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.swi.psy.uva.nl/test#test').
|
||||
rdf(id1, 'http://www.swi.psy.uva.nl/test#a', literal(type('http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral', [element(b, [], [strong])]))).
|
2
packages/sgml/RDF/suite/ok/xsdtypes.ok
Normal file
2
packages/sgml/RDF/suite/ok/xsdtypes.ok
Normal file
@ -0,0 +1,2 @@
|
||||
rdf(id1, rdf:type, 'http://www.swi.psy.uva.nl/test#test').
|
||||
rdf(id1, 'http://www.swi.psy.uva.nl/test#':int, literal(type('http://www.w3.org/2000/10/XMLSchema#int', '42'))).
|
10
packages/sgml/RDF/suite/t1.rdf
Normal file
10
packages/sgml/RDF/suite/t1.rdf
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version='1.0'?>
|
||||
|
||||
<!-- Example 1 from REC-rdf-syntax -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator>Ora Lassila</s:Creator>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
12
packages/sgml/RDF/suite/t10.rdf
Normal file
12
packages/sgml/RDF/suite/t10.rdf
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:DC="http://purl.org/metadata/dublin_core/">
|
||||
<Bag ID="pages">
|
||||
<li resource="http://foo.org/foo.html" />
|
||||
<li resource="http://bar.org/bar.html" />
|
||||
</Bag>
|
||||
<Description aboutEach="#pages">
|
||||
<DC:Creator>Ora Lassila</DC:Creator>
|
||||
</Description>
|
||||
</RDF>
|
7
packages/sgml/RDF/suite/t11.rdf
Normal file
7
packages/sgml/RDF/suite/t11.rdf
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0'?>
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.swi.psy.uva.nl/projects/SWI-Prolog/"
|
||||
s:Creator="Jan Wielemaker"/>
|
||||
</rdf:RDF>
|
11
packages/sgml/RDF/suite/t12.rdf
Normal file
11
packages/sgml/RDF/suite/t12.rdf
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating namespaces -->
|
||||
|
||||
<RDF
|
||||
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator>Ora Lassila</s:Creator>
|
||||
</Description>
|
||||
</RDF>
|
9
packages/sgml/RDF/suite/t13.rdf
Normal file
9
packages/sgml/RDF/suite/t13.rdf
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating namespaces -->
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<Description about="http://www.w3.org/Home/Lassila">
|
||||
<Creator xmlns="http://description.org/schema/">Ora Lassila</Creator>
|
||||
</Description>
|
||||
</RDF>
|
12
packages/sgml/RDF/suite/t14.rdf
Normal file
12
packages/sgml/RDF/suite/t14.rdf
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org">
|
||||
<s:Publisher>World Wide Web Consortium</s:Publisher>
|
||||
<s:Title>W3C Home Page</s:Title>
|
||||
<s:Date>1998-10-03T02:27</s:Date>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
11
packages/sgml/RDF/suite/t15.rdf
Normal file
11
packages/sgml/RDF/suite/t15.rdf
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org"
|
||||
s:Publisher="World Wide Web Consortium"
|
||||
s:Title="W3C Home Page"
|
||||
s:Date="1998-10-03T02:27"/>
|
||||
</rdf:RDF>
|
15
packages/sgml/RDF/suite/t16.rdf
Normal file
15
packages/sgml/RDF/suite/t16.rdf
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator rdf:resource="http://www.w3.org/staffId/85740"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description about="http://www.w3.org/staffId/85740">
|
||||
<s:Name>Ora Lassila</s:Name>
|
||||
<s:Email>lassila@w3.org</s:Email>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
15
packages/sgml/RDF/suite/t17.rdf
Normal file
15
packages/sgml/RDF/suite/t17.rdf
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator>
|
||||
<rdf:Description about="http://www.w3.org/staffId/85740">
|
||||
<s:Name>Ora Lassila</s:Name>
|
||||
<s:Email>lassila@w3.org</s:Email>
|
||||
</rdf:Description>
|
||||
</s:Creator>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
12
packages/sgml/RDF/suite/t18.rdf
Normal file
12
packages/sgml/RDF/suite/t18.rdf
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator rdf:resource="http://www.w3.org/staffId/85740"
|
||||
s:Name="Ora Lassila"
|
||||
s:Email="lassila@w3.org"/>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
17
packages/sgml/RDF/suite/t19.rdf
Normal file
17
packages/sgml/RDF/suite/t19.rdf
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/"
|
||||
xmlns:v="http://description.org/view/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator>
|
||||
<rdf:Description about="http://www.w3.org/staffId/85740">
|
||||
<rdf:type resource="http://description.org/schema/Person"/>
|
||||
<v:Name>Ora Lassila</v:Name>
|
||||
<v:Email>lassila@w3.org</v:Email>
|
||||
</rdf:Description>
|
||||
</s:Creator>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
8
packages/sgml/RDF/suite/t2.rdf
Normal file
8
packages/sgml/RDF/suite/t2.rdf
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version='1.0'?>
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="SWI-prolog">
|
||||
<s:Creator rdf:resource="JW" sex="male" employed_at="SWI"/>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
17
packages/sgml/RDF/suite/t20.rdf
Normal file
17
packages/sgml/RDF/suite/t20.rdf
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/"
|
||||
xmlns:v="http://description.org/view/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila">
|
||||
<s:Creator>
|
||||
<!-- REC-rdf-syntax just says `about' -->
|
||||
<s:Person rdf:about="http://www.w3.org/staffId/85740">
|
||||
<v:Name>Ora Lassila</v:Name>
|
||||
<v:Email>lassila@w3.org</v:Email>
|
||||
</s:Person>
|
||||
</s:Creator>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
19
packages/sgml/RDF/suite/t21.rdf
Normal file
19
packages/sgml/RDF/suite/t21.rdf
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/"
|
||||
xmlns:v="http://description.org/view/">
|
||||
<rdf:Description about="http://mycollege.edu/courses/6.001">
|
||||
<s:students>
|
||||
<rdf:Bag>
|
||||
<rdf:li resource="http://mycollege.edu/students/Amy"/>
|
||||
<rdf:li resource="http://mycollege.edu/students/Tim"/>
|
||||
<rdf:li resource="http://mycollege.edu/students/John"/>
|
||||
<rdf:li resource="http://mycollege.edu/students/Mary"/>
|
||||
<rdf:li resource="http://mycollege.edu/students/Sue"/>
|
||||
</rdf:Bag>
|
||||
</s:students>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
17
packages/sgml/RDF/suite/t22.rdf
Normal file
17
packages/sgml/RDF/suite/t22.rdf
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/"
|
||||
xmlns:v="http://description.org/view/">
|
||||
<rdf:Description about="http://x.org/packages/X11">
|
||||
<s:DistributionSite>
|
||||
<rdf:Alt>
|
||||
<rdf:li resource="ftp://ftp.x.org"/>
|
||||
<rdf:li resource="ftp://ftp.cs.purdue.edu"/>
|
||||
<rdf:li resource="ftp://ftp.eu.net"/>
|
||||
</rdf:Alt>
|
||||
</s:DistributionSite>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
11
packages/sgml/RDF/suite/t23.rdf
Normal file
11
packages/sgml/RDF/suite/t23.rdf
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/"
|
||||
xmlns:v="http://description.org/view/">
|
||||
<rdf:Description aboutEachPrefix="http://foo.org/doc">
|
||||
<s:Copyright>© 1998, The Foo Organization</s:Copyright>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
15
packages/sgml/RDF/suite/t24.rdf
Normal file
15
packages/sgml/RDF/suite/t24.rdf
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:a="http://description.org/schema/">
|
||||
<rdf:Description>
|
||||
<rdf:subject resource="http://www.w3.org/Home/Lassila" />
|
||||
<rdf:predicate resource="http://description.org/schema/Creator" />
|
||||
<rdf:object>Ora Lassila</rdf:object>
|
||||
<rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement" />
|
||||
<a:attributedTo>Ralph Swick</a:attributedTo>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
12
packages/sgml/RDF/suite/t25.rdf
Normal file
12
packages/sgml/RDF/suite/t25.rdf
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, demonstrating abbrevation -->
|
||||
|
||||
<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:s="http://description.org/schema/">
|
||||
<rdf:Description about="http://www.w3.org/Home/Lassila" bagID="D_001">
|
||||
<s:Creator>Ora Lassila</s:Creator>
|
||||
<s:Title>Ora's Home Page</s:Title>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user