XML Object

Download XML Explorer executable

back to main page

 

XML Object is based upon
EXPAT bindings by:

Intelligent Systems Research
5313 N. Kenmore Suite 3A Chicago IL 60640 USA
voice: +(1) 773-989-0426 FAX: +(1) 773-989-0427
email:info@xmlmethods.com
http://www.xmlmethods.com


The EXPAT project has been modified to incorporate Visual Prolog Object Oriented Programming. EXPAT XML parser handlers creates XML objects and links them together into hierarchy of objects and returns reference to the Root object. This Root XML Object can be used to scan XML tree and destroy XML Object. The delete procedure performs cascade deletion of linked XML objects.

To include XML Object - open your project.inc file with VP Studio Setup utility and checkout necessary options:

The sample application allows to create XML Object, print it's structure and access XML hierarchy with Visual Prolog. The PIE Scanner was used to parse some XML parameters. Sample application works as a XML Explorer, can change XML values and can save them back to XML file.

We also have this XML object ported into other Visual Prolog applications such as  Prolog Inference Engine (Desktop and CGI versions).

 

Include:

Download XML explorer project

The XML Object has been implemented via following declarations:

CLASS     xml_object
predicates
procedure    new(xml_object PARENT)
procedure    delete()
procedure    xml_data(STRING NAME, STRING VALUE) - (i,i),(o,o),(i,o)
nondeterm    xml_val(STRING NAME, STRING VALUE) - (i,i),(o,o),(i,o)
procedure    link_xml(xml_object CHILD) - (i)
procedure    unlink_xml((xml_object CHILD) - (i)
        xml_parent(xml_object PARENT) - (o)
nondeterm    xml_child(xml_object CHILD) - (o)
protected facts
determ    parent(xml_object PARENT)
determ    data(STRING NAME, STRING VALUE)
    value(STRING NAME, STRING VALUE)
    child(xml_object CHILD)
ENDCLASS    xml_object

Sample code for XML object printing:

xml_print(OBJECT):-
    OBJECT:xml_data(OBJECTName,OBJECTValue),
    xml_print_name(OBJECT,OBJECTName,OBJECTValue),
    OBJECT:xml_child(CHILD),
    xml_print(CHILD),
    fail.
xml_print(OBJECT):-
    OBJECT:xml_data(OBJECTName,_),
    write("\n</",OBJECTName,">").

xml_print_name(_,xml_default_name,OBJECTValue):-write(OBJECTValue),!.
xml_print_name(OBJECT,OBJECTName,OBJECTValue):-
    not(OBJECT:xml_val(_,_)),
    write("\n<",OBJECTName,">",OBJECTValue),
    !.
xml_print_name(OBJECT,OBJECTName,OBJECTValue):-
    OBJECT:xml_val(_,_),
    write("<",OBJECTName," "),
    xml_print_values(OBJECT),
    write(">"),
    !.

xml_print_values(OBJECT):-
    OBJECT:xml_val(Name,Value),
    write(" ",Name,"=\"",Value,"\""),
    fail.
xml_print_values(_).


Copyright 1998-2000 EDMGROUP (Australia)

Last Updated: March 20, 2002