Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
61a1c95a
Commit
61a1c95a
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2005-03-08 14:36:53 by afrisch] New PXP resolver
Original author: afrisch Date: 2005-03-08 14:36:53+00:00
parent
138e07ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
parser/url.mli
View file @
61a1c95a
type
url
=
Filename
of
string
|
Url
of
string
val
is_url
:
string
->
bool
val
process
:
string
->
url
val
local
:
string
->
string
->
string
...
...
runtime/cduce_pxp.ml
View file @
61a1c95a
...
...
@@ -19,32 +19,38 @@ let pxp_config =
}
let
get_uri
uri
=
match
Url
.
process
uri
with
|
Url
.
Filename
s
->
Url
.
load_file
s
|
Url
.
Url
s
->
s
let
channel_of_id
rid
=
match
rid
.
rid_system_base
,
rid
.
rid_system
with
|
Some
base
,
Some
local
->
let
uri
=
Url
.
local
base
local
in
(* Printf.printf "base=%s local=%s ==> %s\n" base local uri; *)
let
ch
=
new
Netchannels
.
input_string
(
get_uri
uri
)
in
let
id
=
{
rid
with
rid_system
=
Some
uri
}
in
ch
,
None
,
Some
id
|
_
->
raise
Not_competent
let
alt
=
[
new
resolve_to_any_obj_channel
~
channel_of_id
()
]
let
url
=
match
rid
.
rid_system_base
,
rid
.
rid_system
with
|
Some
base
,
Some
rel
->
Url
.
local
base
rel
|
_
,
Some
rel
->
rel
|
_
->
raise
Not_competent
in
let
ch
=
if
Url
.
is_url
url
then
new
Netchannels
.
input_string
(
!
Url
.
load_url
url
)
else
new
Netchannels
.
input_channel
(
open_in_bin
url
)
in
ch
,
None
,
Some
{
rid
with
rid_system
=
Some
url
}
let
alt
=
new
resolve_to_any_obj_channel
~
channel_of_id
()
let
load_pxp
uri
=
try
let
src
=
from_string
~
alt
~
system_id
:
uri
(
get_uri
uri
)
in
let
src
=
XExtID
(
System
uri
,
None
,
alt
)
in
let
mgr
=
create_entity_manager
pxp_config
src
in
process_entity
pxp_config
(
`Entry_document
[
`Extend_dtd_fully
])
mgr
pxp_handle_event
;
with
exn
->
raise
(
Location
.
Generic
(
Pxp_types
.
string_of_exn
exn
))
(*
let channel_or_url id url =
let data = !Url.load_url (Neturl.string_of_url url) in
let ch = new Netchannels.input_string data in
(data, None, None)
*)
let
use
()
=
Load_xml
.
xml_parser
:=
load_pxp
let
()
=
...
...
runtime/cduce_pxp.mli
View file @
61a1c95a
val
use
:
unit
->
unit
(* Call this function from a stand-alone OCaml program
to activate PXP *)
schema/schema_parser.ml
View file @
61a1c95a
...
...
@@ -618,7 +618,7 @@ let schema_of_uri uri =
i
"http://www.w3.org/2001/xml.xsd"
|
Some
ns
->
print_endline
(
"Import with no schemaLocation but a namespace:"
^
(
Utf8
.
get_str
ns
));
print_endline
"Trying to use
the
namespace as
a
URI..."
;
print_endline
"Trying to use namespace as URI..."
;
i
(
Utf8
.
get_str
ns
)
|
_
->
print_endline
"Import ignored, no schemaLocation"
)
...
...
schema/schema_xml.ml
View file @
61a1c95a
...
...
@@ -44,24 +44,24 @@ let node_of src =
open
Pxp_types
open
Pxp_reader
let
get_uri
uri
=
match
Url
.
process
uri
with
|
Url
.
Filename
s
->
Url
.
load_file
s
|
Url
.
Url
s
->
s
let
channel_of_id
rid
=
match
rid
.
rid_system_base
,
rid
.
rid_system
with
|
Some
base
,
Some
local
->
let
uri
=
Url
.
local
base
local
in
let
ch
=
new
Netchannels
.
input_string
(
get_uri
uri
)
in
let
id
=
{
rid
with
rid_system
=
Some
uri
}
in
ch
,
None
,
Some
id
|
_
->
raise
Not_competent
let
url
=
match
rid
.
rid_system_base
,
rid
.
rid_system
with
|
Some
base
,
Some
rel
->
Url
.
local
base
rel
|
_
,
Some
rel
->
rel
|
_
->
raise
Not_competent
in
let
ch
=
if
Url
.
is_url
url
then
new
Netchannels
.
input_string
(
!
Url
.
load_url
url
)
else
new
Netchannels
.
input_channel
(
open_in_bin
url
)
in
ch
,
None
,
Some
{
rid
with
rid_system
=
Some
url
}
let
alt
=
[
new
resolve_to_any_obj_channel
~
channel_of_id
()
]
let
alt
=
new
resolve_to_any_obj_channel
~
channel_of_id
()
let
node_of_uri
uri
=
try
node_of
(
from_string
~
alt
~
system_id
:
uri
(
get_uri
uri
))
try
node_of
(
XExtID
(
System
uri
,
None
,
alt
))
with
exn
->
raise
(
Location
.
Generic
(
Pxp_types
.
string_of_exn
exn
))
let
_may_attr
name
n
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment