]> matita.cs.unibo.it Git - helm.git/commitdiff
Wrong xpointers generated. Fixed.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Tue, 25 Jun 2002 08:52:21 +0000 (08:52 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Tue, 25 Jun 2002 08:52:21 +0000 (08:52 +0000)
helm/ocaml/mathql/mQueryUtil.ml

index 97f94f727d073a015b47f47f2c97d4a32582b321..cb60eff629cf5fa90ef1f967e56e00875951178c 100644 (file)
@@ -44,11 +44,6 @@ let str_btoken = function
    | MQBS   -> "*"
    | MQBSS  -> "**"
 
-let str_ftoken = function
-   | MQFC i -> "/" ^ string_of_int i
-   | MQFS   -> "/*"
-   | MQFSS  -> "/**"
-
 let str_prot = function
    | Some s -> s
    | None   -> "*"
@@ -58,21 +53,35 @@ let rec str_body = function
    | head :: tail -> str_btoken head ^ str_body tail 
 
 let str_frag l = 
-   let rec str_fi start = function 
-      | []     -> ""
-      | t :: l -> 
-         (if start then "#1" else "") ^ str_ftoken t ^ str_fi false l
-   in str_fi true l
+ match l with
+    [] -> ""
+  | l ->
+     let str_ftokens =
+      List.fold_left
+       (fun i t ->
+         i ^
+          match t with
+             MQFC i -> "/" ^ string_of_int i
+           | MQFS   -> "/*"
+           | MQFSS  -> "/**"
+       ) "" l
+     in
+      "#xpointer(1" ^ str_ftokens ^ ")"
+;;
 
 let str_tref (p, b, i) = 
    str_prot p ^ ":/" ^ str_body b ^ str_frag i
+;;
 
 let str_uref (u, i) =
-   let rec str_fi start = function 
-      | []     -> ""
-      | i :: l -> 
-         (if start then "#1" else "") ^ string_of_int i ^ str_fi false l
-   in UriManager.string_of_uri u ^ str_fi true i
+ UriManager.string_of_uri u ^
+  match i with
+     [] -> ""
+   | l ->
+     "#xpointer(1" ^
+      List.fold_left (fun i n -> i ^ "/" ^ string_of_int n) "" l ^
+      ")"
+;;
 
 (* raw HTML representation *)