XAPI

Kevin Grimes k.grimes at liant.com
Tue Jun 24 00:26:27 BST 1997





From: Kevin Grimes at LIANT on 06/23/97 06:30 PM

Limiting the types used in the Java XAPI to basic Java types like int,
boolean, String, plus the Java interfaces that you've actually implemented
in Java (IElement, IXMLProcessor etc.) will make the job of porting the
Java XAPI to IDL easier. InputStream was the first thing I tripped over
when I translated my Java APIs into IDL--to avoid defining an InputStream
interface in IDL I rewrote the member function processDocument to use
String. Here is my version of xml.idl. This is my first use of IDL, and
XML, and Java for that matter, so please let me know if I'm doing something
stupid. I compile this with the MIDL compiler that comes with Microsoft's
Visual Studio. We have C++ and Java clients that implement the
IXMLApplication callbacks or use the IGrove and INode interfaces to
traverse the parse tree.

Regards, Kevin (k.grimes at liant.com)

// xml.idl
[
    uuid (14859300-E953-11d0-B96A-00A024f2C5E0),
    version (0.0),
    helpstring("LXMLProcessor Type Library")
]
library LXMLProcessor
{
    importlib("stdole32.tlb");

    interface INodeList;

    [
        object,
        uuid (14859302-E953-11d0-B96A-00A024f2C5E0),
        helpstring("INode Interface"),
    ]
    interface INode : IDispatch
    {
        HRESULT addChild([in] INode* child);
        HRESULT getChild([in] int i, [out, retval] INode** child);
        HRESULT getChildren([out, retval] INodeList** children);
        HRESULT getNumberOfChildren([out, retval] int* count);
        HRESULT getParent([out, retval] INode** parent);
        HRESULT setParent([in] INode* parent);
    }

    [
        object,
        uuid (14859303-E953-11d0-B96A-00A024f2C5E0),
        helpstring("INodeList Interface"),
    ]
    interface INodeList : IDispatch
    {
        HRESULT addItem([in] INode* item);
        HRESULT getCount([out, retval] int* count);
        HRESULT getItem([in] int i, [out, retval] INode** item);
    }

    [
        object,
        uuid (14859304-E953-11d0-B96A-00A024f2C5E0),
        helpstring("ICharacterData Interface"),
    ]
    interface ICharacterData : IDispatch
    {
        HRESULT toString([out, retval] BSTR* cdata);
    }

    [
        object,
        uuid (14859305-E953-11d0-B96A-00A024f2C5E0),
        helpstring("IElement Interface"),
    ]
    interface IElement : IDispatch
    {
        HRESULT addAttribute([in] BSTR name, [in] BSTR value);
        HRESULT getAttributeValue([in] BSTR name, [out, retval] BSTR*
value);
        HRESULT getId([out, retval] BSTR* id);
        HRESULT getType([out, retval] BSTR* type);
        HRESULT isEmpty([out, retval] VARIANT_BOOL* empty);
        HRESULT setId([in] BSTR id);
        HRESULT setIsEmpty();
        HRESULT toString([out, retval] BSTR* retval);
    }

    [
        object,
        uuid (14859306-E953-11d0-B96A-00A024f2C5E0),
        helpstring("IGrove Interface"),
    ]
    interface IGrove : IDispatch
    {
        HRESULT getDocumentRoot([out, retval] INode** root);
        HRESULT setDocumentRoot([in] INode* root);
    }

    [
        object,
        uuid (14859307-E953-11d0-B96A-00A024f2C5E0),
        helpstring("IXMLApplication Interface"),
    ]
    interface IXMLApplication : IDispatch
    {
        HRESULT doBinaryEntity([in] BSTR systemId,
                                                         [in] BSTR
notationName,
                                                         [in] BSTR
notationSystemId);
        HRESULT doCharacterData([in] BSTR data);
        HRESULT doEmptyElement([in] IElement* e);
        HRESULT doEndOfDocument([in] BSTR docname);
        HRESULT doEndTag([in] IElement* e);
        HRESULT doFatalError([in] BSTR error);
        HRESULT doProcessingInstruction([in] BSTR pi);
        HRESULT doReportableError([in] BSTR error);
        HRESULT doStartOfDocument([in] BSTR docname);
        HRESULT doStartTag([in] IElement* e);
        HRESULT doWarning([in] BSTR warning);
    }

    [
        object,
        uuid (14859308-E953-11d0-B96A-00A024f2C5E0),
        helpstring("IXMLProcessor Interface"),
    ]
    interface IXMLProcessor : IDispatch
    {
        HRESULT buildParseTree([in] VARIANT_BOOL build);
        HRESULT checkValidity([in] VARIANT_BOOL check);
        HRESULT getGrove([out, retval] IGrove** grove);
        HRESULT processExternalEntities([in] VARIANT_BOOL process);
        HRESULT processDocument([in] BSTR filename);
        HRESULT processDocumentURL([in] BSTR spec);
        HRESULT setApplication([in] IXMLApplication* app);
    }

    [
        uuid (1485930A-E953-11d0-B96A-00A024f2C5E0),
        helpstring("Node Class"),
        appobject
    ]
    coclass Node
    {
        interface INode;
    }

    [
        uuid (1485930B-E953-11d0-B96A-00A024f2C5E0),
        helpstring("NodeList Class"),
        appobject
    ]
    coclass NodeList
    {
        interface INodeList;
    }

    [
        uuid (1485930C-E953-11d0-B96A-00A024f2C5E0),
        helpstring("CharacterData Class"),
        appobject
    ]
    coclass CharacterData
    {
        interface INode;
        interface ICharacterData;
    }

    [
        uuid (1485930D-E953-11d0-B96A-00A024f2C5E0),
        helpstring("Element Class"),
        appobject
    ]
    coclass Element
    {
        interface INode;
        interface IElement;
    }

    [
        uuid (1485930E-E953-11d0-B96A-00A024f2C5E0),
        helpstring("Grove Class"),
        appobject
    ]
    coclass Grove
    {
        interface IGrove;
    }

    [
        uuid (1485930F-E953-11d0-B96A-00A024f2C5E0),
        helpstring("XMLApplication Class"),
        appobject
    ]
    coclass XMLApplication
    {
        interface IXMLApplication;
    }

    [
        uuid (14859310-E953-11d0-B96A-00A024f2C5E0),
        helpstring("XMLProcessor Class"),
        appobject
    ]
    coclass XMLProcessor
    {
        interface IXMLProcessor;
    }
};



xml-dev: A list for W3C XML Developers
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To unsubscribe, send to majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
List coordinator, Henry Rzepa (rzepa at ic.ac.uk)




More information about the Xml-dev mailing list