Commit b5cae60a authored by Giuseppe Castagna's avatar Giuseppe Castagna
Browse files

Merge branch 'master' of https://git.cduce.org/cduce

Conflicts:
	CHANGES
parents d86115db 95a432f0
<<<<<<< HEAD
current
......@@ -12,10 +13,27 @@ current
- Build:
* replaced netcgi2 for netcgi1
=======
0.6.1
* Fix the source so that it can be compiled with Ocaml 4.02 and the external version of camlp4
* Upgrade Ocaml interface to support ocaml 4.02
* Modularise the Ocaml interface. This version of CDuce now supports the following combinations:
ocaml compiler | ocaml sources (for the CDuce-Ocaml interface)
3.11.x 3.12.x | 3.11.x 3.12.x
4.00/4.01 | 3.11.x 3.12.x 4.00 4.01
4.02 | 4.02
It is however recommended to use the same version of for the Ocaml compiler and the Ocaml sources
* Parallelize the Makefile (make -j works as exptected)
0.6.0
* Upgrade the Ocaml interface to support ocaml 4.00 and 4.01 (contributed by Julien Lopez)
Warning: the Ocaml interface now requires ocaml >= 4.00 and < 4.02 (4.02 is not supported)
>>>>>>> 95a432f0d7807165e15f4c5e271a2680ac8dadc7
0.5.5
* Added load_xml_subst and print_xml_subst for namespaces substitution.
(necessary for Web Services with OcCDuce and CDuce_WS).
(necessary for Web Services with OcCDuce and CDuce_WS).
0.5.4
* Added Services for Ocsigen.
......@@ -54,10 +72,10 @@ current
0.4.2
- Language:
- Language:
* Added int_of_char
- Bug fix:
- Bug fix:
* "match 1 with (x := `nil) -> x" raised an assert failure
......@@ -74,14 +92,14 @@ current
on each branch
* New "dump_xml" and "dump_xml_utf8", equivalent to the composition
of print and print_xml, but more efficient
- Implementation:
* New subtyping algorithm
* Small improvement to the pattern matching compiler
* Improve type-checking time for map
* Improve type-checking of record expressions
* Don't display warnings for unused branches in ghost (generated) pattern
* Don't display warnings for unused branches in ghost (generated) pattern
matching
- Bug fix:
......@@ -192,16 +210,16 @@ current
- ".." to denote open record types/patterns:
open record: { l1=t1 l2=t2 .. }
closed record: { l1=t1 l2=t2 }
- the ";" between fields is optional even for records
- the ";" between fields is optional even for records
(used to be optional only for attributes)
* Keywords are now allowed as type names
* Concatenation @ allowed in types
* Record concatenation + allowed in types
* Changed "string://" URL-pseudo schema to "string:"
* Changed "string://" URL-pseudo schema to "string:"
* Better resolution of external entities for PXP and expat
- Tools:
* A new tool cduce_mktop produces customized CDuce toplevels with embedded
* A new tool cduce_mktop produces customized CDuce toplevels with embedded
OCaml externals.
* Removed the validate tool.
* Don't build dtd2cduce by default (it requires PXP). An online
......@@ -225,7 +243,7 @@ current
0.2.2
- Language:
* Runtime type-check: (e :? t) raises an exception when e doesn't
* Runtime type-check: (e :? t) raises an exception when e doesn't
have type t; the exception is an explanation of why this is not the case.
(The actual message may change in the future.)
* Better return type for load_xml, defined as:
......@@ -262,7 +280,7 @@ current
Now, [ ... x::Any* ] is as efficient as [ ... ; x ]. Can also be written
[ ... /x _* ]. The [ ... ; ... ] syntax is no longer necessary
and might be deprecated.
- Bug fixes, including:
* Bug fixes in configure/Makefile for Cygwin.
* Bug fix for the compilation of complex patterns with records.
......@@ -289,7 +307,7 @@ current
* Support for URLs in load_xml, load_html, load_file, and schemas:
e.g. you can write `` load_html "http://www.cduce.org/" ''
(need either the ocurl package or the netclient package).
* More advanced (and documented) support for XML Schemas.
* More advanced (and documented) support for XML Schemas.
* Preliminary integration of CQL query language that is:
select e from p1 in e1, ... ,pn in en where e'.
* Allow structured constants in default value patterns (p := c).
......@@ -302,7 +320,7 @@ current
* argv is now an operator of type [] -> [ String* ].
* The --dump, --load, --save options are deprecated.
* Changes to the command line. "--pxp" is replaced with "--no expat".
- Implementation:
* Code upgraded to Ocaml 3.07.
* Major cleaning in progress.
......@@ -324,7 +342,7 @@ current
* Various bug fixes (expat might now work)
* Sequencing operator e1;e2 (equivalent to: let [] = e1 in e2)
* Encoded references
0.1.0
* Support for XML Namespaces
......@@ -342,7 +360,7 @@ current
* Second alpha release
* Bug fixes and syntax changes (e.g. making "fun" optional in "let fun")
* Experimenting with expat support (see expat/README)
0.0.9
0.0.9
* First public release (alpha release)
......@@ -3,6 +3,11 @@ default: cduce
include Makefile.conf
include VERSION
ifneq ($(ML_INTERFACE), false)
OCAMLIFACE=ocamliface/$(ML_INTERFACE_VERSION)
else
OCAMLIFACE=
endif
ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)
......@@ -14,10 +19,11 @@ endif
OUNIT_TESTS=eval cdnum cdsdl misc
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
ALL_TARGET += cduce_lib.cmxa
endif
PACKAGES = dynlink camlp4 ulex pcre num netstring
ALL_ML_IFACE = 3.x 4.01 4.02
# Call make with VERBOSE=true to get a trace of commands
......@@ -41,14 +47,14 @@ SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
CAMLC_P = ocamlc -g
DEPEND_OCAMLDEP = misc/q_symbol.cmo
ifeq ($(PROFILE), true)
CAMLOPT_P = ocamlopt -p -inline 10000
CAMLOPT_P = ocamlopt -p -inline 100
ifeq ($(NATIVE), false)
CAMLC_P = ocamlcp -p a
SYNTAX_PARSER =
DEPEND_OCAMLDEP =
endif
else
CAMLOPT_P = ocamlopt -inline 10000
CAMLOPT_P = ocamlopt -inline 100
endif
OPT = -warn-error FPSXY
......@@ -138,8 +144,11 @@ help:
# Source directories
DIRS = misc parser schema typing types compile runtime driver query ocamliface win32
CLEAN_DIRS = $(DIRS) tools tests
DIRS_DEPEND = misc parser schema typing types compile runtime driver query win32
CLEAN_DIRS := $(DIRS_DEPEND) tools tests
DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
# Objects to build
......@@ -182,18 +191,11 @@ schema/schema_types.ml: schema/schema_types.mli
compile/auto_pat.ml: compile/auto_pat.mli
cp $^ $@
ML_INTERFACE_OBJS = \
ocamliface/caml_cduce.cmo \
ocamliface/mltypes.cmo ocamliface/mlstub.cmo
ifneq ($(ML_INTERFACE), false)
OBJECTS += $(ML_INTERFACE_OBJS)
endif
ifneq ($(CURL), false)
OBJECTS += parser/cduce_curl.cmo
PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
OBJECTS += parser/cduce_netclient.cmo
PACKAGES += netclient
......@@ -229,22 +231,38 @@ endif
all: $(ALL_TARGET)
OBJECTS += driver/run.cmo
ML_INTERFACE_BASE_OBJS = caml_cduce.cmo mltypes.cmo mlstub.cmo
ML_INTERFACE_BASE_SRC = $(ML_INTERFACE_BASE_OBJS:.cmo=.ml) $(ML_INTERFACE_BASE_OBJS:.cmo=.mli)
ML_INTERFACE_OBJS = \
$(ML_INTERFACE_BASE_OBJS:%=$(OCAMLIFACE)/%)
OBJECTS_NO_MLIFACE := $(OBJECTS)
ifneq ($(ML_INTERFACE), false)
OBJECTS += $(ML_INTERFACE_OBJS)
endif
CDUCE = $(OBJECTS) driver/start.cmo
ALL_OBJECTS = $(OBJECTS) \
ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
driver/start.cmo driver/examples.cmo \
driver/webiface.cmo driver/evaluator.cmo \
tools/validate.cmo \
$(ML_INTERFACE_OBJS) parser/cduce_curl.cmo \
parser/cduce_curl.cmo \
parser/cduce_netclient.cmo \
runtime/cduce_expat.cmo runtime/cduce_pxp.cmo
ALL_INTERFACES = schema/schema_types.mli
#types/var.mli types/boolVar.mli
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
INCLUDES = $(DIRS:%=-I %)
INCLUDES_DEPEND = $(DIRS_DEPEND:%=-I %)
# -I +camlp4
cduce: $(CDUCE:.cmo=.$(EXTENSION))
......@@ -271,16 +289,25 @@ dtd2cduce: tools/dtd2cduce.ml
$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
.PHONY: compute_depend
compute_depend: $(DEPEND_OCAMLDEP)
@echo "Computing dependencies ..."
ocamlfind ocamldep -package "$(PACKAGES)" \
$(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
$(INCLUDES_DEPEND) $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo $(DEPEND) > depend
for i in $(ALL_ML_IFACE); do \
touch ocamliface/$$i/caml_cduce.ml; \
ocamlfind ocamldep -package "$(PACKAGES)" \
$(INCLUDES_DEPEND) -I ocamliface/$$i $(SYNTAX_PARSER) -ppopt pa_extend.cmo -ppopt q_MLast.cmo \
$(ML_INTERFACE_BASE_SRC:%=ocamliface/$$i/%) >> depend;\
rm -f ocamliface/$$i/caml_cduce.ml; \
done
clean:
for i in $(CLEAN_DIRS); do \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
done
rm -f misc/q_symbol.cmo.stamp
(cd ocamliface; $(MAKE) clean)
test -n "$(OCAMLIFACE)" && (cd $(OCAMLIFACE); $(MAKE) clean) || true
rm -f `find . -name "*~"`
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
rm -f cduce$(EXE) ocamlprof.dump
......@@ -300,36 +327,40 @@ clean:
distclean: clean
rm -f Makefile.conf
ocamliface/mltypes.$(EXTENSION): ocamliface/caml_cduce.$(EXTENSION)
.SUFFIXES: .ml .mli .cmo .cmi .cmx
$(OCAMLIFACE)/mltypes.$(EXTENSION): $(OCAMLIFACE)/caml_cduce.$(EXTENSION)
$(ALL_INTERFACES): misc/q_symbol.cmo
$(ALL_OBJECTS:.cmo=.cmi): misc/q_symbol.cmo
$(ALL_OBJECTS:.cmo=.cmx) caml_cduce.cmx: misc/q_symbol.cmo
$(ALL_OBJECTS) caml_cduce.cmo: misc/q_symbol.cmo
$(ALL_INTERFACES): misc/q_symbol.cmo.stamp
$(ALL_OBJECTS:.cmo=.cmi): misc/q_symbol.cmo.stamp
$(ALL_OBJECTS:.cmo=.cmx) caml_cduce.cmx: misc/q_symbol.cmo.stamp
$(ALL_OBJECTS) caml_cduce.cmo: misc/q_symbol.cmo.stamp
$(OCAMLIFACE)/mlstub.$(EXTENSION): SYNTAX += q_MLast.cmo
misc/q_symbol.cmo: misc/q_symbol.ml
misc/q_symbol.cmo.stamp: misc/q_symbol.ml
@echo "Build $@"
$(HIDE) $(CAMLC) -c -pp camlp4orf $<
$(HIDE) sync
$(HIDE) touch misc/q_symbol.cmo.stamp
.SUFFIXES: .ml .mli .cmo .cmi .cmx
types/boolVar.cmo: SYNTAX_PARSER=
types/boolVar.cmi: SYNTAX_PARSER=
types/boolVar.cmx: SYNTAX_PARSER=
parser/parser.$(EXTENSION): PACKAGES += camlp4.extend
.ml.cmo:
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.ml.cmx:
@echo "Build $@"
$(HIDE)$(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
$(HIDE) $(CAMLOPT) $(FORPACKOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.mli.cmi:
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
$(HIDE) $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
include depend
......@@ -360,10 +391,13 @@ install_doc: doc
### Pack OCaml modules for the CDuce/OCaml interface
ocamliface/caml_cduce.cmo:
@cd ocamliface; \
$(MAKE) caml_cduce.cmo
$(OCAMLIFACE)/caml_cduce.cmo:
@echo "Build $@"
@cd $(OCAMLIFACE); \
$(MAKE) -s MODE=byte CAMLC="$(OCAMLFIND) $(CAMLC_P)" caml_cduce.cmo
$(OCAMLIFACE)/caml_cduce.cmx:
@echo "Build $@"
@cd $(OCAMLIFACE); \
$(MAKE) -s MODE=opt CAMLOPT="$(OCAMLFIND) $(CAMLOPT_P)" caml_cduce.cmx
ocamliface/caml_cduce.cmx:
@cd ocamliface; \
$(MAKE) caml_cduce.cmx
......@@ -138,7 +138,7 @@ let check_feature f p =
else (print "disabled\n"; false)
let native =
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt") && !native
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt")
let check_pkg p () =
try
......@@ -179,7 +179,17 @@ let add_icon = match Sys.os_type with
let check_mliface dir =
(* Sys.file_exists (Filename.concat dir "typing/types.ml") *)
Sys.file_exists (Filename.concat dir "typing/types.ml")
List.for_all (fun f ->
Sys.file_exists (Filename.concat dir f))
[ "typing/types.ml"; "VERSION" ]
let mliface_version dir =
let ic = open_in (Filename.concat dir "VERSION") in
let s = input_line ic in
close_in ic;
if s < "4" then "3.x"
else if s < "4.02" then "4.01"
else "4.02"
let ocaml_stdlib () =
if (Sys.command "ocamlc -where > ocaml_stdlib" <> 0) then
......@@ -195,17 +205,19 @@ let make_absolute dir =
then Filename.concat (Sys.getcwd ()) dir
else dir
let ml_interface =
let ml_interface, mliface_version =
let dir1 = !(List.assoc "mliface" vars) in
let dirs = if dir1 = "" then [] else [ make_absolute dir1 ] in
print "ocaml sources... ";
let rec loop = function
| [] ->
print "not found (the interface will not be built)\n";
None
None, ""
| d::dirs ->
if check_mliface d then
(print ("found: " ^ d ^ "\n"); Some d)
let version = mliface_version d in
(print ("found: " ^ d ^ ", version " ^ version ^ "\n");
Some d, version)
else loop dirs
in
loop dirs
......@@ -285,7 +297,7 @@ let () =
fprintf out "# This file has been generated by the configure script\n";
fprintf out "NATIVE=%b\n" native;
(match ml_interface with
| Some d -> fprintf out "ML_INTERFACE=true\nOCAML_SRC=%s\n" d
| Some d -> fprintf out "ML_INTERFACE=true\nOCAML_SRC=%s\nML_INTERFACE_VERSION=%s\n" d mliface_version
| None -> fprintf out "ML_INTERFACE=false\n");
fprintf out "PXP=%b\n" pxp;
fprintf out "EXPAT=%b\n" expat;
......
......@@ -336,20 +336,6 @@ tools/validate.cmo : schema/schema_types.cmi schema/schema_parser.cmi \
schema/schema_common.cmi
tools/validate.cmx : schema/schema_types.cmx schema/schema_parser.cmx \
schema/schema_common.cmx
ocamliface/mltypes.cmo : types/ident.cmo ocamliface/config.cmo \
parser/cduce_loc.cmi ocamliface/mltypes.cmi
ocamliface/mltypes.cmx : types/ident.cmx ocamliface/config.cmx \
parser/cduce_loc.cmx ocamliface/mltypes.cmi
ocamliface/mlstub.cmo : types/types.cmi typing/typer.cmi types/sequence.cmi \
misc/ns.cmi ocamliface/mltypes.cmi driver/librarian.cmi types/ident.cmo \
types/externals.cmi compile/compile.cmi parser/cduce_loc.cmi \
driver/cduce_config.cmi types/builtin_defs.cmi types/atoms.cmi \
parser/ast.cmo ocamliface/mlstub.cmi
ocamliface/mlstub.cmx : types/types.cmx typing/typer.cmx types/sequence.cmx \
misc/ns.cmx ocamliface/mltypes.cmx driver/librarian.cmx types/ident.cmx \
types/externals.cmx compile/compile.cmx parser/cduce_loc.cmx \
driver/cduce_config.cmx types/builtin_defs.cmx types/atoms.cmx \
parser/ast.cmx ocamliface/mlstub.cmi
parser/cduce_curl.cmo : runtime/value.cmi parser/url.cmi \
driver/cduce_config.cmi
parser/cduce_curl.cmx : runtime/value.cmx parser/url.cmx \
......@@ -445,9 +431,69 @@ driver/cduce.cmi : runtime/value.cmi types/atoms.cmi
runtime/cduce_pxp.cmi :
runtime/cduce_pxp.cmi :
runtime/cduce_expat.cmi :
ocamliface/mltypes.cmi : types/types.cmi types/ident.cmo
ocamliface/mlstub.cmi : parser/ast.cmo
runtime/cduce_expat.cmi :
runtime/cduce_pxp.cmi :
schema/schema_types.cmi : runtime/value.cmi misc/ns.cmi misc/encodings.cmi \
types/atoms.cmi
ocamliface/3.x/caml_cduce.cmo :
ocamliface/3.x/caml_cduce.cmx :
ocamliface/3.x/mltypes.cmo : types/ident.cmo parser/cduce_loc.cmi \
ocamliface/3.x/caml_cduce.cmo ocamliface/3.x/mltypes.cmi
ocamliface/3.x/mltypes.cmx : types/ident.cmx parser/cduce_loc.cmx \
ocamliface/3.x/caml_cduce.cmx ocamliface/3.x/mltypes.cmi
ocamliface/3.x/mlstub.cmo : types/types.cmi typing/typer.cmi \
types/sequence.cmi misc/ns.cmi ocamliface/3.x/mltypes.cmi \
driver/librarian.cmi types/ident.cmo types/externals.cmi \
compile/compile.cmi parser/cduce_loc.cmi driver/cduce_config.cmi \
types/builtin_defs.cmi types/atoms.cmi parser/ast.cmo \
ocamliface/3.x/mlstub.cmi
ocamliface/3.x/mlstub.cmx : types/types.cmx typing/typer.cmx \
types/sequence.cmx misc/ns.cmx ocamliface/3.x/mltypes.cmx \
driver/librarian.cmx types/ident.cmx types/externals.cmx \
compile/compile.cmx parser/cduce_loc.cmx driver/cduce_config.cmx \
types/builtin_defs.cmx types/atoms.cmx parser/ast.cmx \
ocamliface/3.x/mlstub.cmi
ocamliface/3.x/mltypes.cmi : types/types.cmi ocamliface/3.x/caml_cduce.cmo
ocamliface/3.x/mlstub.cmi : parser/ast.cmo
ocamliface/4.01/caml_cduce.cmo :
ocamliface/4.01/caml_cduce.cmx :
ocamliface/4.01/mltypes.cmo : types/ident.cmo parser/cduce_loc.cmi \
ocamliface/4.01/caml_cduce.cmo ocamliface/4.01/mltypes.cmi
ocamliface/4.01/mltypes.cmx : types/ident.cmx parser/cduce_loc.cmx \
ocamliface/4.01/caml_cduce.cmx ocamliface/4.01/mltypes.cmi
ocamliface/4.01/mlstub.cmo : types/types.cmi typing/typer.cmi \
types/sequence.cmi misc/ns.cmi ocamliface/4.01/mltypes.cmi \
driver/librarian.cmi types/ident.cmo types/externals.cmi \
compile/compile.cmi parser/cduce_loc.cmi driver/cduce_config.cmi \
ocamliface/4.01/caml_cduce.cmo types/builtin_defs.cmi types/atoms.cmi \
parser/ast.cmo ocamliface/4.01/mlstub.cmi
ocamliface/4.01/mlstub.cmx : types/types.cmx typing/typer.cmx \
types/sequence.cmx misc/ns.cmx ocamliface/4.01/mltypes.cmx \
driver/librarian.cmx types/ident.cmx types/externals.cmx \
compile/compile.cmx parser/cduce_loc.cmx driver/cduce_config.cmx \
ocamliface/4.01/caml_cduce.cmx types/builtin_defs.cmx types/atoms.cmx \
parser/ast.cmx ocamliface/4.01/mlstub.cmi
ocamliface/4.01/mltypes.cmi : types/types.cmi types/ident.cmo \
ocamliface/4.01/caml_cduce.cmo
ocamliface/4.01/mlstub.cmi : parser/ast.cmo
ocamliface/4.02/caml_cduce.cmo :
ocamliface/4.02/caml_cduce.cmx :
ocamliface/4.02/mltypes.cmo : types/ident.cmo parser/cduce_loc.cmi \
ocamliface/4.02/caml_cduce.cmo ocamliface/4.02/mltypes.cmi
ocamliface/4.02/mltypes.cmx : types/ident.cmx parser/cduce_loc.cmx \
ocamliface/4.02/caml_cduce.cmx ocamliface/4.02/mltypes.cmi
ocamliface/4.02/mlstub.cmo : types/types.cmi typing/typer.cmi \
types/sequence.cmi misc/ns.cmi ocamliface/4.02/mltypes.cmi \
driver/librarian.cmi types/ident.cmo types/externals.cmi \
compile/compile.cmi parser/cduce_loc.cmi driver/cduce_config.cmi \
ocamliface/4.02/caml_cduce.cmo types/builtin_defs.cmi types/atoms.cmi \
parser/ast.cmo ocamliface/4.02/mlstub.cmi
ocamliface/4.02/mlstub.cmx : types/types.cmx typing/typer.cmx \
types/sequence.cmx misc/ns.cmx ocamliface/4.02/mltypes.cmx \
driver/librarian.cmx types/ident.cmx types/externals.cmx \
compile/compile.cmx parser/cduce_loc.cmx driver/cduce_config.cmx \
ocamliface/4.02/caml_cduce.cmx types/builtin_defs.cmx types/atoms.cmx \
parser/ast.cmx ocamliface/4.02/mlstub.cmi
ocamliface/4.02/mltypes.cmi : types/types.cmi types/ident.cmo \
ocamliface/4.02/caml_cduce.cmo
ocamliface/4.02/mlstub.cmi : parser/ast.cmo
let examples = [ "q1","
type Bib = <bib>[Book*]
let examples = [ "qatt1","type Bib = <bib>[Book*]
type Book = <book year=String>[Title (Author+ | Editor+ ) Publisher Price ]
type Author = <author>[Last First ]
type Editor = <editor>[Last First Affiliation ]
......@@ -43,39 +42,27 @@ let doc : Bib = <bib>[
<price>['129.95']
]];;
(*
-----------------------------Q1-----------------------------
List books published by Addison-Wesley after 1991, including their year and title.
------------------------------------------------------------
let biblio = [doc]/Book;;
<bib>
{
for $b in doc(\"http://bstore1.example.com/bib.xml\")/bib/book
where $b/publisher = \"Addison-Wesley\" and $b/@year > 1991
return
<book year=\"{ $b/@year }\">
{ $b/title }
</book>
}
</bib>
select <book (a)> x
from <book (a)>[ (x::(Any\Editor)|_ )* ] in biblio ;;
(*This expression returns all book in bib but removoing the editor element. If one wants to write more explicitly:
*)
<bib>
select <book year=y>([b]/Title)
from b in [doc]/<book .. >[_* <publisher>\"Addison-Wesley\";_] ,
y in [b]/@year
where 1991<<int_of(y);;
select <book (a)> x
from <book (a)>[ (x::(Any\<editor ..>_)|_ )* ] in biblio;;
<bib>
select <book year=y> t
from <bib>[b::Book*] in [doc],
<book year=y .. >[t::Title _+ <publisher>\"Addison-Wesley\";_] in b
where 1991 << int_of(y);;
(*
Or even:
*)
select <book (a)> x
from <book (a)>[ (x::(<(_\`editor) ..>_)|_ )* ] in biblio ;;
";"q2","
type Bib = <bib>[Book*]
";"qatt2","type Bib = <bib>[Book*]
type Book = <book year=String>[Title (Author+ | Editor+ ) Publisher Price ]
type Author = <author>[Last First ]
type Editor = <editor>[Last First Affiliation ]
......@@ -118,42 +105,21 @@ let doc : Bib = <bib>[
<price>['129.95']
]];;
(*
---------------------------Q2---------------------------------
Create a flat list of all the title-author pairs, with each pair enclosed in a \"result\" element.
--------------------------------------------------------------
<results>
{
for $b in doc(\"http://bstore1.example.com/bib.xml\")/bib/book,
$t in $b/title,
$a in $b/author
return
<result>
{ $t }
{ $a }
</result>
}
</results>
(*
Back to the first one:
*)
<bib>
select <book (a)> x
from <(book) (a)>[ (x::(Any\Editor)|_ )* ] in biblio ;;
<results>
select <result>([b]/Title @ [a])
from b in [doc]/Book,
a in [b]/Author ;;
<results>
select <result>[t a]
from <bib>[b::Book+] in [doc],
<book ..>[t&Title la::Author+ ;_] in b,
a in la ;;
(*
This query takes any element in bib, tranforms it in a book element and removes sub-elements editor, but you will get a warning as capture variable book in the from is never used: we should have written <(_) (a)> instead of <(book) (a)> the from
*)
select <(book) (a)> x
from <(book) (a)>[ (x::(Any\Editor)|_ )* ] in biblio ;;
";"q3","
type Bib = <bib>[Book*]
";"qatt3","type Bib = <bib>[Book*]
type Book = <book year=String>[Title (Author+ | Editor+ ) Publisher Price ]
type Author = <author>[Last First ]
type Editor = <editor>[Last First Affiliation ]
......@@ -196,257 +162,459 @@ let doc : Bib = <bib>[
<price>['129.95']
]];;
(*
---------------------------Q3---------------------------------
For each book in the bibliography, list the title and authors, grouped inside a \"result\" element.
--------------------------------------------------------------
<results>
{
for $b in doc(\"http://bstore1.example.com/bib.xml\")/bib/book
return
<result>
{ $b/title }
{ $b/author }
</result>
}
</results>
Same thing but without tranforming tag to \"book\".
More interestingly:
*)
<results>