]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/urimanager/uriManager.ml
renamed Http_client to Http_user_agent to avoid clashes with Gerd's
[helm.git] / helm / ocaml / urimanager / uriManager.ml
index 6dad8ddef6c4095e4764497f21150d53c4e649e2..3028cf2b9b37e5d527bf35e6d89a07ed23ea7f72 100644 (file)
@@ -67,7 +67,7 @@ let mk_prefixes str =
   function
      [he] ->
       let prefix_uri = curi ^ "/" ^ he
-      and name = List.hd (Str.split (Str.regexp "\.") he) in
+      and name = List.hd (Str.split (Str.regexp "\\.") he) in
        [ normalize prefix_uri ; name ]
    | he::tl ->
       let prefix_uri = curi ^ "/" ^ he in
@@ -97,8 +97,8 @@ let uri_of_string str =
 let cicuri_of_uri uri =
  let completeuri = string_of_uri uri in
   let newcompleteuri = 
-   (Str.replace_first (Str.regexp "\.types$") ""
-    (Str.replace_first (Str.regexp "\.ann$") "" completeuri))
+   (Str.replace_first (Str.regexp "\\.types$") ""
+    (Str.replace_first (Str.regexp "\\.ann$") "" completeuri))
   in
    if completeuri = newcompleteuri then
     uri
@@ -110,7 +110,7 @@ let cicuri_of_uri uri =
 
 let annuri_of_uri uri =
  let completeuri = string_of_uri uri in
-  if Str.string_match (Str.regexp ".*\.ann$") completeuri 0 then
+  if Str.string_match (Str.regexp ".*\\.ann$") completeuri 0 then
    uri
   else
    let newuri = Array.copy uri in
@@ -119,12 +119,12 @@ let annuri_of_uri uri =
 ;;
 
 let uri_is_annuri uri =
- Str.string_match (Str.regexp ".*\.ann$") (string_of_uri uri) 0
+ Str.string_match (Str.regexp ".*\\.ann$") (string_of_uri uri) 0
 ;;
 
 let bodyuri_of_uri uri =
  let struri = string_of_uri uri in
-  if Str.string_match (Str.regexp ".*\.con$") (string_of_uri uri) 0 then
+  if Str.string_match (Str.regexp ".*\\.con$") (string_of_uri uri) 0 then
    let newuri = Array.copy uri in
     newuri.(Array.length uri - 2) <- struri ^ ".body" ;
     Some newuri
@@ -138,3 +138,14 @@ let innertypesuri_of_uri uri =
    newuri.(Array.length cicuri - 2) <- (string_of_uri cicuri) ^ ".types" ;
    newuri
 ;;
+
+type uriref = uri * (int list)
+
+let string_of_uriref (uri, fi) =
+   let str = string_of_uri uri in
+   let xp t = "#xpointer(1/" ^ string_of_int (t + 1) in
+   match fi with
+      | []          -> str 
+      | [t]         -> str ^ xp t ^ ")" 
+      | t :: c :: _ -> str ^ xp t ^ "/" ^ string_of_int c ^ ")" 
+