-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fea7e77
commit 348eb69
Showing
6 changed files
with
84 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
(library | ||
(name needlework_scenario_generator) | ||
(libraries dolog)) | ||
(libraries xml-light dolog)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module Common = Common | ||
|
||
module Gen = Gen | ||
|
||
module XmlUtil = XmlUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
open Common | ||
|
||
type xml = Xml.xml | ||
type t = xml | ||
|
||
let parse_file filename = Xml.parse_file filename | ||
|
||
let to_string = Xml.to_string | ||
let children = Xml.children | ||
(*let find_child tag xml = | ||
Xml.children xml | ||
|> List.find_opt (fun xml -> Xml.tag xml = tag) | ||
let find_child_data tag xml = | ||
Xml.children xml | ||
|> List.find_opt (fun xml -> Xml.tag xml = tag) | ||
|> Option.map Xml.children | ||
|> Option.map List.hd | ||
|> Option.map Xml.pcdata | ||
let get_child tag xml = | ||
Xml.children xml | ||
|> List.find_opt (fun xml -> Xml.tag xml = tag) | ||
|> function | ||
| None -> | ||
failwith (!%"get_child: tag '%s' not found." tag) | ||
| Some xml -> xml | ||
*) | ||
let text xml = try Xml.children xml |> List.hd |> Xml.pcdata with | ||
| e -> prerr_endline (!%"Reader.text: %s: %s" (Printexc.to_string e) (Xml.to_string xml)); | ||
raise e | ||
(* | ||
let get_child_data tag xml = | ||
find_child_data tag xml | ||
|> function | ||
| None -> failwith (!%"get_child_data: tag '%s' not found." tag) | ||
| Some xml -> xml | ||
let get_child_data_list tag xml = | ||
Xml.children xml | ||
|> List.filter (fun xml -> Xml.tag xml = tag) | ||
|> List.map Xml.pcdata | ||
let has tag xml = | ||
Xml.children xml | ||
|> List.exists (fun xml -> Xml.tag xml = tag) | ||
*) | ||
|
||
let (/) xml tag = Xml.children xml |> List.filter (fun xml -> Xml.tag xml = tag) | ||
|
||
let (//) xml tag : xml = | ||
Xml.children xml | ||
|> List.find (fun xml -> Xml.tag xml = tag) | ||
|
||
let (//?) xml tag : xml option = | ||
Xml.children xml | ||
|> List.find_opt (fun xml -> Xml.tag xml = tag) | ||
|
||
let (/@) xml attr = Xml.attrib xml attr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type xml | ||
type t = xml | ||
|
||
val parse_file : string -> t | ||
val children : t -> t list | ||
|
||
val to_string : t -> string | ||
|
||
val (//) : t -> string -> t | ||
val (//?) : t -> string -> t option | ||
val (/) : t -> string -> t list | ||
val (/@) : t -> string -> string | ||
val text : t -> string |