kibi-swipl-linux-x64-gnu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,1510 @@
|
|
|
1
|
+
/* Part of SWI-Prolog
|
|
2
|
+
|
|
3
|
+
Author: Jan Wielemaker
|
|
4
|
+
E-mail: J.Wielemaker@vu.nl
|
|
5
|
+
WWW: http://www.swi-prolog.org
|
|
6
|
+
Copyright (c) 2014-2015, VU University Amsterdam
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
|
10
|
+
modification, are permitted provided that the following conditions
|
|
11
|
+
are met:
|
|
12
|
+
|
|
13
|
+
1. Redistributions of source code must retain the above copyright
|
|
14
|
+
notice, this list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
notice, this list of conditions and the following disclaimer in
|
|
18
|
+
the documentation and/or other materials provided with the
|
|
19
|
+
distribution.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
24
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
25
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
26
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
27
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
28
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
30
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
31
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
:- module(rdfa,
|
|
36
|
+
[ read_rdfa/3, % +Input, -RDF, +Options
|
|
37
|
+
xml_rdfa/3 % +XMLDom, -RDF, +Options
|
|
38
|
+
]).
|
|
39
|
+
:- use_module(library(semweb/rdf_db),
|
|
40
|
+
[ rdf_register_prefix/2,
|
|
41
|
+
rdf_meta/1,
|
|
42
|
+
rdf_global_id/2,
|
|
43
|
+
rdf_equal/2,
|
|
44
|
+
rdf_is_bnode/1,
|
|
45
|
+
rdf_global_term/2,
|
|
46
|
+
rdf_transaction/2,
|
|
47
|
+
rdf_assert/4,
|
|
48
|
+
rdf_set_graph/2,
|
|
49
|
+
op(_,_,_)
|
|
50
|
+
]).
|
|
51
|
+
:- use_module(library(xpath),[xpath/3, op(_,_,_)]).
|
|
52
|
+
|
|
53
|
+
:- autoload(library(apply),[maplist/3,maplist/2,exclude/3,include/3]).
|
|
54
|
+
:- use_module(library(debug),[debugging/1,debug/3]).
|
|
55
|
+
:- autoload(library(error),[instantiation_error/1,type_error/2]).
|
|
56
|
+
:- if(exists_source(library(guitracer))).
|
|
57
|
+
:- autoload(library(gui_tracer),[gtrace/0]).
|
|
58
|
+
:- endif.
|
|
59
|
+
:- autoload(library(lists),[append/2,reverse/2,member/2,append/3]).
|
|
60
|
+
:- autoload(library(option),[merge_options/3,option/2,option/3]).
|
|
61
|
+
:- autoload(library(prolog_stack),[backtrace/1]).
|
|
62
|
+
:- autoload(library(sgml),
|
|
63
|
+
[ load_xml/3, load_html/3, xml_basechar/1, xml_ideographic/1,
|
|
64
|
+
xml_digit/1, xml_combining_char/1, xml_extender/1
|
|
65
|
+
]).
|
|
66
|
+
:- autoload(library(sgml_write),[xml_write/2]).
|
|
67
|
+
:- autoload(library(uri),
|
|
68
|
+
[ uri_file_name/2, uri_components/2, uri_data/3, uri_data/4,
|
|
69
|
+
iri_normalized/3, iri_normalized/2, uri_normalized/3
|
|
70
|
+
]).
|
|
71
|
+
:- autoload(library(dcg/basics),[blanks/2,blank/2,alpha_to_lower/3]).
|
|
72
|
+
:- autoload(library(http/http_open),[http_open/3]).
|
|
73
|
+
|
|
74
|
+
/** <module> Extract RDF from an HTML or XML DOM
|
|
75
|
+
|
|
76
|
+
This module implements extraction of RDFa triples from parsed XML or
|
|
77
|
+
HTML documents. It has two interfaces: read_rdfa/3 to read triples from
|
|
78
|
+
some input (stream, file, URL) and xml_rdfa/3 to extract triples from an
|
|
79
|
+
HTML or XML document that is already parsed with load_html/3 or
|
|
80
|
+
load_xml/3.
|
|
81
|
+
|
|
82
|
+
@see http://www.w3.org/TR/2013/REC-rdfa-core-20130822/
|
|
83
|
+
@see http://www.w3.org/TR/html-rdfa/
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
:- rdf_register_prefix(rdfa, 'http://www.w3.org/ns/rdfa#').
|
|
87
|
+
|
|
88
|
+
:- rdf_meta
|
|
89
|
+
add_triple(+, r, r, o),
|
|
90
|
+
add_incomplete_triple(+, t).
|
|
91
|
+
|
|
92
|
+
:- discontiguous
|
|
93
|
+
term_expansion/2.
|
|
94
|
+
|
|
95
|
+
:- predicate_options(xml_rdfa/3, 3,
|
|
96
|
+
[ base(atom),
|
|
97
|
+
anon_prefix(any),
|
|
98
|
+
lang(atom),
|
|
99
|
+
vocab(atom),
|
|
100
|
+
markup(atom)
|
|
101
|
+
]).
|
|
102
|
+
:- predicate_options(read_dom/3, 3,
|
|
103
|
+
[ pass_to(sgml:load_html/3, 3),
|
|
104
|
+
pass_to(sgml:load_xml/3, 3)
|
|
105
|
+
]).
|
|
106
|
+
:- predicate_options(read_rdfa/3, 3,
|
|
107
|
+
[ pass_to(read_dom/3, 3),
|
|
108
|
+
pass_to(xml_rdfa/3, 3),
|
|
109
|
+
pass_to(system:open/4, 4),
|
|
110
|
+
pass_to(http_open:http_open/3, 3)
|
|
111
|
+
]).
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/*******************************
|
|
115
|
+
* STREAM READING *
|
|
116
|
+
*******************************/
|
|
117
|
+
|
|
118
|
+
%! read_rdfa(+Input, -Triples, +Options) is det.
|
|
119
|
+
%
|
|
120
|
+
% True when Triples is a list of rdf(S,P,O) triples extracted from
|
|
121
|
+
% Input. Input is either a stream, a file name, a URL referencing
|
|
122
|
+
% a file name or a URL that is valid for http_open/3. Options are
|
|
123
|
+
% passed to open/4, http_open/3 and xml_rdfa/3. If no base is
|
|
124
|
+
% provided in Options, a base is deduced from Input.
|
|
125
|
+
|
|
126
|
+
read_rdfa(Input, Triples, Options) :-
|
|
127
|
+
setup_call_cleanup(
|
|
128
|
+
open_input(Input, In, NewOptions, Close, Options),
|
|
129
|
+
read_dom(In, DOM, Options),
|
|
130
|
+
close_input(Close)),
|
|
131
|
+
merge_options(Options, NewOptions, RDFaOptions),
|
|
132
|
+
xml_rdfa(DOM, Triples, RDFaOptions).
|
|
133
|
+
|
|
134
|
+
open_input(Input, In, NewOptions, Close, Options) :-
|
|
135
|
+
open_input2(Input, In, NewOptions, Close0, Options),
|
|
136
|
+
detect_bom(In, Close0, Close).
|
|
137
|
+
|
|
138
|
+
open_input2(stream(In), In, Options, true, _) :-
|
|
139
|
+
!,
|
|
140
|
+
( stream_property(In, file_name(Name)),
|
|
141
|
+
to_uri(Name, URI)
|
|
142
|
+
-> Options = [base(URI)]
|
|
143
|
+
; Options = []
|
|
144
|
+
).
|
|
145
|
+
open_input2(In, In, Options, true, _) :-
|
|
146
|
+
is_stream(In),
|
|
147
|
+
!,
|
|
148
|
+
( stream_property(In, file_name(Name)),
|
|
149
|
+
to_uri(Name, URI)
|
|
150
|
+
-> Options = [base(URI)]
|
|
151
|
+
; Options = []
|
|
152
|
+
).
|
|
153
|
+
open_input2(URL, In, [base(URL)], close(In), Options) :-
|
|
154
|
+
atom(URL),
|
|
155
|
+
uri_file_name(URL, File),
|
|
156
|
+
!,
|
|
157
|
+
open(File, read, In, Options).
|
|
158
|
+
open_input2(URL, In, [base(Base)], close(In), Options) :-
|
|
159
|
+
atom(URL),
|
|
160
|
+
to_uri2(URL, Base),
|
|
161
|
+
!,
|
|
162
|
+
http_open(URL, In, Options).
|
|
163
|
+
open_input2(File, In, [base(URI)], close(In), Options) :-
|
|
164
|
+
absolute_file_name(File, Path, [access(read)]),
|
|
165
|
+
uri_file_name(URI, Path),
|
|
166
|
+
open(Path, read, In, Options).
|
|
167
|
+
|
|
168
|
+
%! detect_bom(+In, +Close0, -Close) is det.
|
|
169
|
+
%
|
|
170
|
+
% We may be loading a binary stream. In that case we want to do
|
|
171
|
+
% BOM detection.
|
|
172
|
+
|
|
173
|
+
detect_bom(In, Close0, Close) :-
|
|
174
|
+
stream_property(In, type(binary)),
|
|
175
|
+
stream_property(In, encoding(Enc)),
|
|
176
|
+
catch(set_stream(In, encoding(bom)),_,fail),
|
|
177
|
+
!,
|
|
178
|
+
merge_close(Close0, set_stream(In, encoding(Enc)), Close).
|
|
179
|
+
detect_bom(_, Close, Close).
|
|
180
|
+
|
|
181
|
+
merge_close(true, Close, Close) :- !.
|
|
182
|
+
merge_close(Close, _, Close).
|
|
183
|
+
|
|
184
|
+
to_uri(URI0, URI) :-
|
|
185
|
+
to_uri2(URI0, URI),
|
|
186
|
+
!.
|
|
187
|
+
to_uri(URI0, URI) :-
|
|
188
|
+
absolute_file_name(URI0, Path),
|
|
189
|
+
uri_file_name(URI, Path).
|
|
190
|
+
|
|
191
|
+
to_uri2(URI0, Base) :-
|
|
192
|
+
uri_components(URI0, Components),
|
|
193
|
+
uri_data(scheme, Components, Scheme),
|
|
194
|
+
ground(Scheme),
|
|
195
|
+
http_scheme(Scheme),
|
|
196
|
+
!,
|
|
197
|
+
uri_data(fragment, Components, _, Components2),
|
|
198
|
+
uri_components(Base, Components2).
|
|
199
|
+
|
|
200
|
+
http_scheme(http).
|
|
201
|
+
http_scheme(https).
|
|
202
|
+
|
|
203
|
+
close_input(true).
|
|
204
|
+
close_input(close(X)) :- close(X).
|
|
205
|
+
close_input(set_stream(In, encoding(Enc))) :- set_stream(In, encoding(Enc)).
|
|
206
|
+
|
|
207
|
+
read_dom(In, DOM, Options) :-
|
|
208
|
+
option(dialect(Dialect), Options),
|
|
209
|
+
!,
|
|
210
|
+
( xml_dialect(Dialect)
|
|
211
|
+
-> load_xml(stream(In), DOM, Options)
|
|
212
|
+
; load_html(stream(In), DOM, Options)
|
|
213
|
+
).
|
|
214
|
+
read_dom(In, DOM, Options) :-
|
|
215
|
+
peek_string(In, 1000, Start),
|
|
216
|
+
guess_dialect(Start, Dialect),
|
|
217
|
+
read_dom(In, DOM, [dialect(Dialect)|Options]).
|
|
218
|
+
|
|
219
|
+
xml_dialect(xml).
|
|
220
|
+
xml_dialect(xmlns).
|
|
221
|
+
xml_dialect(svg).
|
|
222
|
+
xml_dialect(xhtml).
|
|
223
|
+
xml_dialect(xhtml5).
|
|
224
|
+
|
|
225
|
+
guess_dialect(Start, Dialect) :-
|
|
226
|
+
sub_string(Start, _, _, _, "<?xml"),
|
|
227
|
+
!,
|
|
228
|
+
Dialect = xml.
|
|
229
|
+
guess_dialect(Start, Dialect) :-
|
|
230
|
+
sub_string(Start, _, _, _, "<html"),
|
|
231
|
+
!,
|
|
232
|
+
( sub_string(Start, _, _, _, "xmlns:")
|
|
233
|
+
-> Dialect = xhtml
|
|
234
|
+
; string_codes(Start, Codes),
|
|
235
|
+
phrase(html_doctype(DialectFound), Codes, _)
|
|
236
|
+
-> Dialect = DialectFound
|
|
237
|
+
; Dialect = html
|
|
238
|
+
).
|
|
239
|
+
guess_dialect(Start, Dialect) :-
|
|
240
|
+
sub_string(Start, _, _, _, "<svg"),
|
|
241
|
+
!,
|
|
242
|
+
Dialect = svg.
|
|
243
|
+
guess_dialect(_, xml).
|
|
244
|
+
|
|
245
|
+
html_doctype(html5) -->
|
|
246
|
+
blanks,
|
|
247
|
+
"<!DOCTYPE", blank, blanks, "html", blanks, ">",
|
|
248
|
+
!.
|
|
249
|
+
html_doctype(html4) -->
|
|
250
|
+
blanks,
|
|
251
|
+
"<!", icase_string(`doctype`), blank, blanks, icase_string(`html`),
|
|
252
|
+
blank, blanks,
|
|
253
|
+
icase_string(`public`),
|
|
254
|
+
blank,
|
|
255
|
+
!.
|
|
256
|
+
|
|
257
|
+
icase_string([]) --> [].
|
|
258
|
+
icase_string([H|T]) --> alpha_to_lower(H), icase_string(T).
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
/*******************************
|
|
262
|
+
* DOM PROCESSING *
|
|
263
|
+
*******************************/
|
|
264
|
+
|
|
265
|
+
%! xml_rdfa(+DOM, -RDF, +Options)
|
|
266
|
+
%
|
|
267
|
+
% True when RDF is a list of rdf(S,P,O) terms extracted from DOM
|
|
268
|
+
% according to the RDFa specification. Options processed:
|
|
269
|
+
%
|
|
270
|
+
% * base(+BaseURI)
|
|
271
|
+
% URI to use for ''. Normally set to the document URI.
|
|
272
|
+
% * anon_prefix(+AnnonPrefix)
|
|
273
|
+
% Prefix for blank nodes.
|
|
274
|
+
% * lang(+Lang)
|
|
275
|
+
% Default for =lang=
|
|
276
|
+
% * vocab(+Vocab)
|
|
277
|
+
% Default for =vocab=
|
|
278
|
+
% * markup(+Markup)
|
|
279
|
+
% Markup language processed (xhtml, xml, ...)
|
|
280
|
+
|
|
281
|
+
xml_rdfa(DOM, _, _) :-
|
|
282
|
+
var(DOM),
|
|
283
|
+
!,
|
|
284
|
+
instantiation_error(DOM).
|
|
285
|
+
xml_rdfa(DOM, RDF, Options) :-
|
|
286
|
+
is_list(DOM),
|
|
287
|
+
!,
|
|
288
|
+
maplist(xml_rdfa_aux(Options), DOM, RDFList),
|
|
289
|
+
append(RDFList, RDF).
|
|
290
|
+
xml_rdfa(DOM, RDF, Options) :-
|
|
291
|
+
DOM = element(_,_,_),
|
|
292
|
+
!,
|
|
293
|
+
rdfa_evaluation_context(DOM, EvalContext, Options),
|
|
294
|
+
process_node(DOM, EvalContext),
|
|
295
|
+
arg(1, EvalContext.triples, List),
|
|
296
|
+
reverse(List, RDF0),
|
|
297
|
+
apply_patterns(RDF0, RDF).
|
|
298
|
+
% XML Processing Instruction (PI).
|
|
299
|
+
xml_rdfa(DOM, [], _) :-
|
|
300
|
+
DOM = pi(_),
|
|
301
|
+
!.
|
|
302
|
+
xml_rdfa(DOM, _, _) :-
|
|
303
|
+
type_error(xml_dom, DOM).
|
|
304
|
+
|
|
305
|
+
xml_rdfa_aux(Options, DOM, RDF) :-
|
|
306
|
+
xml_rdfa(DOM, RDF, Options).
|
|
307
|
+
|
|
308
|
+
process_node(DOM, EvalContext) :-
|
|
309
|
+
rdfa_local_context(EvalContext, LocalContext), % 7.5.1
|
|
310
|
+
update_vocab(DOM, LocalContext), % 7.5.2
|
|
311
|
+
update_prefixes(DOM, LocalContext), % 7.5.3
|
|
312
|
+
update_lang(DOM, LocalContext), % 7.5.4
|
|
313
|
+
update_subject(DOM, LocalContext), % 7.5.5, 7.5.6
|
|
314
|
+
emit_typeof(DOM, LocalContext), % 7.5.7
|
|
315
|
+
update_list_mapping(DOM, LocalContext), % 7.5.8
|
|
316
|
+
step_7_5_9(DOM, LocalContext), % 7.5.9
|
|
317
|
+
step_7_5_10(DOM, LocalContext), % 7.5.10
|
|
318
|
+
update_property_value(DOM, LocalContext), % 7.5.11
|
|
319
|
+
complete_triples(LocalContext), % 7.5.12
|
|
320
|
+
descent(DOM, LocalContext), % 7.5.13
|
|
321
|
+
complete_lists(LocalContext),
|
|
322
|
+
!. % 7.5.14
|
|
323
|
+
:- if(current_predicate(gtrace/0)).
|
|
324
|
+
process_node(DOM, EvalContext) :-
|
|
325
|
+
print_message(warning, rdfa(failed(DOM, EvalContext))),
|
|
326
|
+
( debugging(rdfa(test))
|
|
327
|
+
-> gtrace,
|
|
328
|
+
process_node(DOM, EvalContext)
|
|
329
|
+
; true
|
|
330
|
+
).
|
|
331
|
+
:- endif.
|
|
332
|
+
|
|
333
|
+
%! rdfa_evaluation_context(+DOM, -Context, +Options)
|
|
334
|
+
%
|
|
335
|
+
% 7.5.0: Create the initial evaluation context
|
|
336
|
+
%
|
|
337
|
+
% @tbd: derive markup from DOM
|
|
338
|
+
|
|
339
|
+
rdfa_evaluation_context(DOM, Context, Options) :-
|
|
340
|
+
Context = rdfa_eval{base:Base, % atom
|
|
341
|
+
parent_subject:Base, % atom
|
|
342
|
+
parent_object:null, % null or atom
|
|
343
|
+
incomplete_triples:[], % list
|
|
344
|
+
list_mapping:ListMapping, % IRI --> list(List)
|
|
345
|
+
lang:Lang, % null or atom
|
|
346
|
+
iri_mapping:IRIMappings, % dict
|
|
347
|
+
term_mapping:TermMappings, % dict
|
|
348
|
+
vocab:Vocab, % null or atom
|
|
349
|
+
bnode_id:bnode(1), % integer
|
|
350
|
+
markup:Markup, % Processing profile
|
|
351
|
+
anon_prefix:AnonPrefix,
|
|
352
|
+
named_bnodes:r{v:_{}},
|
|
353
|
+
root:DOM, % XML DOM
|
|
354
|
+
triples:triples([])}, % list
|
|
355
|
+
empty_list_mapping(ListMapping),
|
|
356
|
+
option(markup(Markup), Options, xhtml),
|
|
357
|
+
base(DOM, Options, Base),
|
|
358
|
+
default_vocab(Markup, DefaultVocab),
|
|
359
|
+
option(lang(Lang), Options, ''),
|
|
360
|
+
option(vocab(Vocab), Options, DefaultVocab),
|
|
361
|
+
( option(anon_prefix(AnonPrefix), Options)
|
|
362
|
+
-> true
|
|
363
|
+
; atom_concat('__', Base, AnonPrefix)
|
|
364
|
+
),
|
|
365
|
+
default_prefixes(Markup, DefPrefixes),
|
|
366
|
+
mapping(prefixes(IRIMappings0), Options),
|
|
367
|
+
put_dict(DefPrefixes, IRIMappings0, IRIMappings),
|
|
368
|
+
mapping(terms(TermMappings), Options).
|
|
369
|
+
|
|
370
|
+
base(DOM, _Options, Base) :-
|
|
371
|
+
xpath(DOM, //base(@href=Base), _),
|
|
372
|
+
!.
|
|
373
|
+
base(_DOM, Options, Base) :-
|
|
374
|
+
option(base(Base0), Options),
|
|
375
|
+
rdf_global_id(Base0, Base),
|
|
376
|
+
!.
|
|
377
|
+
base(_, _, 'http://www.example.org/').
|
|
378
|
+
|
|
379
|
+
mapping(Term, Options) :-
|
|
380
|
+
Term =.. [Name, Value],
|
|
381
|
+
( TermG =.. [Name, Var],
|
|
382
|
+
option(TermG, Options)
|
|
383
|
+
-> dict_create(Value, Name, Var)
|
|
384
|
+
; dict_create(Value, Name, [])
|
|
385
|
+
).
|
|
386
|
+
|
|
387
|
+
%! default_prefixes(+Markup, -Dict)
|
|
388
|
+
%
|
|
389
|
+
% Create a default prefix map. Which prefixes are supposed to be
|
|
390
|
+
% in this map?
|
|
391
|
+
|
|
392
|
+
default_prefixes(Markup, _{'':DefPrefix}) :-
|
|
393
|
+
default_prefix_mapping(Markup, DefPrefix).
|
|
394
|
+
|
|
395
|
+
%! rdfa_core_prefix(?Prefix, ?URI) is nondet.
|
|
396
|
+
%
|
|
397
|
+
% RDFa initial context prefix declarations.
|
|
398
|
+
%
|
|
399
|
+
% @see http://www.w3.org/2011/rdfa-context/rdfa-1.1
|
|
400
|
+
|
|
401
|
+
rdfa_core_prefix(dcat, 'http://www.w3.org/ns/dcat#').
|
|
402
|
+
rdfa_core_prefix(qb, 'http://purl.org/linked-data/cube#').
|
|
403
|
+
rdfa_core_prefix(grddl, 'http://www.w3.org/2003/g/data-view#').
|
|
404
|
+
rdfa_core_prefix(ma, 'http://www.w3.org/ns/ma-ont#').
|
|
405
|
+
rdfa_core_prefix(org, 'http://www.w3.org/ns/org#').
|
|
406
|
+
rdfa_core_prefix(owl, 'http://www.w3.org/2002/07/owl#').
|
|
407
|
+
rdfa_core_prefix(prov, 'http://www.w3.org/ns/prov#').
|
|
408
|
+
rdfa_core_prefix(rdf, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#').
|
|
409
|
+
rdfa_core_prefix(rdfa, 'http://www.w3.org/ns/rdfa#').
|
|
410
|
+
rdfa_core_prefix(rdfs, 'http://www.w3.org/2000/01/rdf-schema#').
|
|
411
|
+
rdfa_core_prefix(rif, 'http://www.w3.org/2007/rif#').
|
|
412
|
+
rdfa_core_prefix(rr, 'http://www.w3.org/ns/r2rml#').
|
|
413
|
+
rdfa_core_prefix(sd, 'http://www.w3.org/ns/sparql-service-description#').
|
|
414
|
+
rdfa_core_prefix(skos, 'http://www.w3.org/2004/02/skos/core#').
|
|
415
|
+
rdfa_core_prefix(skosxl, 'http://www.w3.org/2008/05/skos-xl#').
|
|
416
|
+
rdfa_core_prefix(wdr, 'http://www.w3.org/2007/05/powder#').
|
|
417
|
+
rdfa_core_prefix(void, 'http://rdfs.org/ns/void#').
|
|
418
|
+
rdfa_core_prefix(wdrs, 'http://www.w3.org/2007/05/powder-s#').
|
|
419
|
+
rdfa_core_prefix(xhv, 'http://www.w3.org/1999/xhtml/vocab#').
|
|
420
|
+
rdfa_core_prefix(xml, 'http://www.w3.org/XML/1998/namespace').
|
|
421
|
+
rdfa_core_prefix(xsd, 'http://www.w3.org/2001/XMLSchema#').
|
|
422
|
+
rdfa_core_prefix(cc, 'http://creativecommons.org/ns#').
|
|
423
|
+
rdfa_core_prefix(ctag, 'http://commontag.org/ns#').
|
|
424
|
+
rdfa_core_prefix(dc, 'http://purl.org/dc/terms/').
|
|
425
|
+
rdfa_core_prefix(dcterms, 'http://purl.org/dc/terms/').
|
|
426
|
+
rdfa_core_prefix(dc11, 'http://purl.org/dc/elements/1.1/').
|
|
427
|
+
rdfa_core_prefix(foaf, 'http://xmlns.com/foaf/0.1/').
|
|
428
|
+
rdfa_core_prefix(gr, 'http://purl.org/goodrelations/v1#').
|
|
429
|
+
rdfa_core_prefix(ical, 'http://www.w3.org/2002/12/cal/icaltzd#').
|
|
430
|
+
rdfa_core_prefix(og, 'http://ogp.me/ns#').
|
|
431
|
+
rdfa_core_prefix(rev, 'http://purl.org/stuff/rev#').
|
|
432
|
+
rdfa_core_prefix(sioc, 'http://rdfs.org/sioc/ns#').
|
|
433
|
+
rdfa_core_prefix(v, 'http://rdf.data-vocabulary.org/#').
|
|
434
|
+
rdfa_core_prefix(vcard, 'http://www.w3.org/2006/vcard/ns#').
|
|
435
|
+
rdfa_core_prefix(schema, 'http://schema.org/').
|
|
436
|
+
|
|
437
|
+
default_prefix_mapping(xhtml, 'http://www.w3.org/1999/xhtml/vocab#') :- !.
|
|
438
|
+
default_prefix_mapping(_, 'http://www.example.org/').
|
|
439
|
+
|
|
440
|
+
default_vocab(_, '').
|
|
441
|
+
|
|
442
|
+
%! rdfa_local_context(EvalContext, LocalContext)
|
|
443
|
+
%
|
|
444
|
+
% 7.5.1: Create the local context
|
|
445
|
+
|
|
446
|
+
rdfa_local_context(EvalContext, LocalContext) :-
|
|
447
|
+
LocalContext = rdfa_local{skip_element:false,
|
|
448
|
+
new_subject:null,
|
|
449
|
+
current_object_resource:null,
|
|
450
|
+
typed_resource:null,
|
|
451
|
+
iri_mapping:IRIMappings,
|
|
452
|
+
incomplete_triples:[],
|
|
453
|
+
list_mapping:ListMapping,
|
|
454
|
+
lang:Lang,
|
|
455
|
+
term_mapping:TermMapping,
|
|
456
|
+
vocab:Vocab,
|
|
457
|
+
eval_context:EvalContext
|
|
458
|
+
},
|
|
459
|
+
_{ iri_mapping:IRIMappings,
|
|
460
|
+
list_mapping:ListMapping,
|
|
461
|
+
lang:Lang,
|
|
462
|
+
term_mapping:TermMapping,
|
|
463
|
+
vocab:Vocab
|
|
464
|
+
} :< EvalContext.
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
%! update_vocab(+DOM, +Context) is det.
|
|
468
|
+
%
|
|
469
|
+
% 7.5.2. Handle @vocab
|
|
470
|
+
|
|
471
|
+
update_vocab(DOM, Context) :-
|
|
472
|
+
xpath(DOM, /(*(@vocab=Vocab0)), _),
|
|
473
|
+
!,
|
|
474
|
+
( Vocab0 == ''
|
|
475
|
+
-> Vocab = '' % Host Language defined default?
|
|
476
|
+
; iri(Vocab0, Vocab, Context)
|
|
477
|
+
),
|
|
478
|
+
nb_set_dict(vocab, Context, Vocab),
|
|
479
|
+
add_triple(Context,
|
|
480
|
+
Context.eval_context.base,
|
|
481
|
+
rdfa:usesVocabulary,
|
|
482
|
+
Vocab).
|
|
483
|
+
update_vocab(_, _).
|
|
484
|
+
|
|
485
|
+
%! update_prefixes(+DOM, +Context) is det.
|
|
486
|
+
%
|
|
487
|
+
% 7.5.3: Update prefix map using @prefix and @xmlns. First
|
|
488
|
+
% processes xmlns:Prefix=IRI.
|
|
489
|
+
|
|
490
|
+
update_prefixes(DOM, Context) :-
|
|
491
|
+
DOM=element(_,Attrs,_),
|
|
492
|
+
xmlns_dict(Attrs, _{}, Dict0),
|
|
493
|
+
( xpath(DOM, /(*(@prefix=PrefixDecl)), _)
|
|
494
|
+
-> prefix_dict(PrefixDecl, Dict0, Dict)
|
|
495
|
+
; Dict = Dict0
|
|
496
|
+
),
|
|
497
|
+
Dict \= _{},
|
|
498
|
+
!,
|
|
499
|
+
put_dict(Dict, Context.iri_mapping, NewMapping),
|
|
500
|
+
b_set_dict(iri_mapping, Context, NewMapping).
|
|
501
|
+
update_prefixes(_, _).
|
|
502
|
+
|
|
503
|
+
xmlns_dict([], Dict, Dict).
|
|
504
|
+
xmlns_dict([Attr=IRI|T0], Dict0, Dict) :-
|
|
505
|
+
( Attr = xmlns:Name
|
|
506
|
+
; atom_concat('xmlns:', Name, Attr)
|
|
507
|
+
),
|
|
508
|
+
!,
|
|
509
|
+
downcase_atom(Name, Prefix),
|
|
510
|
+
put_dict(Prefix, Dict0, IRI, Dict1),
|
|
511
|
+
xmlns_dict(T0, Dict1, Dict).
|
|
512
|
+
xmlns_dict([_|T0], Dict0, Dict) :-
|
|
513
|
+
xmlns_dict(T0, Dict0, Dict).
|
|
514
|
+
|
|
515
|
+
prefix_dict(Text, Dict0, Dict) :-
|
|
516
|
+
atom_codes(Text, Codes),
|
|
517
|
+
phrase(prefixes(Dict0, Dict), Codes).
|
|
518
|
+
|
|
519
|
+
%! update_lang(+DOM, +Context) is det.
|
|
520
|
+
%
|
|
521
|
+
% 7.5.4: Update lang
|
|
522
|
+
|
|
523
|
+
update_lang(DOM, Context) :-
|
|
524
|
+
DOM=element(_,Attrs,_),
|
|
525
|
+
( ( memberchk(xml:lang=Lang, Attrs) % XML with namespaces
|
|
526
|
+
; memberchk('xml:lang'=Lang, Attrs) % XML without namespaces
|
|
527
|
+
; memberchk(lang=Lang, Attrs) % HTML 5
|
|
528
|
+
)
|
|
529
|
+
-> nb_set_dict(lang, Context, Lang)
|
|
530
|
+
; true
|
|
531
|
+
),
|
|
532
|
+
( ( memberchk(xml:base=Base, Attrs) % XML with namespaces
|
|
533
|
+
; memberchk('xml:base'=Base, Attrs) % XML without namespaces
|
|
534
|
+
)
|
|
535
|
+
-> nb_set_dict(base, Context.eval_context, Base)
|
|
536
|
+
; true
|
|
537
|
+
).
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
%! update_subject(+DOM, +Context) is det.
|
|
541
|
+
%
|
|
542
|
+
% 7.5.5 and 7.5.6: establish a value for new subject
|
|
543
|
+
|
|
544
|
+
update_subject(DOM, Context) :-
|
|
545
|
+
DOM=element(E,Attrs,_),
|
|
546
|
+
\+ has_attribute(rel, Attrs, Context),
|
|
547
|
+
\+ has_attribute(rev, Attrs, Context), % Commit to rule-set 7.5.5
|
|
548
|
+
!,
|
|
549
|
+
( memberchk(property=_, Attrs),
|
|
550
|
+
\+ memberchk(content=_, Attrs),
|
|
551
|
+
\+ memberchk(datatype=_, Attrs)
|
|
552
|
+
-> ( ( about(DOM, About, Context) % 7.5.5.1
|
|
553
|
+
; About = Context.eval_context.parent_object
|
|
554
|
+
),
|
|
555
|
+
About \== null
|
|
556
|
+
-> nb_set_dict(new_subject, Context, About)
|
|
557
|
+
; true
|
|
558
|
+
),
|
|
559
|
+
( memberchk(typeof=_, Attrs)
|
|
560
|
+
-> ( ( iri_attr(about, Attrs, TypedIRI, Context),
|
|
561
|
+
TypedIRI \== null
|
|
562
|
+
; DOM == Context.eval_context.root
|
|
563
|
+
-> iri('', TypedIRI, Context)
|
|
564
|
+
; ( iri_attr(resource, Attrs, TypedIRI, Context)
|
|
565
|
+
; iri_attr(href, Attrs, TypedIRI, Context)
|
|
566
|
+
; iri_attr(src, Attrs, TypedIRI, Context)
|
|
567
|
+
; new_bnode(TypedIRI, Context)
|
|
568
|
+
),
|
|
569
|
+
TypedIRI \== null
|
|
570
|
+
-> nb_set_dict(typed_resource, Context, TypedIRI),
|
|
571
|
+
nb_set_dict(current_object_resource, Context, TypedIRI)
|
|
572
|
+
)
|
|
573
|
+
-> nb_set_dict(typed_resource, Context, TypedIRI)
|
|
574
|
+
; true
|
|
575
|
+
)
|
|
576
|
+
; true
|
|
577
|
+
)
|
|
578
|
+
; ( new_subject_attr_2(SubjectAttr), % 7.5.5.2
|
|
579
|
+
memberchk(SubjectAttr=About0, Attrs),
|
|
580
|
+
attr_convert(SubjectAttr, About0, About, Context),
|
|
581
|
+
About \== null
|
|
582
|
+
-> true
|
|
583
|
+
; html_root(E, Context),
|
|
584
|
+
About = Context.eval_context.parent_object,
|
|
585
|
+
About \== null
|
|
586
|
+
-> true
|
|
587
|
+
; DOM == Context.eval_context.root
|
|
588
|
+
-> iri('', About, Context)
|
|
589
|
+
; memberchk(typeof=_, Attrs)
|
|
590
|
+
-> new_bnode(About, Context)
|
|
591
|
+
; About = Context.eval_context.parent_object,
|
|
592
|
+
About \== null
|
|
593
|
+
-> ( \+ memberchk(typeof=_, Attrs)
|
|
594
|
+
-> nb_set_dict(skip_element, Context, true)
|
|
595
|
+
; true
|
|
596
|
+
)
|
|
597
|
+
),
|
|
598
|
+
debug(rdfa(new_subject), '~w: set new_subject to ~p', [E, About]),
|
|
599
|
+
nb_set_dict(new_subject, Context, About),
|
|
600
|
+
( memberchk(typeof=_, Attrs)
|
|
601
|
+
-> nb_set_dict(typed_resource, Context, About)
|
|
602
|
+
; true
|
|
603
|
+
)
|
|
604
|
+
).
|
|
605
|
+
update_subject(DOM, Context) :-
|
|
606
|
+
DOM=element(_,Attrs,_), % 7.5.6
|
|
607
|
+
( iri_attr(about, Attrs, NewSubject, Context)
|
|
608
|
+
-> nb_set_dict(new_subject, Context, NewSubject),
|
|
609
|
+
( memberchk(typeof=_, Attrs)
|
|
610
|
+
-> nb_set_dict(typed_resource, Context, NewSubject)
|
|
611
|
+
; true
|
|
612
|
+
)
|
|
613
|
+
; true % was \+ memberchk(resource=_, Attrs):
|
|
614
|
+
% If no resource is provided ...
|
|
615
|
+
-> ( DOM == Context.eval_context.root
|
|
616
|
+
-> iri('', NewSubject, Context),
|
|
617
|
+
nb_set_dict(new_subject, Context, NewSubject),
|
|
618
|
+
( memberchk(typeof=_, Attrs)
|
|
619
|
+
-> nb_set_dict(typed_resource, Context, NewSubject)
|
|
620
|
+
; true
|
|
621
|
+
)
|
|
622
|
+
; NewSubject = Context.eval_context.parent_object,
|
|
623
|
+
NewSubject \== null
|
|
624
|
+
-> nb_set_dict(new_subject, Context, NewSubject)
|
|
625
|
+
; true
|
|
626
|
+
)
|
|
627
|
+
),
|
|
628
|
+
( ( iri_attr(resource, Attrs, CurrentObjectResource, Context)
|
|
629
|
+
; iri_attr(href, Attrs, CurrentObjectResource, Context)
|
|
630
|
+
; iri_attr(src, Attrs, CurrentObjectResource, Context)
|
|
631
|
+
; memberchk(typeof=_, Attrs),
|
|
632
|
+
\+ memberchk(about=_, Attrs),
|
|
633
|
+
new_bnode(CurrentObjectResource, Context)
|
|
634
|
+
),
|
|
635
|
+
CurrentObjectResource \== null
|
|
636
|
+
-> nb_set_dict(current_object_resource, Context, CurrentObjectResource)
|
|
637
|
+
; true
|
|
638
|
+
),
|
|
639
|
+
( memberchk(typeof=_, Attrs),
|
|
640
|
+
\+ memberchk(about=_, Attrs)
|
|
641
|
+
-> nb_set_dict(typed_resource, Context,
|
|
642
|
+
Context.current_object_resource)
|
|
643
|
+
; true
|
|
644
|
+
).
|
|
645
|
+
|
|
646
|
+
new_subject_attr_2(about).
|
|
647
|
+
new_subject_attr_2(resource).
|
|
648
|
+
new_subject_attr_2(href).
|
|
649
|
+
new_subject_attr_2(src).
|
|
650
|
+
|
|
651
|
+
html_root(head, Context) :- html_markup(Context.eval_context.markup).
|
|
652
|
+
html_root(body, Context) :- html_markup(Context.eval_context.markup).
|
|
653
|
+
|
|
654
|
+
html_markup(html).
|
|
655
|
+
html_markup(xhtml).
|
|
656
|
+
|
|
657
|
+
%! emit_typeof(+DOM, +LocalContext) is det.
|
|
658
|
+
%
|
|
659
|
+
% 7.5.7: emit triples for @typeof value.
|
|
660
|
+
|
|
661
|
+
emit_typeof(DOM, Context) :-
|
|
662
|
+
DOM = element(_,Attrs,_),
|
|
663
|
+
Subject = Context.typed_resource,
|
|
664
|
+
Subject \== null,
|
|
665
|
+
memberchk(typeof=TypeOf, Attrs),
|
|
666
|
+
!,
|
|
667
|
+
iri_list(TypeOf, IRIs, Context),
|
|
668
|
+
maplist(type_triple(Context), IRIs).
|
|
669
|
+
emit_typeof(_, _).
|
|
670
|
+
|
|
671
|
+
type_triple(Context, IRI) :-
|
|
672
|
+
add_triple(Context, Context.typed_resource, rdf:type, IRI).
|
|
673
|
+
|
|
674
|
+
%! update_list_mapping(+DOM, +Context) is det.
|
|
675
|
+
%
|
|
676
|
+
% 7.5.8: Create a list mapping if appropriate
|
|
677
|
+
|
|
678
|
+
update_list_mapping(_DOM, Context) :-
|
|
679
|
+
Context.new_subject \== null,
|
|
680
|
+
Context.new_subject \== Context.eval_context.parent_object,
|
|
681
|
+
!,
|
|
682
|
+
empty_list_mapping(ListMapping),
|
|
683
|
+
b_set_dict(list_mapping, Context, ListMapping).
|
|
684
|
+
update_list_mapping(_, _).
|
|
685
|
+
|
|
686
|
+
%! empty_list_mapping(-Mapping) is det.
|
|
687
|
+
%! empty_list_mapping(+Mapping) is semidet.
|
|
688
|
+
%! get_list_mapping(+IRI, +Mapping, -List) is semidet.
|
|
689
|
+
%! add_list_mapping(+IRI, !Mapping, +List) is det.
|
|
690
|
+
%
|
|
691
|
+
% Manage a list mapping. Note this needs to be wrapped in a term
|
|
692
|
+
% to be able to extend the mapping while keeping its identity.
|
|
693
|
+
|
|
694
|
+
empty_list_mapping(list_mapping(_{})).
|
|
695
|
+
|
|
696
|
+
get_list_mapping(IRI, list_mapping(Dict), Dict.get(IRI)).
|
|
697
|
+
|
|
698
|
+
add_list_mapping(IRI, LM, List) :-
|
|
699
|
+
LM = list_mapping(Dict),
|
|
700
|
+
setarg(1, LM, Dict.put(IRI, List)).
|
|
701
|
+
|
|
702
|
+
list_mapping_pairs(list_mapping(Dict), Pairs) :-
|
|
703
|
+
dict_pairs(Dict, _, Pairs).
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
%! step_7_5_9(+DOM, +Context)
|
|
707
|
+
|
|
708
|
+
step_7_5_9(_DOM, Context) :-
|
|
709
|
+
Context.current_object_resource == null,
|
|
710
|
+
!.
|
|
711
|
+
step_7_5_9(DOM, Context) :-
|
|
712
|
+
DOM = element(_,Attrs,_),
|
|
713
|
+
memberchk(inlist=_, Attrs),
|
|
714
|
+
has_attribute(rel, Attrs, Rel, Context),
|
|
715
|
+
!,
|
|
716
|
+
iri_list(Rel, Preds, Context),
|
|
717
|
+
CurrentObjectResource = Context.current_object_resource,
|
|
718
|
+
maplist(add_property_list(Context, CurrentObjectResource),
|
|
719
|
+
Preds).
|
|
720
|
+
step_7_5_9(DOM, Context) :-
|
|
721
|
+
DOM = element(_,Attrs,_),
|
|
722
|
+
( has_attribute(rel, Attrs, Rel, Context),
|
|
723
|
+
\+ memberchk(inlist=_, Attrs)
|
|
724
|
+
-> iri_list(Rel, RelIRIs, Context),
|
|
725
|
+
maplist(rel_triple(Context), RelIRIs)
|
|
726
|
+
; true
|
|
727
|
+
),
|
|
728
|
+
( has_attribute(rev, Attrs, Rev, Context)
|
|
729
|
+
-> iri_list(Rev, RevIRIs, Context),
|
|
730
|
+
maplist(rev_triple(Context), RevIRIs)
|
|
731
|
+
; true
|
|
732
|
+
).
|
|
733
|
+
|
|
734
|
+
rel_triple(Context, IRI) :-
|
|
735
|
+
add_triple(Context,
|
|
736
|
+
Context.new_subject, IRI, Context.current_object_resource).
|
|
737
|
+
|
|
738
|
+
rev_triple(Context, IRI) :-
|
|
739
|
+
add_triple(Context,
|
|
740
|
+
Context.current_object_resource, IRI, Context.new_subject).
|
|
741
|
+
|
|
742
|
+
%! step_7_5_10(+DOM, +Context)
|
|
743
|
+
%
|
|
744
|
+
% Similar to step_7_5_9, but adding to incomplete triples.
|
|
745
|
+
|
|
746
|
+
step_7_5_10(_DOM, Context) :-
|
|
747
|
+
Context.current_object_resource \== null,
|
|
748
|
+
!.
|
|
749
|
+
step_7_5_10(DOM, Context) :-
|
|
750
|
+
DOM = element(_,Attrs,_),
|
|
751
|
+
memberchk(inlist=_, Attrs),
|
|
752
|
+
has_attribute(rel, Attrs, Rel, Context),
|
|
753
|
+
!,
|
|
754
|
+
set_current_object_resource_to_bnode(Context),
|
|
755
|
+
iri_list(Rel, IRIs, Context),
|
|
756
|
+
maplist(incomplete_ll_triple(Context), IRIs).
|
|
757
|
+
step_7_5_10(DOM, Context) :-
|
|
758
|
+
DOM = element(_,Attrs,_),
|
|
759
|
+
( has_attribute(rel, Attrs, Rel, Context),
|
|
760
|
+
\+ memberchk(inlist=_, Attrs)
|
|
761
|
+
-> iri_list(Rel, RelIRIs, Context),
|
|
762
|
+
set_current_object_resource_to_bnode(Context),
|
|
763
|
+
maplist(incomplete_rel_triple(Context), RelIRIs)
|
|
764
|
+
; true
|
|
765
|
+
),
|
|
766
|
+
( has_attribute(rev, Attrs, Rev, Context)
|
|
767
|
+
-> iri_list(Rev, RevIRIs, Context),
|
|
768
|
+
set_current_object_resource_to_bnode(Context),
|
|
769
|
+
maplist(incomplete_rev_triple(Context), RevIRIs)
|
|
770
|
+
; true
|
|
771
|
+
).
|
|
772
|
+
|
|
773
|
+
set_current_object_resource_to_bnode(Context) :-
|
|
774
|
+
new_bnode(BNode, Context),
|
|
775
|
+
b_set_dict(current_object_resource, Context, BNode).
|
|
776
|
+
|
|
777
|
+
incomplete_ll_triple(Context, IRI) :-
|
|
778
|
+
LM = Context.list_mapping,
|
|
779
|
+
( get_list_mapping(IRI, LM, LL)
|
|
780
|
+
-> true
|
|
781
|
+
; LL = list([]),
|
|
782
|
+
add_list_mapping(IRI, LM, LL)
|
|
783
|
+
),
|
|
784
|
+
add_incomplete_triple(Context, _{list:LL, direction:none}).
|
|
785
|
+
|
|
786
|
+
incomplete_rel_triple(Context, IRI) :-
|
|
787
|
+
add_incomplete_triple(Context, _{predicate:IRI, direction:forward}).
|
|
788
|
+
|
|
789
|
+
incomplete_rev_triple(Context, IRI) :-
|
|
790
|
+
add_incomplete_triple(Context, _{predicate:IRI, direction:reverse}).
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
%! update_property_value(+DOM, +Context) is det.
|
|
794
|
+
%
|
|
795
|
+
% 7.5.11: establish current property value.
|
|
796
|
+
|
|
797
|
+
update_property_value(DOM, Context) :-
|
|
798
|
+
DOM = element(Element,Attrs,Content),
|
|
799
|
+
memberchk(property=PropSpec, Attrs),
|
|
800
|
+
!,
|
|
801
|
+
iri_list(PropSpec, Preds, Context),
|
|
802
|
+
( memberchk(datatype=DTSpec, Attrs)
|
|
803
|
+
-> ( DTSpec \== '',
|
|
804
|
+
term_or_curie_or_absiri(DTSpec, DataType, Context),
|
|
805
|
+
DataType \== null
|
|
806
|
+
-> ( ( rdf_equal(rdf:'XMLLiteral', DataType)
|
|
807
|
+
; rdf_equal(rdf:'HTML', DataType)
|
|
808
|
+
)
|
|
809
|
+
-> content_xml(Content, Text)
|
|
810
|
+
; content_text(DOM, Text, Context)
|
|
811
|
+
),
|
|
812
|
+
Obj0 = literal(type(DataType, Text))
|
|
813
|
+
; content_text(DOM, Text, Context),
|
|
814
|
+
Obj0 = literal(Text)
|
|
815
|
+
)
|
|
816
|
+
; memberchk(content=Text, Attrs)
|
|
817
|
+
-> Obj0 = literal(Text)
|
|
818
|
+
; \+ has_attribute(rel, Attrs, Context),
|
|
819
|
+
\+ has_attribute(rev, Attrs, Context),
|
|
820
|
+
%\+ memberchk(content=_, Attrs), % already guaranteed
|
|
821
|
+
( iri_attr(resource, Attrs, Obj0, Context)
|
|
822
|
+
; iri_attr(href, Attrs, Obj0, Context)
|
|
823
|
+
; iri_attr(src, Attrs, Obj0, Context)
|
|
824
|
+
),
|
|
825
|
+
Obj0 \== null
|
|
826
|
+
-> true
|
|
827
|
+
; ( memberchk(datetime=DateTime, Attrs)
|
|
828
|
+
; Element == time,
|
|
829
|
+
Content = [DateTime]
|
|
830
|
+
),
|
|
831
|
+
html_markup(Context.eval_context.markup)
|
|
832
|
+
-> ( date_time_type(DateTime, DataType)
|
|
833
|
+
-> Obj0 = literal(type(DataType, DateTime))
|
|
834
|
+
; Obj0 = literal(DateTime)
|
|
835
|
+
)
|
|
836
|
+
; memberchk(typeof=_, Attrs),
|
|
837
|
+
\+ memberchk(about=_, Attrs)
|
|
838
|
+
-> Obj0 = Context.typed_resource
|
|
839
|
+
; content_text(Content, Text, Context), % "as a plain literal"???
|
|
840
|
+
Obj0 = literal(Text)
|
|
841
|
+
),
|
|
842
|
+
( Obj0 = literal(Text),
|
|
843
|
+
atomic(Text),
|
|
844
|
+
Context.lang \== ''
|
|
845
|
+
-> Obj = literal(lang(Context.lang, Text))
|
|
846
|
+
; Obj = Obj0
|
|
847
|
+
),
|
|
848
|
+
( memberchk(inlist=_, Attrs)
|
|
849
|
+
-> maplist(add_property_list(Context, Obj), Preds)
|
|
850
|
+
; NewSubject = Context.new_subject,
|
|
851
|
+
maplist(add_property(Context, NewSubject, Obj), Preds)
|
|
852
|
+
).
|
|
853
|
+
update_property_value(_, _).
|
|
854
|
+
|
|
855
|
+
add_property_list(Context, Obj, Pred) :-
|
|
856
|
+
LM = Context.list_mapping,
|
|
857
|
+
( get_list_mapping(Pred, LM, LL)
|
|
858
|
+
-> LL = list(Old),
|
|
859
|
+
setarg(1, LL, [Obj|Old])
|
|
860
|
+
; add_list_mapping(Pred, LM, list([Obj]))
|
|
861
|
+
).
|
|
862
|
+
|
|
863
|
+
add_property(Context, Subject, Object, Pred) :-
|
|
864
|
+
add_triple(Context, Subject, Pred, Object).
|
|
865
|
+
|
|
866
|
+
content_text(element(_,Attrs,_), Text, _Context) :-
|
|
867
|
+
memberchk(content=Text, Attrs),
|
|
868
|
+
!.
|
|
869
|
+
content_text(element(_,Attrs,_), Text, Context) :-
|
|
870
|
+
memberchk(datetime=Text, Attrs),
|
|
871
|
+
html_markup(Context.eval_context.markup),
|
|
872
|
+
!.
|
|
873
|
+
content_text(element(_,_,Content), Text, _Context) :-
|
|
874
|
+
!,
|
|
875
|
+
phrase(text_nodes(Content), Texts),
|
|
876
|
+
atomic_list_concat(Texts, Text).
|
|
877
|
+
content_text(Content, Text, _Context) :-
|
|
878
|
+
!,
|
|
879
|
+
phrase(text_nodes(Content), Texts),
|
|
880
|
+
atomic_list_concat(Texts, Text).
|
|
881
|
+
|
|
882
|
+
text_nodes([]) --> !.
|
|
883
|
+
text_nodes([H|T]) --> !, text_nodes(H), text_nodes(T).
|
|
884
|
+
text_nodes(element(_,_,Content)) --> !, text_nodes(Content).
|
|
885
|
+
text_nodes(CDATA) --> [CDATA].
|
|
886
|
+
|
|
887
|
+
content_xml(DOM, Text) :-
|
|
888
|
+
with_output_to(atom(Text), xml_write(DOM, [header(false)])).
|
|
889
|
+
|
|
890
|
+
%! complete_triples(+Context)
|
|
891
|
+
%
|
|
892
|
+
% 7.5.12: Complete incomplete triples
|
|
893
|
+
|
|
894
|
+
complete_triples(Context) :-
|
|
895
|
+
Context.skip_element == false,
|
|
896
|
+
Context.new_subject \== null,
|
|
897
|
+
Context.eval_context.incomplete_triples \== [],
|
|
898
|
+
!,
|
|
899
|
+
reverse(Context.eval_context.incomplete_triples, Incomplete),
|
|
900
|
+
maplist(complete_triple(Context), Incomplete).
|
|
901
|
+
complete_triples(_).
|
|
902
|
+
|
|
903
|
+
complete_triple(Context, Dict) :-
|
|
904
|
+
complete_triple(Dict.direction, Dict, Context).
|
|
905
|
+
|
|
906
|
+
complete_triple(none, Dict, Context) :-
|
|
907
|
+
List = Dict.list,
|
|
908
|
+
List = list(Old),
|
|
909
|
+
setarg(1, List, [Context.new_subject|Old]).
|
|
910
|
+
complete_triple(forward, Dict, Context) :-
|
|
911
|
+
add_triple(Context,
|
|
912
|
+
Context.eval_context.parent_subject,
|
|
913
|
+
Dict.predicate,
|
|
914
|
+
Context.new_subject).
|
|
915
|
+
complete_triple(reverse, Dict, Context) :-
|
|
916
|
+
add_triple(Context,
|
|
917
|
+
Context.new_subject,
|
|
918
|
+
Dict.predicate,
|
|
919
|
+
Context.eval_context.parent_subject).
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
%! descent(DOM, Context)
|
|
923
|
+
%
|
|
924
|
+
% 7.5.13: Descent into the children
|
|
925
|
+
|
|
926
|
+
descent(element(_,_,Content), Context) :-
|
|
927
|
+
( Context.skip_element == true
|
|
928
|
+
-> maplist(descent_skip(Context), Content)
|
|
929
|
+
; maplist(descent_no_skip(Context), Content)
|
|
930
|
+
).
|
|
931
|
+
|
|
932
|
+
descent_skip(Context, DOM) :-
|
|
933
|
+
DOM = element(E,_,_),
|
|
934
|
+
!,
|
|
935
|
+
debug(rdfa(descent), 'skip: ~w: new_subject=~p',
|
|
936
|
+
[E, Context.new_subject]),
|
|
937
|
+
process_node(DOM, Context.eval_context.put(
|
|
938
|
+
_{ lang:Context.lang,
|
|
939
|
+
vocab:Context.vocab,
|
|
940
|
+
iri_mapping:Context.iri_mapping
|
|
941
|
+
})).
|
|
942
|
+
descent_skip(_, _).
|
|
943
|
+
|
|
944
|
+
descent_no_skip(Context, DOM) :-
|
|
945
|
+
DOM = element(E,_,_),
|
|
946
|
+
!,
|
|
947
|
+
( ParentSubject = Context.new_subject,
|
|
948
|
+
ParentSubject \== null
|
|
949
|
+
-> true
|
|
950
|
+
; ParentSubject = Context.eval_context.parent_subject
|
|
951
|
+
),
|
|
952
|
+
( ParentObject = Context.current_object_resource,
|
|
953
|
+
ParentObject \== null
|
|
954
|
+
-> true
|
|
955
|
+
; ParentObject = ParentSubject
|
|
956
|
+
),
|
|
957
|
+
debug(rdfa(descent), 'no skip: ~w: parent subject = ~p, object = ~p',
|
|
958
|
+
[E, ParentSubject, ParentObject]),
|
|
959
|
+
process_node(DOM, Context.eval_context.put(
|
|
960
|
+
_{ parent_subject:ParentSubject,
|
|
961
|
+
parent_object:ParentObject,
|
|
962
|
+
iri_mapping:Context.iri_mapping,
|
|
963
|
+
incomplete_triples:Context.incomplete_triples,
|
|
964
|
+
list_mapping:Context.list_mapping,
|
|
965
|
+
lang:Context.lang,
|
|
966
|
+
vocab:Context.vocab
|
|
967
|
+
})).
|
|
968
|
+
descent_no_skip(_, _).
|
|
969
|
+
|
|
970
|
+
%! complete_lists(+Context) is det.
|
|
971
|
+
%
|
|
972
|
+
% 7.5.14: Complete possibly pending lists
|
|
973
|
+
|
|
974
|
+
complete_lists(Context) :-
|
|
975
|
+
empty_list_mapping(Context.list_mapping),
|
|
976
|
+
!.
|
|
977
|
+
complete_lists(Context) :-
|
|
978
|
+
( CurrentSubject = Context.new_subject,
|
|
979
|
+
CurrentSubject \== null
|
|
980
|
+
-> true
|
|
981
|
+
; CurrentSubject = Context.eval_context.base
|
|
982
|
+
),
|
|
983
|
+
list_mapping_pairs(Context.list_mapping, Pairs),
|
|
984
|
+
maplist(complete_list(Context, CurrentSubject), Pairs).
|
|
985
|
+
|
|
986
|
+
complete_list(Context, _, IRI-_) :-
|
|
987
|
+
get_list_mapping(IRI, Context.eval_context.list_mapping, _),
|
|
988
|
+
!.
|
|
989
|
+
complete_list(Context, CurrentSubject, IRI-list(List0)) :-
|
|
990
|
+
reverse(List0, List),
|
|
991
|
+
emit_list(List, ListURI, Context),
|
|
992
|
+
add_triple(Context, CurrentSubject, IRI, ListURI).
|
|
993
|
+
|
|
994
|
+
emit_list([], NIL, _) :-
|
|
995
|
+
rdf_equal(NIL, rdf:nil).
|
|
996
|
+
emit_list([H|T], URI, Context) :-
|
|
997
|
+
emit_list(T, TailURI, Context),
|
|
998
|
+
new_bnode(URI, Context),
|
|
999
|
+
add_triple(Context, URI, rdf:first, H),
|
|
1000
|
+
add_triple(Context, URI, rdf:rest, TailURI).
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
%! has_attribute(+Name, +Attrs, +Context) is semidet.
|
|
1004
|
+
%! has_attribute(+Name, +Attrs, -Value, +Context) is semidet.
|
|
1005
|
+
%
|
|
1006
|
+
% True if Attrs contains Name. We sometimes need to ignore
|
|
1007
|
+
% Attributes if their value is invalid.
|
|
1008
|
+
%
|
|
1009
|
+
% @see HTML+RDFa, 3.1 Additional RDFa Processing Rules, point 7.
|
|
1010
|
+
|
|
1011
|
+
has_attribute(Name, Attrs, Context) :-
|
|
1012
|
+
has_attribute(Name, Attrs, _, Context).
|
|
1013
|
+
|
|
1014
|
+
has_attribute(rel, Attrs, Rel, Context) :-
|
|
1015
|
+
memberchk(rel=Rel, Attrs),
|
|
1016
|
+
html_markup(Context.eval_context.markup),
|
|
1017
|
+
memberchk(property=_, Attrs),
|
|
1018
|
+
!,
|
|
1019
|
+
html_non_empty_rel(Rel, Context).
|
|
1020
|
+
has_attribute(rev, Attrs, Rev, Context) :-
|
|
1021
|
+
memberchk(rev=Rev, Attrs),
|
|
1022
|
+
html_markup(Context.eval_context.markup),
|
|
1023
|
+
memberchk(property=_, Attrs),
|
|
1024
|
+
!,
|
|
1025
|
+
html_non_empty_rel(Rev, Context).
|
|
1026
|
+
has_attribute(Name, Attrs, Value, _Context) :-
|
|
1027
|
+
memberchk(Name=Value, Attrs).
|
|
1028
|
+
|
|
1029
|
+
html_non_empty_rel(Spec, Context) :-
|
|
1030
|
+
Sep = "\s\t\n\r",
|
|
1031
|
+
split_string(Spec, Sep, Sep, SpecList),
|
|
1032
|
+
member(Spec1, SpecList),
|
|
1033
|
+
safe_curie_or_curie_or_absiri(Spec1, _, Context),
|
|
1034
|
+
!.
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
%! iri_attr(+AttName, +Attrs, -IRI, +Context) is semidet.
|
|
1038
|
+
|
|
1039
|
+
iri_attr(Name, Attrs, IRI, Context) :-
|
|
1040
|
+
memberchk(Name=IRI0, Attrs),
|
|
1041
|
+
attr_convert(Name, IRI0, IRI, Context).
|
|
1042
|
+
|
|
1043
|
+
attr_convert(about, Spec, IRI, Context) :-
|
|
1044
|
+
safe_curie_or_curie_or_iri(Spec, IRI, Context).
|
|
1045
|
+
attr_convert(href, Spec, IRI, Context) :-
|
|
1046
|
+
iri(Spec, IRI, Context).
|
|
1047
|
+
attr_convert(src, Spec, IRI, Context) :-
|
|
1048
|
+
iri(Spec, IRI, Context).
|
|
1049
|
+
attr_convert(resource, Spec, IRI, Context) :-
|
|
1050
|
+
safe_curie_or_curie_or_iri(Spec, IRI, Context).
|
|
1051
|
+
attr_convert(vocab, Spec, IRI, Context) :-
|
|
1052
|
+
iri(Spec, IRI, Context).
|
|
1053
|
+
attr_convert(datatype, Spec, IRI, Context) :-
|
|
1054
|
+
term_or_curie_or_absiri(Spec, IRI, Context).
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
about(DOM, About, Context) :-
|
|
1058
|
+
DOM=element(_,Attrs,_),
|
|
1059
|
+
( memberchk(about=About0, Attrs)
|
|
1060
|
+
-> safe_curie_or_curie_or_iri(About0, About, Context)
|
|
1061
|
+
; DOM == Context.eval_context.root
|
|
1062
|
+
-> iri('', About, Context)
|
|
1063
|
+
).
|
|
1064
|
+
|
|
1065
|
+
%! new_bnode(-BNode, +Context) is det.
|
|
1066
|
+
%
|
|
1067
|
+
% Create a new blank node. Note that the current id is kept in a
|
|
1068
|
+
% term to avoid copying the counter on the descent step.
|
|
1069
|
+
|
|
1070
|
+
new_bnode(BNode, Context) :-
|
|
1071
|
+
EvalCtx = Context.eval_context,
|
|
1072
|
+
Node = EvalCtx.bnode_id,
|
|
1073
|
+
arg(1, Node, Id),
|
|
1074
|
+
succ(Id, Id1),
|
|
1075
|
+
nb_setarg(1, Node, Id1),
|
|
1076
|
+
Prefix = EvalCtx.anon_prefix,
|
|
1077
|
+
( atom(Prefix)
|
|
1078
|
+
-> atom_concat(Prefix, Id, BNode)
|
|
1079
|
+
; BNode = bnode(Id)
|
|
1080
|
+
).
|
|
1081
|
+
|
|
1082
|
+
%! iri_list(+Spec, -IRIs, +Context) is det.
|
|
1083
|
+
%
|
|
1084
|
+
% True when IRIs is a list of fulfy qualified IRIs from Spec
|
|
1085
|
+
|
|
1086
|
+
iri_list(Spec, IRIs, Context) :-
|
|
1087
|
+
Sep = "\s\t\n\r",
|
|
1088
|
+
split_string(Spec, Sep, Sep, SpecList),
|
|
1089
|
+
( SpecList == [""]
|
|
1090
|
+
-> IRIs = []
|
|
1091
|
+
; maplist(ctx_to_iri(Context), SpecList, IRIs0),
|
|
1092
|
+
exclude(==(null), IRIs0, IRIs)
|
|
1093
|
+
).
|
|
1094
|
+
|
|
1095
|
+
ctx_to_iri(Context, Spec, IRI) :-
|
|
1096
|
+
term_or_curie_or_absiri(Spec, IRI, Context).
|
|
1097
|
+
|
|
1098
|
+
%! iri(+Spec, -IRI, +Context)
|
|
1099
|
+
%
|
|
1100
|
+
% Used for @href and @src attributes
|
|
1101
|
+
|
|
1102
|
+
iri(Spec, IRI, Context) :-
|
|
1103
|
+
iri_normalized(Spec, Context.eval_context.base, IRI).
|
|
1104
|
+
|
|
1105
|
+
abs_iri(Spec, IRI) :-
|
|
1106
|
+
uri_components(Spec, Components),
|
|
1107
|
+
uri_data(authority, Components, Authority), nonvar(Authority),
|
|
1108
|
+
uri_data(scheme, Components, Scheme), nonvar(Scheme),
|
|
1109
|
+
!,
|
|
1110
|
+
iri_normalized(Spec, IRI).
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
%! safe_curie_or_curie_or_iri(+Spec, -IRI, +Context) is det.
|
|
1114
|
+
%
|
|
1115
|
+
% Implement section 7.4, CURIE and IRI Processing. Used for
|
|
1116
|
+
% @about and @resource
|
|
1117
|
+
|
|
1118
|
+
safe_curie_or_curie_or_iri(Spec, IRI, Context) :-
|
|
1119
|
+
safe_curie_or_curie_or_absiri(Spec, IRI, Context),
|
|
1120
|
+
!.
|
|
1121
|
+
safe_curie_or_curie_or_iri(Spec, IRI, Context) :-
|
|
1122
|
+
uri_normalized(Spec, Context.eval_context.base, IRI).
|
|
1123
|
+
|
|
1124
|
+
safe_curie_or_curie_or_absiri(Spec, IRI, _Context) :-
|
|
1125
|
+
abs_iri(Spec, IRI0),
|
|
1126
|
+
!,
|
|
1127
|
+
IRI = IRI0.
|
|
1128
|
+
safe_curie_or_curie_or_absiri(Spec, IRI, Context) :-
|
|
1129
|
+
atom_codes(Spec, Codes),
|
|
1130
|
+
( safe_curie(Codes, Curie)
|
|
1131
|
+
-> ( phrase(curie(IRI, Context), Curie)
|
|
1132
|
+
-> true
|
|
1133
|
+
; IRI = null
|
|
1134
|
+
)
|
|
1135
|
+
; phrase(curie(IRI, Context), Codes)
|
|
1136
|
+
).
|
|
1137
|
+
|
|
1138
|
+
safe_curie(Codes, Curie) :-
|
|
1139
|
+
append([0'[|Curie], `]`, Codes).
|
|
1140
|
+
|
|
1141
|
+
curie(IRI, Context) -->
|
|
1142
|
+
"_:", !, reference_or_empty(Reference),
|
|
1143
|
+
{ IRI = Context.eval_context.named_bnodes.v.get(Reference)
|
|
1144
|
+
-> true
|
|
1145
|
+
; new_bnode(IRI, Context),
|
|
1146
|
+
b_set_dict(v, Context.eval_context.named_bnodes,
|
|
1147
|
+
Context.eval_context.named_bnodes.v.put(Reference, IRI))
|
|
1148
|
+
}.
|
|
1149
|
+
curie(IRI, Context) -->
|
|
1150
|
+
":", !, reference_or_empty(Reference),
|
|
1151
|
+
{ atom_concat(Context.iri_mapping.get(''), Reference, IRI) }.
|
|
1152
|
+
curie(IRI, Context) -->
|
|
1153
|
+
nc_name(Prefix), ":", !, reference_or_empty(Reference),
|
|
1154
|
+
{ atom_concat(Context.iri_mapping.get(Prefix), Reference, IRI0)
|
|
1155
|
+
-> IRI = IRI0
|
|
1156
|
+
; rdfa_core_prefix(Prefix, URIPrefix)
|
|
1157
|
+
-> atom_concat(URIPrefix, Reference, IRI)
|
|
1158
|
+
}.
|
|
1159
|
+
|
|
1160
|
+
%! term_or_curie_or_absiri(+Spec, -IRI, +Context) is det.
|
|
1161
|
+
%
|
|
1162
|
+
% Used for @datatype and @property, @typeof, @rel and @rev
|
|
1163
|
+
|
|
1164
|
+
term_or_curie_or_absiri(Spec, IRI, _Context) :-
|
|
1165
|
+
abs_iri(Spec, IRI0),
|
|
1166
|
+
!,
|
|
1167
|
+
IRI = IRI0.
|
|
1168
|
+
term_or_curie_or_absiri(Spec, IRI, Context) :-
|
|
1169
|
+
atom_codes(Spec, Codes),
|
|
1170
|
+
( phrase(term(Term), Codes),
|
|
1171
|
+
downcase_atom(Term, LwrCase)
|
|
1172
|
+
-> ( Vocab = Context.vocab,
|
|
1173
|
+
Vocab \== ''
|
|
1174
|
+
-> atom_concat(Vocab, Term, IRI)
|
|
1175
|
+
; term_iri(LwrCase, Context.eval_context.markup, IRI0)
|
|
1176
|
+
-> IRI = IRI0
|
|
1177
|
+
; IRI = Context.term_mapping.get(Term)
|
|
1178
|
+
-> true
|
|
1179
|
+
; dict_pairs(Context.term_mapping, _Tag, Pairs),
|
|
1180
|
+
member(TermCaps-IRI, Pairs),
|
|
1181
|
+
downcase_atom(TermCaps, LwrCase)
|
|
1182
|
+
-> true
|
|
1183
|
+
; IRI = null
|
|
1184
|
+
)
|
|
1185
|
+
; phrase(curie(IRI, Context), Codes)
|
|
1186
|
+
-> true
|
|
1187
|
+
; uri_normalized(Spec, Context.eval_context.base, IRI)
|
|
1188
|
+
).
|
|
1189
|
+
|
|
1190
|
+
%! term_iri(?Term, ?Markup, ?IRI)
|
|
1191
|
+
%
|
|
1192
|
+
% @see http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
|
|
1193
|
+
|
|
1194
|
+
term_expansion(term_iri(Term, Markup), term_iri(Term, Markup, URI)) :-
|
|
1195
|
+
default_prefix_mapping(Markup, Prefix),
|
|
1196
|
+
atom_concat(Prefix, Term, URI).
|
|
1197
|
+
|
|
1198
|
+
term_iri(alternate, xhtml).
|
|
1199
|
+
term_iri(appendix, xhtml).
|
|
1200
|
+
term_iri(cite, xhtml).
|
|
1201
|
+
term_iri(bookmark, xhtml).
|
|
1202
|
+
term_iri(contents, xhtml).
|
|
1203
|
+
term_iri(chapter, xhtml).
|
|
1204
|
+
term_iri(copyright, xhtml).
|
|
1205
|
+
term_iri(first, xhtml).
|
|
1206
|
+
term_iri(glossary, xhtml).
|
|
1207
|
+
term_iri(help, xhtml).
|
|
1208
|
+
term_iri(icon, xhtml).
|
|
1209
|
+
term_iri(index, xhtml).
|
|
1210
|
+
term_iri(last, xhtml).
|
|
1211
|
+
term_iri(meta, xhtml).
|
|
1212
|
+
term_iri(next, xhtml).
|
|
1213
|
+
term_iri(prev, xhtml).
|
|
1214
|
+
term_iri(previous, xhtml).
|
|
1215
|
+
term_iri(section, xhtml).
|
|
1216
|
+
term_iri(start, xhtml).
|
|
1217
|
+
term_iri(stylesheet, xhtml).
|
|
1218
|
+
term_iri(subsection, xhtml).
|
|
1219
|
+
term_iri(top, xhtml).
|
|
1220
|
+
term_iri(up, xhtml).
|
|
1221
|
+
term_iri(p3pv1, xhtml).
|
|
1222
|
+
|
|
1223
|
+
term_iri(describedby, _, 'http://www.w3.org/2007/05/powder-s#describedby').
|
|
1224
|
+
term_iri(license, _, 'http://www.w3.org/1999/xhtml/vocab#license').
|
|
1225
|
+
term_iri(role, _, 'http://www.w3.org/1999/xhtml/vocab#role').
|
|
1226
|
+
|
|
1227
|
+
/*******************************
|
|
1228
|
+
* GRAMMARS *
|
|
1229
|
+
*******************************/
|
|
1230
|
+
|
|
1231
|
+
prefixes(Dict0, Dict) -->
|
|
1232
|
+
ws, nc_name(Name), ws, ":", ws, reference(IRI), !, ws,
|
|
1233
|
+
prefixes(Dict0.put(Name,IRI), Dict).
|
|
1234
|
+
prefixes(Dict, Dict) --> [].
|
|
1235
|
+
|
|
1236
|
+
ws --> ws1, !, ws.
|
|
1237
|
+
ws --> [].
|
|
1238
|
+
|
|
1239
|
+
ws1 --> " ".
|
|
1240
|
+
ws1 --> "\t".
|
|
1241
|
+
ws1 --> "\r".
|
|
1242
|
+
ws1 --> "\n".
|
|
1243
|
+
|
|
1244
|
+
nc_name(Name) -->
|
|
1245
|
+
[H], {nc_name_start_code(H)},
|
|
1246
|
+
nc_name_codes(Codes),
|
|
1247
|
+
{ atom_codes(Name0, [H|Codes]),
|
|
1248
|
+
downcase_atom(Name0, Name)
|
|
1249
|
+
}.
|
|
1250
|
+
|
|
1251
|
+
%! term(-Term)//
|
|
1252
|
+
%
|
|
1253
|
+
% 7.4.3
|
|
1254
|
+
|
|
1255
|
+
term(Term) -->
|
|
1256
|
+
[H], {nc_name_start_code(H)},
|
|
1257
|
+
term_codes(Codes),
|
|
1258
|
+
{ atom_codes(Term, [H|Codes])
|
|
1259
|
+
}.
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
nc_name_codes([H|T]) --> nc_name_code(H), !, nc_name_codes(T).
|
|
1263
|
+
nc_name_codes([]) --> [].
|
|
1264
|
+
|
|
1265
|
+
nc_name_code(H) --> [H], {nc_name_code(H)}.
|
|
1266
|
+
|
|
1267
|
+
term_codes([H|T]) --> term_code(H), !, term_codes(T).
|
|
1268
|
+
term_codes([]) --> [].
|
|
1269
|
+
|
|
1270
|
+
term_code(H) --> [H], {term_code(H)}.
|
|
1271
|
+
|
|
1272
|
+
nc_name_start_code(0':) :- !, fail.
|
|
1273
|
+
nc_name_start_code(C) :- xml_basechar(C), !.
|
|
1274
|
+
nc_name_start_code(C) :- xml_ideographic(C).
|
|
1275
|
+
|
|
1276
|
+
nc_name_code(0':) :- !, fail.
|
|
1277
|
+
nc_name_code(C) :- xml_basechar(C), !.
|
|
1278
|
+
nc_name_code(C) :- xml_digit(C), !.
|
|
1279
|
+
nc_name_code(C) :- xml_ideographic(C), !.
|
|
1280
|
+
nc_name_code(C) :- xml_combining_char(C), !.
|
|
1281
|
+
nc_name_code(C) :- xml_extender(C), !.
|
|
1282
|
+
|
|
1283
|
+
term_code(0'/) :- !.
|
|
1284
|
+
term_code(C) :- nc_name_code(C).
|
|
1285
|
+
|
|
1286
|
+
reference(IRI) -->
|
|
1287
|
+
[H],
|
|
1288
|
+
reference_codes(T),
|
|
1289
|
+
{ atom_codes(IRI, [H|T]) }.
|
|
1290
|
+
|
|
1291
|
+
reference_codes([]) --> ws1, !.
|
|
1292
|
+
reference_codes([H|T]) --> [H], !, reference_codes(T).
|
|
1293
|
+
reference_codes([]) --> [].
|
|
1294
|
+
|
|
1295
|
+
reference_or_empty(IRI) -->
|
|
1296
|
+
reference_codes(Codes),
|
|
1297
|
+
{ atom_codes(IRI, Codes) }.
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
%! date_time_type(+DateTime, -DataType) is semidet.
|
|
1301
|
+
%
|
|
1302
|
+
% True when DataType is the xsd type that matches the lexical
|
|
1303
|
+
% representation of DateTime
|
|
1304
|
+
|
|
1305
|
+
date_time_type(DateTime, DataType) :-
|
|
1306
|
+
atom_codes(DateTime, Codes),
|
|
1307
|
+
phrase(date_time_type(DataType), Codes).
|
|
1308
|
+
|
|
1309
|
+
date_time_type(DT) --> duration, !, { rdf_equal(DT, xsd:duration) }.
|
|
1310
|
+
date_time_type(DT) --> date_time, !, { rdf_equal(DT, xsd:dateTime) }.
|
|
1311
|
+
date_time_type(DT) --> date, !, { rdf_equal(DT, xsd:date) }.
|
|
1312
|
+
date_time_type(DT) --> time, !, { rdf_equal(DT, xsd:time) }.
|
|
1313
|
+
date_time_type(DT) --> gyearmonth, !, { rdf_equal(DT, xsd:gYearMonth) }.
|
|
1314
|
+
date_time_type(DT) --> gyear, !, { rdf_equal(DT, xsd:gYear) }.
|
|
1315
|
+
|
|
1316
|
+
duration --> opt_minus, "P",
|
|
1317
|
+
opt_dy, opt_dm, opt_dd,
|
|
1318
|
+
( "T"
|
|
1319
|
+
-> opt_dh, opt_dm, opt_ds
|
|
1320
|
+
; ""
|
|
1321
|
+
).
|
|
1322
|
+
|
|
1323
|
+
date_time --> opt_minus, yyyy, "-", !, mM, "-", dd,
|
|
1324
|
+
"T", hh, ":", mm, ":", ss, opt_fraction, opt_zzzzzz.
|
|
1325
|
+
date --> opt_minus, yyyy, "-", !, mM, "-", dd.
|
|
1326
|
+
time --> hh, ":", mm, ":", ss, opt_fraction.
|
|
1327
|
+
gyearmonth --> opt_minus, yyyy, "-", !, mM.
|
|
1328
|
+
gyear --> opt_minus, yyyy.
|
|
1329
|
+
|
|
1330
|
+
opt_minus --> "-", !.
|
|
1331
|
+
opt_minus --> "".
|
|
1332
|
+
|
|
1333
|
+
yyyy --> dnzs, d, d, d, d.
|
|
1334
|
+
|
|
1335
|
+
dnzs --> "".
|
|
1336
|
+
dnzs --> dnz, dnzs.
|
|
1337
|
+
|
|
1338
|
+
opt_fraction --> ".", !, ds.
|
|
1339
|
+
opt_fraction --> "".
|
|
1340
|
+
|
|
1341
|
+
mM --> d(V1), d(V2), { M is V1*10+V2, M >= 1, M =< 12 }.
|
|
1342
|
+
dd --> d(V1), d(V2), { M is V1*10+V2, M >= 1, M =< 31 }.
|
|
1343
|
+
hh --> d(V1), d(V2), { M is V1*10+V2, M =< 23 }.
|
|
1344
|
+
mm --> d(V1), d(V2), { M is V1*10+V2, M =< 59 }.
|
|
1345
|
+
ss --> d(V1), d(V2), { M is V1*10+V2, M =< 59 }.
|
|
1346
|
+
|
|
1347
|
+
d(V) --> [D], { between(0'0, 0'9, D), V is D-0'0 }.
|
|
1348
|
+
d --> [D], { between(0'0, 0'9, D) }.
|
|
1349
|
+
dnz --> [D], { between(0'1, 0'9, D) }.
|
|
1350
|
+
|
|
1351
|
+
ds --> d, !, ds.
|
|
1352
|
+
ds --> "".
|
|
1353
|
+
|
|
1354
|
+
opt_zzzzzz --> sign, hh, ":", mm.
|
|
1355
|
+
opt_zzzzzz --> "Z".
|
|
1356
|
+
opt_zzzzzz --> "".
|
|
1357
|
+
|
|
1358
|
+
sign --> "+".
|
|
1359
|
+
sign --> "-".
|
|
1360
|
+
|
|
1361
|
+
opt_dy --> ( int, "Y" | "" ).
|
|
1362
|
+
opt_dm --> ( int, "M" | "" ).
|
|
1363
|
+
opt_dd --> ( int, "D" | "" ).
|
|
1364
|
+
opt_dh --> ( int, "H" | "" ).
|
|
1365
|
+
opt_ds --> ( int, ("." -> int ; ""), "S" | "" ).
|
|
1366
|
+
|
|
1367
|
+
int --> d, ds.
|
|
1368
|
+
|
|
1369
|
+
/*******************************
|
|
1370
|
+
* TRIPLES *
|
|
1371
|
+
*******************************/
|
|
1372
|
+
|
|
1373
|
+
%! add_triple(+Context, +S, +P, +O) is det.
|
|
1374
|
+
%
|
|
1375
|
+
% Add a triple to the global evaluation context. Triples are
|
|
1376
|
+
% embedded in a term, so we can use setarg/3 on the list, while
|
|
1377
|
+
% the evaluation context is copied for descending the node
|
|
1378
|
+
% hierarchy.
|
|
1379
|
+
|
|
1380
|
+
add_triple(Context, S, P, O) :-
|
|
1381
|
+
( debugging(rdfa(triple))
|
|
1382
|
+
-> debug(rdfa(triple), 'Added { ~p ~p ~p }', [S,P,O]),
|
|
1383
|
+
backtrace(4)
|
|
1384
|
+
; true
|
|
1385
|
+
),
|
|
1386
|
+
valid_subject(S),
|
|
1387
|
+
valid_predicate(P),
|
|
1388
|
+
valid_object(O),
|
|
1389
|
+
!,
|
|
1390
|
+
Triples = Context.eval_context.triples,
|
|
1391
|
+
arg(1, Triples, Old),
|
|
1392
|
+
setarg(1, Triples, [rdf(S,P,O)|Old]).
|
|
1393
|
+
add_triple(_, _, _, _). % ignored invalid triple.
|
|
1394
|
+
|
|
1395
|
+
valid_subject(S) :- S \== null.
|
|
1396
|
+
valid_predicate(P) :- P \== null, \+ rdf_is_bnode(P).
|
|
1397
|
+
valid_object(O) :- O \== null, ( atom(O) -> true ; valid_literal(O) ).
|
|
1398
|
+
|
|
1399
|
+
valid_literal(literal(Plain)) :-
|
|
1400
|
+
atom(Plain),
|
|
1401
|
+
!.
|
|
1402
|
+
valid_literal(literal(type(T, _))) :-
|
|
1403
|
+
!,
|
|
1404
|
+
T \== null.
|
|
1405
|
+
valid_literal(literal(lang(_,_))).
|
|
1406
|
+
|
|
1407
|
+
add_incomplete_triple(Context, Dict) :-
|
|
1408
|
+
debug(rdfa(incomplete), 'Incomplete: ~p', [Dict]),
|
|
1409
|
+
b_set_dict(incomplete_triples, Context,
|
|
1410
|
+
[ Dict
|
|
1411
|
+
| Context.incomplete_triples
|
|
1412
|
+
]).
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
/*******************************
|
|
1416
|
+
* PATTERNS *
|
|
1417
|
+
*******************************/
|
|
1418
|
+
|
|
1419
|
+
%! apply_patterns(+TriplesIn, -TriplesOut) is det.
|
|
1420
|
+
%
|
|
1421
|
+
% Apply RDFa patterns. We need several passes do deal with ordering
|
|
1422
|
+
% issues and the possibility that patterns are invalid:
|
|
1423
|
+
%
|
|
1424
|
+
% 1. find patterns from rdf(_,rdfa:copy,Pattern)
|
|
1425
|
+
% 2. collect the properties for these patterns and delete
|
|
1426
|
+
% patterns that do not have rdf:type rdfa:Pattern.
|
|
1427
|
+
% 3. Actually copy the patterns and delete the patterns themselves.
|
|
1428
|
+
|
|
1429
|
+
apply_patterns(TriplesIn, TriplesOut) :-
|
|
1430
|
+
referenced_patterns(TriplesIn, Pairs),
|
|
1431
|
+
( Pairs == []
|
|
1432
|
+
-> TriplesOut = TriplesIn
|
|
1433
|
+
; sort(Pairs, UniquePairs),
|
|
1434
|
+
dict_pairs(Dict, _, UniquePairs),
|
|
1435
|
+
pattern_properties(TriplesIn, Dict),
|
|
1436
|
+
delete_invalid_patterns(Dict, Patterns),
|
|
1437
|
+
phrase(apply_patterns(TriplesIn, Patterns), TriplesOut)
|
|
1438
|
+
).
|
|
1439
|
+
|
|
1440
|
+
term_expansion(TIn, TOut) :-
|
|
1441
|
+
rdf_global_term(TIn, TOut).
|
|
1442
|
+
|
|
1443
|
+
referenced_patterns([], []).
|
|
1444
|
+
referenced_patterns([rdf(_,rdfa:copy,O)|T0], [O-[]|T]) :-
|
|
1445
|
+
!,
|
|
1446
|
+
referenced_patterns(T0, T).
|
|
1447
|
+
referenced_patterns([_|T0], T) :-
|
|
1448
|
+
referenced_patterns(T0, T).
|
|
1449
|
+
|
|
1450
|
+
pattern_properties([], _).
|
|
1451
|
+
pattern_properties([rdf(S,P,O)|T], Dict) :-
|
|
1452
|
+
ignore(b_set_dict(S, Dict, [P-O|Dict.get(S)])),
|
|
1453
|
+
pattern_properties(T, Dict).
|
|
1454
|
+
|
|
1455
|
+
delete_invalid_patterns(Patterns0, Patterns) :-
|
|
1456
|
+
dict_pairs(Patterns0, Tag, Pairs0),
|
|
1457
|
+
include(rdfa_pattern, Pairs0, Pairs),
|
|
1458
|
+
dict_pairs(Patterns, Tag, Pairs).
|
|
1459
|
+
|
|
1460
|
+
rdfa_pattern(_-PO) :-
|
|
1461
|
+
memberchk((rdf:type)-(rdfa:'Pattern'), PO).
|
|
1462
|
+
|
|
1463
|
+
apply_patterns([], _) --> [].
|
|
1464
|
+
apply_patterns([rdf(S,rdfa:copy,O)|T0], Dict) -->
|
|
1465
|
+
!,
|
|
1466
|
+
copy_pattern(Dict.O, S),
|
|
1467
|
+
apply_patterns(T0, Dict).
|
|
1468
|
+
apply_patterns([rdf(S,_,_)|T0], Dict) -->
|
|
1469
|
+
{ _ = Dict.get(S) },
|
|
1470
|
+
!,
|
|
1471
|
+
apply_patterns(T0, Dict).
|
|
1472
|
+
apply_patterns([H|T], Dict) -->
|
|
1473
|
+
[H],
|
|
1474
|
+
apply_patterns(T, Dict).
|
|
1475
|
+
|
|
1476
|
+
copy_pattern([], _) --> [].
|
|
1477
|
+
copy_pattern([(rdf:type)-(rdfa:'Pattern')|T], S) -->
|
|
1478
|
+
!,
|
|
1479
|
+
copy_pattern(T, S).
|
|
1480
|
+
copy_pattern([P-O|T], S) -->
|
|
1481
|
+
[rdf(S,P,O)],
|
|
1482
|
+
copy_pattern(T, S).
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
/*******************************
|
|
1486
|
+
* HOOK INTO RDF-DB *
|
|
1487
|
+
*******************************/
|
|
1488
|
+
|
|
1489
|
+
:- multifile
|
|
1490
|
+
rdf_db:rdf_load_stream/3,
|
|
1491
|
+
rdf_db:rdf_file_type/2.
|
|
1492
|
+
|
|
1493
|
+
%! rdf_db:rdf_load_stream(+Format, +Stream, :Options)
|
|
1494
|
+
%
|
|
1495
|
+
% Register library(semweb/rdfa) as loader for HTML RDFa files.
|
|
1496
|
+
%
|
|
1497
|
+
% @tbd Which options need to be forwarded to read_rdfa/3?
|
|
1498
|
+
|
|
1499
|
+
rdf_db:rdf_load_stream(rdfa, Stream, _Module:Options1):-
|
|
1500
|
+
rdf_db:graph(Options1, Graph),
|
|
1501
|
+
atom_concat('__', Graph, BNodePrefix),
|
|
1502
|
+
merge_options([anon_prefix(BNodePrefix)], Options1, Options2),
|
|
1503
|
+
read_rdfa(Stream, Triples, Options2),
|
|
1504
|
+
rdf_transaction(( forall(member(rdf(S,P,O), Triples),
|
|
1505
|
+
rdf_assert(S, P, O, Graph)),
|
|
1506
|
+
rdf_set_graph(Graph, modified(false))
|
|
1507
|
+
),
|
|
1508
|
+
parse(Graph)).
|
|
1509
|
+
|
|
1510
|
+
rdf_db:rdf_file_type(html, rdfa).
|