Use that prefix in the naive tree implementation for attribute nodes.
(***********************************************************************)
(*
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-02-07 09:59:37 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-02-14 16:14:00 CET by Kim Nguyen>
let text_string = QName.to_string QName.text
let attr_map_string = QName.to_string QName.attribute_map
let text_string = QName.to_string QName.text
let attr_map_string = QName.to_string QName.attribute_map
+ let att_pref = QName.node QName.attribute_prefix
let rec start_element_handler parser_ ctx tag attr_list =
do_text parser_ ctx;
let parent = top ctx in
let rec start_element_handler parser_ ctx tag attr_list =
do_text parser_ ctx;
let parent = top ctx in
end_element_handler parser_ ctx attr_map_string
and do_attribute parser_ ctx (att, value) =
end_element_handler parser_ ctx attr_map_string
and do_attribute parser_ ctx (att, value) =
- let att_tag = " " ^ att in
+ let att_tag = att_pref ^ att in
start_element_handler parser_ ctx att_tag [];
start_element_handler parser_ ctx text_string [];
let n = top ctx in n.data <- value;
start_element_handler parser_ ctx att_tag [];
start_element_handler parser_ ctx text_string [];
let n = top ctx in n.data <- value;
(***********************************************************************)
(*
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-01-30 19:07:38 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-02-14 16:14:44 CET by Kim Nguyen>
*)
include Hcons.Make (struct
*)
include Hcons.Make (struct
let document_fragment = of_string "#document-fragment"
let attribute_map = of_string "#attribute-map"
let nil = of_string "#"
let document_fragment = of_string "#document-fragment"
let attribute_map = of_string "#attribute-map"
let nil = of_string "#"
+let attribute_prefix = of_string "@"
+let has_attribute_prefix s =
+ let s = node s in
+ String.length s > 0 && s.[0] = '@'
+
+let add_attribute_prefix s =
+ of_string ("@" ^ (node s))
(***********************************************************************)
(*
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-01-30 19:07:34 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-02-14 16:15:23 CET by Kim Nguyen>
*)
(** Implementation of qualified names as hashconsed strings *)
*)
(** Implementation of qualified names as hashconsed strings *)
val comment : t
(** Represents the QName of a comment node. Equivalent to
val comment : t
(** Represents the QName of a comment node. Equivalent to
- [of_string "#cdata-section"]
*)
val document_fragment : t
*)
val document_fragment : t
(** Represents the QName of a nil node. Equivalent to
[of_string "#"]
*)
(** Represents the QName of a nil node. Equivalent to
[of_string "#"]
*)
+
+val attribute_prefix : t
+(** Represents a prefix that may be prepended to attribute name
+ to distinguish them from element names
+*)
+
+val has_attribute_prefix : t -> bool
+(** Tests whether the given QName starts with the attribute prefix
+*)
+
+val add_attribute_prefix : t -> t
+(** Prepends the attribute_prefix to the given QName *)