testxpath.cpp File Reference

Go to the source code of this file.

Classes

struct  XpathTest
 Phoebe DOM Implementation. More...

Typedefs

typedef org::w3c::dom::Node Node
 Phoebe DOM Implementation.
typedef org::w3c::dom::NodePtr NodePtr
typedef org::w3c::dom::NodeList NodeList
typedef org::w3c::dom::DOMString DOMString
typedef org::w3c::dom::Document Document
typedef org::w3c::dom::DocumentPtr DocumentPtr
typedef
org::w3c::dom::io::StdWriter 
StdWriter
typedef
org::w3c::dom::ls::DOMImplementationLSImpl 
DOMImplementationLSImpl
typedef
org::w3c::dom::ls::LSSerializer 
LSSerializer
typedef org::w3c::dom::ls::LSOutput LSOutput
typedef org::w3c::dom::ls::LSInput LSInput
typedef org::w3c::dom::ls::LSParser LSParser
typedef
org::w3c::dom::xpath::XPathParser 
XPathParser

Functions

bool doStringTest (const char *str)
bool doStringTests ()
bool dumpDoc (DocumentPtr doc)
bool doXmlTest (XpathTest *xpt)
bool doXmlTests ()
bool doTests ()
int main (int argc, char **argv)

Variables

XpathTest xpathTests []

Typedef Documentation

Definition at line 43 of file testxpath.cpp.

Definition at line 44 of file testxpath.cpp.

Definition at line 42 of file testxpath.cpp.

Definition at line 49 of file testxpath.cpp.

Definition at line 48 of file testxpath.cpp.

Definition at line 50 of file testxpath.cpp.

Definition at line 47 of file testxpath.cpp.

Phoebe DOM Implementation.

This is a C++ approximation of the W3C DOM model, which follows fairly closely the specifications in the various .idl files, copies of which are provided for reference. Most important is this one:

http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html

Authors: Bob Jamison

Copyright (C) 2006-2008 Bob Jamison

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition at line 39 of file testxpath.cpp.

Definition at line 41 of file testxpath.cpp.

Definition at line 40 of file testxpath.cpp.

Definition at line 45 of file testxpath.cpp.

Definition at line 51 of file testxpath.cpp.


Function Documentation

bool doStringTest ( const char *  str  ) 

Definition at line 1336 of file testxpath.cpp.

References org::w3c::dom::xpath::XPathParser::parse(), org::w3c::dom::xpath::XPathParser::setDebug(), and xp.

Referenced by doStringTests().

{
    XPathParser xp;
    xp.setDebug(true);

    if (!xp.parse(str))
        return false;


    return true;
}

bool doStringTests (  ) 

Definition at line 1350 of file testxpath.cpp.

References doStringTest(), and XpathTest::xpathStr.

{
    for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++)
        {
        if (!doStringTest(xpt->xpathStr))
            return false;
        }
    return true;
}

bool doTests (  ) 

Definition at line 1411 of file testxpath.cpp.

References doXmlTests().

{
    /*
    if (!doStringTests())
        {
        printf("## Failed string tests\n");
        return false;
        }
    */
    if (!doXmlTests())
        {
        printf("## Failed xml tests\n");
        return false;
        }
    return true;
}

bool doXmlTest ( XpathTest xpt  ) 

Definition at line 1373 of file testxpath.cpp.

References org::w3c::dom::ls::DOMImplementationLSImpl::createLSInput(), org::w3c::dom::ls::DOMImplementationLSImpl::createLSParser(), dxf_input::doc, org::w3c::dom::xpath::XPathParser::evaluate(), org::w3c::dom::NodeList::getLength(), Barcode::Code39Ext::i, org::w3c::dom::NodeList::item(), n, org::w3c::dom::ls::LSParser::parse(), dxf_input::parser, org::w3c::dom::xpath::XPathParser::setDebug(), org::w3c::dom::ls::LSInput::setStringData(), XpathTest::xml, xp, and XpathTest::xpathStr.

Referenced by doXmlTests().

{
    printf("################################################################\n");

    //### READ
    DOMImplementationLSImpl domImpl;
    LSInput input = domImpl.createLSInput();
    LSParser &parser = domImpl.createLSParser(0, "");
    input.setStringData(xpt->xml);
    DocumentPtr doc = parser.parse(input);

    //### XPATH
    XPathParser xp;
    xp.setDebug(true);

    DOMString xpathStr = xpt->xpathStr;
    NodeList list = xp.evaluate(doc, xpathStr);
    for (unsigned int i=0 ; i<list.getLength() ; i++)
        {
        NodePtr n = list.item(i);
        printf("@@ node: %s\n", n->getNodeName().c_str());
        }

    //dumpDoc(doc);

    return true;
}

bool doXmlTests (  ) 

Definition at line 1401 of file testxpath.cpp.

References doXmlTest(), and XpathTest::xpathStr.

Referenced by doTests().

{
    for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++)
        {
        if (!doXmlTest(xpt))
            return false;
        }
    return true;
}

int main ( int  argc,
char **  argv 
)

Definition at line 1430 of file testxpath.cpp.

References doTests().

{
    doTests();
    return 0;
}


Variable Documentation

Definition at line 62 of file testxpath.cpp.