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
27cd3cfe
Commit
27cd3cfe
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2005-03-08 15:27:12 by afrisch] utf-8 BOM
Original author: afrisch Date: 2005-03-08 15:27:12+00:00
parent
37fb0285
Changes
6
Hide whitespace changes
Inline
Side-by-side
runtime/cduce_pxp.ml
View file @
27cd3cfe
...
...
@@ -18,6 +18,21 @@ let pxp_config =
drop_ignorable_whitespace
=
true
}
let
utf8_bom
=
"
\239\187\191
"
let
of_string
s
=
let
enc
,
s
=
if
(
String
.
length
s
>=
3
)
&&
(
String
.
sub
s
0
3
=
utf8_bom
)
then
Some
`Enc_utf8
,
(
String
.
sub
s
3
(
String
.
length
s
-
3
))
else
None
,
s
in
enc
,
new
Netchannels
.
input_string
s
let
of_file
fn
=
let
ic
=
open_in_bin
fn
in
let
buf
=
String
.
create
3
in
really_input
ic
buf
0
3
;
let
e
=
if
buf
=
utf8_bom
then
Some
`Enc_utf8
else
(
seek_in
ic
0
;
None
)
in
e
,
new
Netchannels
.
input_channel
ic
let
channel_of_id
rid
=
let
url
=
...
...
@@ -26,31 +41,25 @@ let channel_of_id rid =
|
_
,
Some
rel
->
rel
|
_
->
raise
Not_competent
in
let
ch
=
let
enc
,
ch
=
if
Url
.
is_url
url
then
new
Netchannels
.
input
_string
(
!
Url
.
load_url
url
)
else
new
Netchannels
.
input_channel
(
open_in_bin
url
)
then
of
_string
(
!
Url
.
load_url
url
)
else
of_file
url
in
ch
,
None
,
Some
{
rid
with
rid_system
=
Some
url
}
ch
,
enc
,
Some
{
rid
with
rid_system
=
Some
url
}
let
alt
=
new
resolve_to_any_obj_channel
~
channel_of_id
()
let
src_of_uri
uri
=
XExtID
(
System
uri
,
None
,
alt
)
let
load_pxp
uri
=
try
let
src
=
XExtID
(
System
uri
,
None
,
alt
)
in
let
mgr
=
create_entity_manager
pxp_config
src
in
let
mgr
=
create_entity_manager
pxp_config
(
src_of_uri
uri
)
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
()
=
...
...
@@ -59,3 +68,4 @@ let () =
"PXP XML parser"
use
let
()
=
Schema_xml
.
src_of_uri
:=
src_of_uri
schema/schema_xml.ml
View file @
27cd3cfe
...
...
@@ -4,6 +4,8 @@ open Schema_pcre
exception
Error
of
string
let
error
s
=
raise
(
Error
s
)
let
src_of_uri
=
ref
(
fun
_
->
failwith
"PXP support required to load XML Schema"
)
type
node
=
(
'
a
Pxp_document
.
node
Pxp_document
.
extension
as
'
a
)
Pxp_document
.
node
...
...
@@ -41,27 +43,8 @@ let new_xsd_config () =
let
node_of
src
=
(
Pxp_tree_parser
.
parse_wfdocument_entity
(
new_xsd_config
()
)
src
spec
)
#
root
open
Pxp_types
open
Pxp_reader
let
channel_of_id
rid
=
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
node_of_uri
uri
=
try
node_of
(
XExtID
(
System
uri
,
None
,
alt
)
)
try
node_of
(
!
src_of_uri
uri
)
with
exn
->
raise
(
Location
.
Generic
(
Pxp_types
.
string_of_exn
exn
))
let
_may_attr
name
n
=
...
...
schema/schema_xml.mli
View file @
27cd3cfe
...
...
@@ -4,6 +4,8 @@ exception Error of string
module
Node
:
Set
.
OrderedType
type
node
=
Node
.
t
val
src_of_uri
:
(
string
->
Pxp_types
.
source
)
ref
val
node_of_uri
:
string
->
node
val
_may_attr
:
string
->
node
->
Utf8
.
t
option
...
...
web/manual/expressions.xml
View file @
27cd3cfe
...
...
@@ -731,16 +731,27 @@ of type <code>%%T%%</code>. The reference is actually a value of type
</p>
<p>
T
hree
syntactic sugar constructions are provided to facilitate
T
wo
syntactic sugar constructions are provided to facilitate
the use of references:
</p>
<sample>
!%%e%% === %%e%%.get [] {{ Dereferencing }}
%%e1%% := %%e2%% === %%e1%%.set %%e2%% {{ Assignment }}
</sample>
<p>
An expression of type
<code>
[]
</code>
is often considered
as a command and followed by another expression. The sequencing
operator gives a syntax for that:
</p>
<sample>
%%e1%% ; %%e2%% === let [] = %%e1%% in %%e2%% {{Sequencing}}
</sample>
</box>
...
...
@@ -756,11 +767,11 @@ select %%e%% from
%%p2%% in %%e2%%,
:
%%pn%% in %%en%%
where %%
b
%%
where %%
c1%% and ... and %%cn
%%
]]>
</sample>
<p>
where
<code>
%%e%%
</code>
is an expression
<code>
%%
b
%%
</code>
a boolean
expression, the
<code>
%%pi%%
</code>
's are patterns, and the
where
<code>
%%e%%
</code>
is an expression
, the
<code>
%%
ci
%%
</code>
are boolean
expression
s
, the
<code>
%%pi%%
</code>
's are patterns, and the
<code>
%%ei%%
</code>
's are sequence expressions.
</p>
<p>
...
...
@@ -770,5 +781,11 @@ transform is that queries are automatically optimized by applying classical
logic SQL optimization techniques (this automatic optimization can be
disabled).
</p>
<p>
The built-in optimizer is free to move boolean conditions around to
evaluate them as soon as possible. As warning is issued if a
condition does not depend on any of the variables captured by the
patterns.
</p>
</box>
</page>
web/manual/schema.xml
View file @
27cd3cfe
...
...
@@ -633,4 +633,33 @@ val xml : Any = <ignored_tag From="fake@microsoft.com">[
</p>
</box>
<box
title=
"Unsupported XML Schema features"
link=
"nonsupp"
>
<p>
The support for XML Schema embedded in CDuce does not attempt
to cover the full XML Schema specification. In particular,
imported schemas are not checked to be valid. You can use
for instance this
<a
href=
"http://apps.gotdotnet.com/xmltools/xsdvalidator/"
>
on-line validator
</a>
to check validity of a schema.
</p>
<p>
Also, some features from the XML Schema specification are not or
only partially supported. Here is a non-exhaustive list of limitations:
</p>
<ul>
<li>
Substitution groups.
</li>
<li>
Some facets (pattern, totalDigits, fractionDigits).
</li>
<li>
<tt>
<
redefine>
</tt>
(inclusion of an XML Schema with modifications).
</li>
<li>
<tt>
xsi:type
</tt>
.
</li>
</ul>
</box>
</page>
web/manual/types_patterns.xml
View file @
27cd3cfe
...
...
@@ -258,10 +258,8 @@ E.g.: <code>[ 1 2 3 ] @ [ 4 5 6 ]</code> evaluates to
It is possible to specify a terminator different from
<code>
`nil
</code>
;
for instance
<code>
[ 1 2 3 4 ; %%q%% ]
</code>
denotes
<code>
(1,(2,(3,(4,%%q%%))))
</code>
,
and is equivalent to
(but more efficient than):
and is equivalent to
<code>
[ 1 2 3 4 ] @ %%q%%
</code>
.
Consequently, a pair
<code>
(%%e1%%,%%e2%%)
</code>
can also
be written
<code>
[ %%e1%%; %%e2%% ]
</code>
.
</p>
<p>
...
...
@@ -344,6 +342,18 @@ in a pattern, e.g.: <code>[ x::Int* ; _ ]</code>, which
is equivalent to
<code>
[ x::Int* _* ]
</code>
.
</p>
<p>
If it possible in some circumstances to use the
<code>
@
</code>
operator (sequence concatenation) on types, including in recursive
definitions. E.g.:
</p>
<sample>
<![CDATA[
type t = [ <a>
(t @ t) ? ] (* [s?] where s=
<a>
[ s? s? ] *)
type x = [ Int* ]
type y = x @ [ Char* ] (* [ Int* Char* ] *)
]]>
</sample>
</section>
</box>
...
...
@@ -444,6 +454,20 @@ it is possible to omit it. E.g.: <code>{ x; y = b; z }</code>
is equivalent to
<code>
{ x = x; y = b; z = z }
</code>
.
</p>
<p>
The
<code>
+
</code>
operator (record concatenation, with priority given
to the right argument in case of overlapping) is available on record
types and patterns. This operator can be used to make a close
record type/pattern open, or to add fields:
</p>
<sample>
type t = { a=Int b=Char }
type s = t + {..} (* { a=Int b=Char .. }
type u = s + { c=Float } (* { a=Int b=Char c=Float .. } *)
type v = t + { c=Float } (* { a=Int b=Char c=Float } *)
</sample>
</box>
<box
title=
"XML elements"
link=
"xml"
>
...
...
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