Commit aaf2760b authored by Pietro Abate's avatar Pietro Abate

[r2003-05-31 10:32:42 by cvscast] support for expat

Original author: cvscast
Date: 2003-05-31 10:32:43+00:00
parent 18ba2ad0
......@@ -22,14 +22,17 @@ endif
VERSION = 0.0.9
SYNTAX_PARSER = -pp '$(SYNTAX)'
CAMLC_P = ocamlc
ifeq ($(PROFILE), true)
CAMLC_P = ocamlcp -p a
CAMLOPT_P = ocamlopt -p
SYNTAX_PARSER =
ifeq ($(NATIVE), false)
CAMLC_P = ocamlcp -p a
SYNTAX_PARSER =
endif
else
CAMLC_P = ocamlc
CAMLOPT_P = ocamlopt
SYNTAX_PARSER = -pp '$(SYNTAX)'
CAMLOPT_P = ocamlopt -inline 25
endif
OPT = -warn-error A
......@@ -38,10 +41,10 @@ CAMLOPT = ocamlfind $(CAMLOPT_P) $(OPT) $(PACKAGES)
ifeq ($(NATIVE), true)
EXTENSION = cmx
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa mlexpat.cmxa
else
EXTENSION = cmo
LINK = $(CAMLC) -custom -linkpkg gramlib.cma
LINK = $(CAMLC) -custom -linkpkg gramlib.cma mlexpat.cma
endif
all: cduce dtd2cduce local_website
......@@ -76,7 +79,7 @@ WEBIFACE = $(OBJECTS) driver/examples.cmo driver/webiface.cmo
DTD2CDUCE = tools/dtd2cduce.cmo
DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli)
INCLUDES = $(DIRS:%=-I %)
INCLUDES = $(DIRS:%=-I %) -I expat
cduce: $(CDUCE:.cmo=.$(EXTENSION))
$(LINK) $(INCLUDES) -o $@ $^
......@@ -100,6 +103,7 @@ clean:
for i in $(CLEAN_DIRS); do \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
done
(cd expat; make clean)
rm -f `find . -name "*~"`
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
rm -f cduce ocamlprof.dump
......@@ -113,6 +117,10 @@ clean:
misc/q_symbol.cmo: misc/q_symbol.ml
$(CAMLC) -c $<
.PHONY: expat
expat:
(cd expat; make)
.ml.cmo:
$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
......
......@@ -74,10 +74,12 @@ runtime/eval.cmo: misc/q_symbol.cmo types/ident.cmo types/patterns.cmi runtime/r
typing/typed.cmo types/types.cmi runtime/value.cmi runtime/eval.cmi
runtime/eval.cmx: misc/q_symbol.cmo types/ident.cmx types/patterns.cmx runtime/run_dispatch.cmx \
typing/typed.cmx types/types.cmx runtime/value.cmx runtime/eval.cmi
runtime/load_xml.cmo: misc/q_symbol.cmo types/atoms.cmi misc/encodings.cmi types/ident.cmo \
parser/location.cmi runtime/value.cmi runtime/load_xml.cmi
runtime/load_xml.cmx: misc/q_symbol.cmo types/atoms.cmx misc/encodings.cmx types/ident.cmx \
parser/location.cmx runtime/value.cmx runtime/load_xml.cmi
runtime/load_xml.cmo: misc/q_symbol.cmo types/atoms.cmi misc/encodings.cmi expat/expat.cmi \
types/ident.cmo parser/location.cmi runtime/value.cmi \
runtime/load_xml.cmi
runtime/load_xml.cmx: misc/q_symbol.cmo types/atoms.cmx misc/encodings.cmx expat/expat.cmx \
types/ident.cmx parser/location.cmx runtime/value.cmx \
runtime/load_xml.cmi
runtime/print_xml.cmo: misc/q_symbol.cmo types/atoms.cmi misc/encodings.cmi types/ident.cmo \
parser/location.cmi types/sequence.cmi runtime/value.cmi
runtime/print_xml.cmx: misc/q_symbol.cmo types/atoms.cmx misc/encodings.cmx types/ident.cmx \
......@@ -102,10 +104,12 @@ driver/cduce.cmx: misc/q_symbol.cmo parser/ast.cmx runtime/eval.cmx types/ident.
parser/location.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \
misc/state.cmx typing/typed.cmx typing/typer.cmx types/types.cmx \
runtime/value.cmx parser/wlexer.cmx driver/cduce.cmi
driver/run.cmo: misc/q_symbol.cmo driver/cduce.cmi types/ident.cmo parser/location.cmi \
types/sequence.cmi misc/state.cmi runtime/value.cmi parser/wlexer.cmo
driver/run.cmx: misc/q_symbol.cmo driver/cduce.cmx types/ident.cmx parser/location.cmx \
types/sequence.cmx misc/state.cmx runtime/value.cmx parser/wlexer.cmx
driver/run.cmo: misc/q_symbol.cmo driver/cduce.cmi types/ident.cmo runtime/load_xml.cmi \
parser/location.cmi types/sequence.cmi misc/state.cmi runtime/value.cmi \
parser/wlexer.cmo
driver/run.cmx: misc/q_symbol.cmo driver/cduce.cmx types/ident.cmx runtime/load_xml.cmx \
parser/location.cmx types/sequence.cmx misc/state.cmx runtime/value.cmx \
parser/wlexer.cmx
driver/webiface.cmo: misc/q_symbol.cmo driver/cduce.cmi driver/examples.cmo parser/location.cmi \
misc/state.cmi
driver/webiface.cmx: misc/q_symbol.cmo driver/cduce.cmx driver/examples.cmx parser/location.cmx \
......
......@@ -17,6 +17,8 @@ let specs =
" specify filename for persistency";
"--quiet", Arg.Set Cduce.quiet,
" suppress normal output (typing, results)";
"--expat", Arg.Unit (fun () -> Load_xml.use_parser := `Expat),
" use expat instead of PXP to parse XML documents";
"-v", Arg.Unit version,
" print CDuce version";
"--version", Arg.Unit version,
......
Copyright (c) 2002, 2003 by Maas-Maarten Zeeman
The package ocaml-expat is copyright by Maas-Maarten Zeeman.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this document and the ocaml-expat software ("the Software"),
to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The Software is provided ``as is'', without warranty of any kind,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose and noninfringement.
In no event shall Maas-Maarten Zeeman be liable for any claim, damages
or other liability, whether in an action of contract, tort or
otherwise, arising from, out of or in connection with the Software or
the use or other dealings in the software.
EXPAT_LIB=-L/usr/lib -lexpat
EXPAT_LIBDIR=/usr/lib
EXPAT_INCDIR=/usr/include
libmlexpat.a: expat_stubs.o expat.cmo expat.cmx
ocamlmklib -verbose -o mlexpat $^ $(EXPAT_LIB)
expat.cmo: expat.cmi expat.ml
ocamlc -c expat.ml
expat.cmx: expat.cmi expat.ml
ocamlopt -c expat.ml
expat.cmi: expat.mli
ocamlc -c expat.mli
clean:
rm -f *.o *.a *.so *.cmo *.cmx *.cmi *.cma *.cmxa
(***********************************************************************)
(* The OcamlExpat library *)
(* *)
(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. See *)
(* LICENCE for details. *)
(***********************************************************************)
(* $Id: expat.ml,v 1.1 2003/05/31 10:32:42 cvscast Exp $ *)
type expat_parser
type xml_error =
XML_ERROR_NONE
| XML_ERROR_NO_MEMORY
| XML_ERROR_SYNTAX
| XML_ERROR_NO_ELEMENTS
| XML_ERROR_INVALID_TOKEN
| XML_ERROR_UNCLOSED_TOKEN
| XML_ERROR_PARTIAL_CHAR
| XML_ERROR_TAG_MISMATCH
| XML_ERROR_DUPLICATE_ATTRIBUTE
| XML_ERROR_JUNK_AFTER_DOC_ELEMENT
| XML_ERROR_PARAM_ENTITY_REF
| XML_ERROR_UNDEFINED_ENTITY
| XML_ERROR_RECURSIVE_ENTITY_REF
| XML_ERROR_ASYNC_ENTITY
| XML_ERROR_BAD_CHAR_REF
| XML_ERROR_BINARY_ENTITY_REF
| XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
| XML_ERROR_MISPLACED_XML_PI
| XML_ERROR_UNKNOWN_ENCODING
| XML_ERROR_INCORRECT_ENCODING
| XML_ERROR_UNCLOSED_CDATA_SECTION
| XML_ERROR_EXTERNAL_ENTITY_HANDLING
| XML_ERROR_NOT_STANDALONE
| XML_ERROR_UNEXPECTED_STATE
| XML_ERROR_ENTITY_DECLARED_IN_PE
| XML_ERROR_FEATURE_REQUIRES_XML_DTD
| XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
exception Expat_error of xml_error
external xml_error_to_string : xml_error -> string = "expat_XML_ErrorString"
(* exception is currently too minimalistic, but it's a start *)
let _ = Callback.register_exception "expat_error"
(Expat_error XML_ERROR_NONE)
external expat_version : unit -> string = "expat_XML_ExpatVersion"
(* calls to create a parser *)
external parser_create : encoding:string -> expat_parser =
"expat_XML_ParserCreate"
external parser_create_ns : encoding:string -> separator:char -> expat_parser =
"expat_XML_ParserCreateNS"
(* calls needed to parse *)
external parse : expat_parser -> string -> unit = "expat_XML_Parse"
external parse_sub : expat_parser -> string -> int -> int -> unit = "expat_XML_Parse_sub"
external final : expat_parser -> unit = "expat_XML_Final"
(* start element handler calls *)
external set_start_element_handler : expat_parser ->
(string -> (string * string) list -> unit) -> unit =
"expat_XML_SetStartElementHandler"
external reset_start_element_handler : expat_parser -> unit =
"expat_XML_ResetStartElementHandler"
(* end element handler calls *)
external set_end_element_handler : expat_parser -> (string -> unit) -> unit =
"expat_XML_SetEndElementHandler"
external reset_end_element_handler : expat_parser -> unit =
"expat_XML_ResetEndElementHandler"
(* character data handler calls *)
external set_character_data_handler : expat_parser -> (string -> unit) -> unit =
"expat_XML_SetCharacterDataHandler"
external reset_character_data_handler : expat_parser -> unit =
"expat_XML_ResetCharacterDataHandler"
(* processing instruction handler calls *)
external set_processing_instruction_handler : expat_parser ->
(string -> string -> unit) -> unit =
"expat_XML_SetProcessingInstructionHandler"
external reset_processing_instruction_handler : expat_parser -> unit =
"expat_XML_ResetProcessingInstructionHandler"
(* comment handler *)
external set_comment_handler : expat_parser -> (string -> unit) -> unit =
"expat_XML_SetCommentHandler"
external reset_comment_handler : expat_parser -> unit =
"expat_XML_ResetCommentHandler"
(* some general parser query calls *)
external get_current_byte_index : expat_parser -> int =
"expat_XML_GetCurrentByteIndex"
external get_current_column_number : expat_parser -> int =
"expat_XML_GetCurrentColumnNumber"
external get_current_line_number : expat_parser -> int =
"expat_XML_GetCurrentLineNumber"
external get_current_byte_count : expat_parser -> int =
"expat_XML_GetCurrentByteCount"
(***********************************************************************)
(* The OcamlExpat library *)
(* *)
(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. See *)
(* LICENCE for details. *)
(***********************************************************************)
(* $Id: expat.mli,v 1.1 2003/05/31 10:32:42 cvscast Exp $ *)
(** The Ocaml Expat library provides an interface to the Expat XML Parser.
Expat is a library, written C, for parsing XML documents. It's the
underlying for Mozilla, Perl's [XML::Parser], Python's
[xml.parser.expat], and other open source XML parsers.
To use this library, link with
[ocamlc expat.cma]
or
[ocamlopt expat.cmxa]
@author Maas-Maarten Zeeman
*)
(** The type of expat parsers *)
type expat_parser
(** {5 Parser Creation} *)
(** Create a new XML parser. If encoding is not empty, it specifies
a character encoding to use for the document. This overrides the
document encoding declaration. Expat has four built in encodings.
[US-ASCII], [UTF-8], [UTF-16], [ISO-8859-1] *)
val parser_create : encoding:string -> expat_parser
(** Create a new XML parser that has namespace processing in effect *)
val parser_create_ns : encoding:string -> separator:char -> expat_parser
(** {5 Parsing} *)
(** Let the parser parse a chunk of an XML document.
@raise Expat_error error *)
val parse : expat_parser -> string -> unit
val parse_sub : expat_parser -> string -> int -> int -> unit
(** Inform the parser that the entire document has been parsed. *)
val final : expat_parser -> unit
(** {5 Handler Setting and Resetting}
The strings that are passed to the handlers are always encoded in
[UTF-8]. Your application is responsible for translation of these
strings into other encodings.
*)
(** {6 Start element setting and resetting} *)
val set_start_element_handler : expat_parser ->
(string -> (string * string) list -> unit) -> unit
val reset_start_element_handler : expat_parser -> unit
(** {6 End element setting and resetting} *)
val set_end_element_handler : expat_parser -> (string -> unit) -> unit
val reset_end_element_handler : expat_parser -> unit
(** {6 Character data hander setting and resetting} *)
val set_character_data_handler : expat_parser -> (string -> unit) -> unit
val reset_character_data_handler : expat_parser -> unit
(** {6 Processing Instruction handler setting and resetting} *)
val set_processing_instruction_handler : expat_parser ->
(string -> string -> unit) -> unit
val reset_processing_instruction_handler : expat_parser -> unit
(** {6 Comment handler setting and resetting} *)
val set_comment_handler : expat_parser -> (string -> unit) -> unit
val reset_comment_handler : expat_parser -> unit
(** {5 Parse Position Functions} *)
val get_current_byte_index : expat_parser -> int
val get_current_column_number : expat_parser -> int
val get_current_line_number : expat_parser -> int
val get_current_byte_count : expat_parser -> int
(** {5 Error Reporting} *)
type xml_error =
XML_ERROR_NONE
| XML_ERROR_NO_MEMORY
| XML_ERROR_SYNTAX
| XML_ERROR_NO_ELEMENTS
| XML_ERROR_INVALID_TOKEN
| XML_ERROR_UNCLOSED_TOKEN
| XML_ERROR_PARTIAL_CHAR
| XML_ERROR_TAG_MISMATCH
| XML_ERROR_DUPLICATE_ATTRIBUTE
| XML_ERROR_JUNK_AFTER_DOC_ELEMENT
| XML_ERROR_PARAM_ENTITY_REF
| XML_ERROR_UNDEFINED_ENTITY
| XML_ERROR_RECURSIVE_ENTITY_REF
| XML_ERROR_ASYNC_ENTITY
| XML_ERROR_BAD_CHAR_REF
| XML_ERROR_BINARY_ENTITY_REF
| XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
| XML_ERROR_MISPLACED_XML_PI
| XML_ERROR_UNKNOWN_ENCODING
| XML_ERROR_INCORRECT_ENCODING
| XML_ERROR_UNCLOSED_CDATA_SECTION
| XML_ERROR_EXTERNAL_ENTITY_HANDLING
| XML_ERROR_NOT_STANDALONE
| XML_ERROR_UNEXPECTED_STATE
| XML_ERROR_ENTITY_DECLARED_IN_PE
| XML_ERROR_FEATURE_REQUIRES_XML_DTD
| XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
(** Exception raised by parse function to report error conditions *)
exception Expat_error of xml_error
(** Converts a xml_error to a string *)
val xml_error_to_string : xml_error -> string
(** {5 Miscellaneous Functions} *)
(** Return the Expat library version as a string (e.g. "expat_1.95.1" *)
val expat_version : unit -> string
This diff is collapsed.
......@@ -5,6 +5,15 @@ open Ident
exception MultipleDeclaration of id
type env = t Env.t
let set_cdr x q = Obj.set_field (Obj.repr x) 1 (Obj.repr q)
let seq_accu () = Pair (nil,nil)
let append_accu x y = let acc = Pair (y,nil) in set_cdr x acc; acc
let get_accu = function
| Pair (x,y) -> y
| _ -> assert false
(* Evaluation of expressions *)
let rec eval env e0 = match e0.Typed.exp_descr with
......@@ -107,17 +116,34 @@ and eval_map env brs = function
and eval_transform env brs = function
| Pair (x,y) ->
(match eval_branches env brs x with
| Value.Absent -> eval_transform env brs y
| x -> concat x (eval_transform env brs y))
| String_latin1 (_,_,_,q) | String_utf8 (_,_,_,q) as v ->
if Types.Char.is_empty (brs.Typed.br_accept)
then eval_transform env brs q
else eval_transform env brs (normalize v)
| q -> q
(*
and eval_transform env brs v =
let acc = seq_accu () in
eval_transform_aux env brs acc v;
get_accu acc
and eval_transform_aux env brs acc = function
| Pair (x,y) ->
let x =
match eval_branches env brs x with
| Value.Absent -> Value.nil
| x -> x in
| x -> List.fold_left add_accu acc x
x in
concat x (eval_transform env brs y)
| String_latin1 (_,_,_,q) | String_utf8 (_,_,_,q) as v ->
if Types.Char.is_empty (brs.Typed.br_accept)
then eval_transform env brs q
else eval_transform env brs (normalize v)
| q -> q
*)
and eval_xtrans env brs = function
| String_utf8 (s,i,j,q) as v ->
......
(* Loading XML documents *)
(*TODO: close the file ! *)
let use_parser = ref `Pxp
open Pxp_yacc
open Pxp_lexer_types
......@@ -34,7 +34,7 @@ let rec only_ws s i =
(i = 0) ||
(let i = pred i in match (String.unsafe_get s i) with
| ' ' | '\t' | '\n' | '\r' -> only_ws s i
| _ -> false)
| _ -> false)
let string s q =
......@@ -58,7 +58,74 @@ type token =
| Start of string * (string * string) list
| String of string
let load_xml_aux s =
let stack = ref []
let txt = create 1024
let rec create_elt accu = function
| String s :: st -> create_elt (string s accu) st
| Element x :: st -> create_elt (Pair (x,accu)) st
| Start (name,att) :: st -> stack := Element (elem name att accu) :: st
| [] -> assert false
let buflen = 1000
let buf = String.create buflen
let load_expat s =
let p = Expat.parser_create "" in
Expat.set_start_element_handler p
(fun name att ->
if not (only_ws txt.buffer txt.pos) then
stack := String (String.sub txt.buffer 0 txt.pos) :: !stack;
txt.pos <- 0;
stack := Start (name,att) :: !stack);
Expat.set_end_element_handler p
(fun _ ->
let accu =
if only_ws txt.buffer txt.pos
then nil
else string (String.sub txt.buffer 0 txt.pos) nil in
txt.pos <- 0;
create_elt accu !stack);
Expat.set_character_data_handler p (add_string txt);
let ic = open_in s in
let rec loop () =
let n = input ic buf 0 buflen in
if (n > 0) then
(*(Expat.parse p (String.sub buf 0 n); loop ())*)
(Expat.parse_sub p buf 0 n; loop ())
in
try
loop();
Expat.final p;
close_in ic;
match !stack with
| [ Element x ] -> stack := []; x
| _ -> assert false
with
Expat.Expat_error e ->
failwith ("Expat ("^s^"):"^Expat.xml_error_to_string e)
let handle_event = function
| E_start_tag (name,att,_) ->
if not (only_ws txt.buffer txt.pos) then
stack := String (String.sub txt.buffer 0 txt.pos) :: !stack;
txt.pos <- 0;
stack := Start (name,att) :: !stack
| E_char_data data ->
add_string txt data
| E_end_tag (_,_) ->
let accu =
if only_ws txt.buffer txt.pos
then nil
else string (String.sub txt.buffer 0 txt.pos) nil in
txt.pos <- 0;
create_elt accu !stack
| _ -> ()
let load_pxp s =
let config = { default_config with
(* warner = new warner; *)
encoding = `Enc_utf8;
......@@ -67,48 +134,15 @@ let load_xml_aux s =
}
in
let mgr = create_entity_manager config (from_file s) in
let next_event =
create_pull_parser config (`Entry_document[]) mgr in
let get () =
match next_event () with
| Some (E_error exn) -> failwith (Pxp_types.string_of_exn exn)
| Some E_end_of_stream | None -> failwith "Unexpected end of XML stream"
| Some x -> x in
let txt = create 1024 in
let rec create_elt accu = function
| String s :: st -> create_elt (string s accu) st
| Element x :: st -> create_elt (Pair (x,accu)) st
| [ Start (name,att) ] -> elem name att accu
| Start (name,att) :: st -> parse_seq (Element (elem name att accu) :: st)
| [] -> assert false
and parse_seq stack =
match get() with
| E_start_tag (name,att,_) ->
let stack =
if only_ws txt.buffer txt.pos then stack
else String (String.sub txt.buffer 0 txt.pos) :: stack in
txt.pos <- 0;
parse_seq (Start (name,att) :: stack)
| E_char_data data ->
add_string txt data;
parse_seq stack
| E_end_tag (_,_) ->
let accu =
if only_ws txt.buffer txt.pos
then nil
else string (String.sub txt.buffer 0 txt.pos) nil in
txt.pos <- 0;
create_elt accu stack
| _ -> failwith "Expect start_tag, char_data, or end_tag"
in
let rec parse_doc () =
match get () with
| E_start_tag (name,att,_) -> parse_seq [ Start (name,att) ]
| _ -> parse_doc () in
parse_doc ()
process_entity config (`Entry_document[]) mgr handle_event;
match !stack with
| [ Element x ] -> stack := []; x
| _ -> assert false
let load_xml_aux s =
match !use_parser with
| `Expat -> load_expat s
| `Pxp -> load_pxp s
let load_xml s =
Location.protect_op "load_xml";
......
val use_parser: [ `Expat | `Pxp ] ref
val load_xml: string -> Value.t
val load_html: string -> Value.t
type Table = <table>[Row*] ;;
type Table = <table>[Row*]
type Row = <row> [
<id>[PCDATA]
<firstname>[PCDATA]
......@@ -8,10 +7,10 @@ type Row = <row> [
<city>[PCDATA]
<state>[PCDATA]
<zip>[PCDATA]
] ;;
include "../../web/xhtml-strict.cd" ;;
]
include "../../web/xhtml-strict.cd"
(* type Xhtml = Any *)
let fun dbonerow (<table> x : Table) : Xhtml =
<html>[
......@@ -53,14 +52,14 @@ let fun dbonerow (<table> x : Table) : Xhtml =
]
)
]
;;
match load_xml "testcases/db30000.xml" with
| x & Table -> print_xml(dbonerow x)
| _ -> raise "Ma che c%$#^# di file mi hai passato?";;
match argv with
[ f ] -> (*load_xml f*)
(match load_xml f with
| x & Table -> print_xml(dbonerow x)
| _ -> raise "Ma che c%$#^# di file mi hai passato?")
| _ -> raise "Please specify input file on command line"
......
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<table>
<row>
......@@ -8,6 +8,9 @@ open Printf
(* dump_event: dumps a single parsing event *)
let dump_event e = ()
(*
let dump_event =
function
E_start_doc(v,sa,dtd) ->
......@@ -31,12 +34,12 @@ let dump_event =
printf "E_error %s\n" (Pxp_types.string_of_exn e)
| E_end_of_stream ->
printf "E_end_of_stream\n"
;;
*)
(* parse: prints the events while parsing the passed string *)
let parse s =
let pull s =
let config = default_config in
let mgr = create_entity_manager config (from_file s) in
let next_event =
......@@ -46,9 +49,15 @@ let parse s =
event := next_event();
match !event with
Some e -> dump_event e
| None -> ()
| None -> ()
done
;;
let () = parse Sys.argv.(1);;
let push s =
process_entity
default_config
(`Entry_document[`Extend_dtd_fully])
(create_entity_manager default_config (from_file s))
dump_event
let () = push Sys.argv.(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment