<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/6982dabc6e9541815755c57458ab4117"
  from="Gaurav Chanda &lt;gaurav_chanda@l...&gt;"
  author="Gaurav Chanda"
  date="2002-07-09T08:35:56"
  subject="[Caml-list] Pxp objects inside class definition"
  prev="2002/07/ced740f9b22e4ed570de853782df4585"
  next="2002/07/6d663c04999aebd27b79a847c5db949d"
  next-in-thread="2002/07/6d663c04999aebd27b79a847c5db949d"
  prev-thread="2002/07/ced740f9b22e4ed570de853782df4585"
  next-thread="2002/07/44bb761bf353031a2a1eed29d5966ee0"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Pxp objects inside class definition">
<msg 
  url="2002/07/6982dabc6e9541815755c57458ab4117"
  from="Gaurav Chanda &lt;gaurav_chanda@l...&gt;"
  author="Gaurav Chanda"
  date="2002-07-09T08:35:56"
  subject="[Caml-list] Pxp objects inside class definition">
<msg 
  url="2002/07/6d663c04999aebd27b79a847c5db949d"
  from="Gerd Stolpmann &lt;info@g...&gt;"
  author="Gerd Stolpmann"
  date="2002-07-09T12:20:46"
  subject="Re: [Caml-list] Pxp objects inside class definition">
</msg>
</msg>
</thread>

<contents>
Hello

I am using the Polymorphic XML Parser (PXP) to parse XML documents. I have made 2 files : point.ml and point.mli, which contain simple class definitions.

The file point.mli contains:

open Pxp_yacc ;
open Pxp_document ;
open Pxp_types ;

class type point_sig =
        object
                value mutable x : Pxp_document.node 'a;
        end;

class point : point_sig ;


The file point.ml contains:

open Pxp_yacc ;
open Pxp_document ;
open Pxp_types ;

class type point_sig =
        object
                value mutable x : Pxp_document.node 'a;
        end ;

value def = "&lt;def&gt;&lt;/def&gt;" ;
value def = parse_wfdocument_entity default_config (from_string def) default_spec ;
value defr = def#root ;

class point:point_sig =
        object
                value mutable x = defr;
        end;

I get an error message while compilation. My compilation command is : 
ocamlopt -pp "camlp4r pa_extend.cmo" -I +camlp4 -I Ty/ -I /usr/lib/ocaml/site-lib/netstring -I /usr/lib/ocaml/site-lib/pxp-engine  -I /usr/lib/ocaml/site-lib/pxp-lex-iso88591/ -c point.mli point.ml


The error message is : 

File "point.ml", line 15, characters 8-67:
The class type
  object
    val mutable x :
      ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
  end
is not matched by the class type point_sig
The class type
  object
    val mutable x :
      ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
  end
is not matched by the class type
  object
    val mutable x :
      ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node
  end
