List.iter (do_attribute parser_ ctx) attr_list
and do_attribute parser_ ctx (att, value) =
- let att_tag = QName.to_string (QName.attribute (QName.of_string att)) in
- start_element_handler parser_ ctx att_tag [];
+ start_element_handler parser_ ctx att [];
let n = top ctx in
n.data <- value;
n.kind <- Tree.NodeKind.Attribute;
- end_element_handler parser_ ctx att_tag
+ end_element_handler parser_ ctx att
and consume_closing ctx n =
if n.next_sibling != dummy then
and processing_instruction_handler parser_ ctx tag data =
do_text parser_ ctx;
- let pi = QName.to_string
- (QName.processing_instruction (QName.of_string tag))
- in
- start_element_handler parser_ ctx pi [];
+ start_element_handler parser_ ctx tag [];
let node = top ctx in
node.data <- data;
node.kind <- Tree.NodeKind.ProcessingInstruction;
- end_element_handler parser_ ctx pi
+ end_element_handler parser_ ctx tag
let character_data_handler _parser ctx text =
let rec print_attributes ?(sep=true) out tree_ node =
if (node.kind == Tree.NodeKind.Attribute) then
- let tag = QName.to_string (QName.remove_prefix node.tag) in
+ let tag = QName.to_string node.tag in
if sep then output_char out ' ';
output_string out tag;
output_string out "=\"";
output_string out "-->"
| ProcessingInstruction ->
output_string out "<?";
- output_string out (QName.to_string (QName.remove_prefix node.tag));
+ output_string out (QName.to_string node.tag);
output_char out ' ';
output_string out node.data;
output_string out "?>"
let compile_axis_test axis (test,kind) phi trans states =
let q = State.next () in
let phi = match kind with
- Tree.NodeKind.Node -> phi
- | _ -> phi %% F.is kind
+ Tree.NodeKind.Node -> phi
+ | _ -> phi %% F.is kind
in
let phi', trans', states' =
match axis with
aphi %% ephi, etrans, estates) (phi1, trans1, states1) elist
(**
- Compile the top-level XPath query in reverse (doing downward
+ Compile the top-level XPath query in reverse (going downward
to the last top-level state):
- /a0::t0[p0]/.../an-1::tn-1[pn-1]/an::tn[pn] becomes:
+ /a0::t0[p0]/../an-1::tn-1[pn-1]/an::tn[pn] becomes:
self::node()[ pn and
self::tn[pn]/inv(an)::(tn-1)[pn-1]/.../inv(a1)::t0[p0]/inv(a0)::document()]
(* Only select attribute nodes if the previous axis
is attribute *)
let phi0 =
- if axis != Attribute then
+ if axis != Attribute && kind == Tree.NodeKind.Node then
phi0 %% (F.not_ F.is_attribute)
else phi0
in
match ll with
[] ->
- let phi1, trans1, states1 =
- List.fold_left (fun (aphi, atrans, astates) e ->
+ let phi1, trans1, states1 =
+ List.fold_left (fun (aphi, atrans, astates) e ->
let ephi, etrans, estates = compile_expr e atrans astates in
aphi %% ephi, etrans, estates) (phi0, trans0, states0) elist
- in
- let _, trans2, states2 =
- compile_axis_test Self (test,kind) phi1 trans1 states1
- in
- let marking_state =
- StateSet.choose (StateSet.diff states2 states1)
- in
- marking_state, trans2, states2
+ in
+ let _, trans2, states2 =
+ compile_axis_test Self (test,kind) phi1 trans1 states1
+ in
+ let marking_state =
+ StateSet.choose (StateSet.diff states2 states1)
+ in
+ marking_state, trans2, states2
| _ ->
- let phi1, trans1, states1 =
- compile_axis_test Self (test,kind) phi0 trans0 states0
- in
- let phi2, trans2, states2 =
- List.fold_left (fun (aphi, atrans, astates) e ->
+ let phi1, trans1, states1 =
+ compile_axis_test Self (test,kind) phi0 trans0 states0
+ in
+ let phi2, trans2, states2 =
+ List.fold_left (fun (aphi, atrans, astates) e ->
let ephi, etrans, estates = compile_expr e atrans astates in
aphi %% ephi, etrans, estates) (phi1, trans1, states1) elist
- in
- loop ll trans2 states2 phi2
+ in
+ loop ll trans2 states2 phi2
in
let starting = State.next () in
let phi0, trans0, states0 =