The instance variable x has type
  (('a Pxp_document.node as 'b) Pxp_document.extension as 'a)
  Pxp_document.node =
    &lt; add_node : ?force:bool -&gt; 'b -&gt; unit;
      add_pinstr : Pxp_dtd.proc_instruction -&gt; unit;
      append_node : 'b -&gt; unit; attribute : string -&gt; Pxp_types.att_value;
      attribute_names : string list;
      attribute_type : string -&gt; Pxp_types.att_type;
      attributes : (string * Pxp_types.att_value) list;
      attributes_as_nodes : 'b list;
      classify_data_node : 'b -&gt; Pxp_document.data_node_classification;
      comment : string option; complement_attlist : unit -&gt; unit;
      create_data : Pxp_dtd.dtd -&gt; string -&gt; 'b;
      create_element : ?name_pool_for_attribute_values:Pxp_types.pool -&gt;
                       ?position:string * int * int -&gt;
                       ?valcheck:bool -&gt;
                       ?att_values:(string * Pxp_types.att_value) list -&gt;
                       Pxp_dtd.dtd -&gt;
                       Pxp_document.node_type -&gt; (string * string) list -&gt; 'b;
      create_other : ?position:string * int * int -&gt;
                     Pxp_dtd.dtd -&gt; Pxp_document.node_type -&gt; 'b;
      data : string; delete : unit; dtd : Pxp_dtd.dtd;
      dump : Format.formatter -&gt; unit; encoding : Pxp_types.rep_encoding;
      extension : 'a; id_attribute_name : string;
      id_attribute_value : string; idref_attribute_names : string list;
      insert_nodes : ?pos:int -&gt; 'b list -&gt; unit;
      internal_adopt : 'b option -&gt; int -&gt; unit;
      internal_delete : 'b -&gt; unit;
      internal_init : string * int * int -&gt;
                      Pxp_types.pool option -&gt;
                      bool -&gt;
                      Pxp_dtd.dtd -&gt;
                      string -&gt;
                      (string * string) list -&gt;
                      (string * Pxp_types.att_value) list -&gt; unit;
      internal_init_other : string * int * int -&gt;
                            Pxp_dtd.dtd -&gt; Pxp_document.node_type -&gt; unit;
      internal_set_pos : int -&gt; unit; iter_nodes : ('b -&gt; unit) -&gt; unit;
      iter_nodes_sibl : ('b option -&gt; 'b -&gt; 'b option -&gt; unit) -&gt; unit;
      local_validate : ?use_dfa:bool -&gt;
                       ?check_data_nodes:bool -&gt; unit -&gt; unit;
      localname : string; namespace_info : 'a Pxp_document.namespace_info;
      namespace_manager : Pxp_dtd.namespace_manager; namespace_uri :
      string; next_node : 'b; node_path : int list; node_position : int;
      node_type : Pxp_document.node_type; normprefix : string;
      nth_node : int -&gt; 'b; optional_list_attribute : string -&gt; string list;
      optional_string_attribute : string -&gt; string option;
      orphaned_clone : 'b; orphaned_flat_clone : 'b; parent : 'b;
 pinstr : string -&gt; Pxp_dtd.proc_instruction list;
      pinstr_names : string list; position : string * int * int;
      previous_node : 'b;
      quick_set_attributes : (string * Pxp_types.att_value) list -&gt; unit;
      remove : unit -&gt; unit;
      remove_nodes : ?pos:int -&gt; ?len:int -&gt; unit -&gt; unit;
      required_list_attribute : string -&gt; string list;
      required_string_attribute : string -&gt; string;
      reset_attribute : string -&gt; unit; root : 'b;
      set_attribute : ?force:bool -&gt; string -&gt; Pxp_types.att_value -&gt; unit;
      set_attributes : (string * Pxp_types.att_value) list -&gt; unit;
      set_comment : string option -&gt; unit; set_data : string -&gt; unit;
      set_namespace_info : 'a Pxp_document.namespace_info option -&gt; unit;
      set_nodes : 'b list -&gt; unit; sub_nodes : 'b list;
      validate : unit -&gt; unit; validate_attlist : unit -&gt; unit;
      validate_contents : ?use_dfa:bool -&gt;
                          ?check_data_nodes:bool -&gt; unit -&gt; unit;
      write : ?prefixes:string list -&gt;
              ?default:string -&gt;
              Pxp_types.output_stream -&gt; Pxp_types.encoding -&gt; unit &gt;
but is expected to have type
  ('c Pxp_document.node #Pxp_document.extension as 'c) Pxp_document.node =
    &lt; add_node : ?force:bool -&gt; 'c Pxp_document.node -&gt; unit;
      add_pinstr : Pxp_dtd.proc_instruction -&gt; unit;
      append_node : 'c Pxp_document.node -&gt; unit;
      attribute : string -&gt; Pxp_types.att_value;
      attribute_names : string list;
      attribute_type : string -&gt; Pxp_types.att_type;
      attributes : (string * Pxp_types.att_value) list;
      attributes_as_nodes : 'c Pxp_document.node list;
      classify_data_node : 'c Pxp_document.node -&gt;
                           Pxp_document.data_node_classification;
      comment : string option; complement_attlist : unit -&gt; unit;
      create_data : Pxp_dtd.dtd -&gt; string -&gt; 'c Pxp_document.node;
      create_element : ?name_pool_for_attribute_values:Pxp_types.pool -&gt;
                       ?position:string * int * int -&gt;
                       ?valcheck:bool -&gt;
                       ?att_values:(string * Pxp_types.att_value) list -&gt;
                       Pxp_dtd.dtd -&gt;
                       Pxp_document.node_type -&gt;
                       (string * string) list -&gt; 'c Pxp_document.node;
      create_other : ?position:string * int * int -&gt;
                     Pxp_dtd.dtd -&gt;
                     Pxp_document.node_type -&gt; 'c Pxp_document.node;
      data : string; delete : unit; dtd : Pxp_dtd.dtd;
      dump : Format.formatter -&gt; unit; encoding : Pxp_types.rep_encoding;
      extension : 'c; id_attribute_name : string;
      id_attribute_value : string; idref_attribute_names : string list;
      insert_nodes : ?pos:int -&gt; 'c Pxp_document.node list -&gt; unit;
      internal_adopt : 'c Pxp_document.node option -&gt; int -&gt; unit;
      internal_delete : 'c Pxp_document.node -&gt; unit;
      internal_init : string * int * int -&gt;
                      Pxp_types.pool option -&gt;
                      bool -&gt;
                      Pxp_dtd.dtd -&gt;
                      string -&gt;
                      (string * string) list -&gt;
                      (string * Pxp_types.att_value) list -&gt; unit;
      internal_init_other : string * int * int -&gt;
                            Pxp_dtd.dtd -&gt; Pxp_document.node_type -&gt; unit;
      internal_set_pos : int -&gt; unit;
      iter_nodes : ('c Pxp_document.node -&gt; unit) -&gt; unit;
      iter_nodes_sibl : ('c Pxp_document.node option -&gt;
                         'c Pxp_document.node -&gt;
                         'c Pxp_document.node option -&gt; unit) -&gt;
 unit;
      local_validate : ?use_dfa:bool -&gt;
                       ?check_data_nodes:bool -&gt; unit -&gt; unit;
      localname : string; namespace_info : 'c Pxp_document.namespace_info;
      namespace_manager : Pxp_dtd.namespace_manager; namespace_uri :
      string; next_node : 'c Pxp_document.node; node_path : int list;
      node_position : int; node_type : Pxp_document.node_type;
      normprefix : string; nth_node : int -&gt; 'c Pxp_document.node;
      optional_list_attribute : string -&gt; string list;
      optional_string_attribute : string -&gt; string option;
      orphaned_clone : 'c Pxp_document.node;
      orphaned_flat_clone : 'c Pxp_document.node;
      parent : 'c Pxp_document.node;
      pinstr : string -&gt; Pxp_dtd.proc_instruction list;
      pinstr_names : string list; position : string * int * int;
      previous_node : 'c Pxp_document.node;
      quick_set_attributes : (string * Pxp_types.att_value) list -&gt; unit;
      remove : unit -&gt; unit;
      remove_nodes : ?pos:int -&gt; ?len:int -&gt; unit -&gt; unit;
      required_list_attribute : string -&gt; string list;
      required_string_attribute : string -&gt; string;
      reset_attribute : string -&gt; unit; root : 'c Pxp_document.node;
      set_attribute : ?force:bool -&gt; string -&gt; Pxp_types.att_value -&gt; unit;
      set_attributes : (string * Pxp_types.att_value) list -&gt; unit;
      set_comment : string option -&gt; unit; set_data : string -&gt; unit;
      set_namespace_info : 'c Pxp_document.namespace_info option -&gt; unit;
      set_nodes : 'c Pxp_document.node list -&gt; unit;
      sub_nodes : 'c Pxp_document.node list; validate : unit -&gt; unit;
      validate_attlist : unit -&gt; unit;
      validate_contents : ?use_dfa:bool -&gt;
                          ?check_data_nodes:bool -&gt; unit -&gt; unit;
      write : ?prefixes:string list -&gt;
              ?default:string -&gt;
              Pxp_types.output_stream -&gt; Pxp_types.encoding -&gt; unit &gt;
Type 'a = 'a Pxp_document.node Pxp_document.extension
is not compatible with type
  'c =
    &lt; clone : 'c; node : 'c Pxp_document.node;
      set_node : 'c Pxp_document.node -&gt; unit; .. &gt;
make: *** [code] Error 2



I am not being able to define PXP objects inside classes. Could you help me solve this problem ?

Thanks

Gaurav


_____________________________________________________
Supercharge your e-mail with a 25MB Inbox, POP3 Access, No Ads
and NoTaglines --&gt; LYCOS MAIL PLUS.
http://www.mail.lycos.com/brandPage.shtml?pageId=plus 
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

