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
| typedef org::w3c::dom::Document Document |
Definition at line 43 of file testxpath.cpp.
Definition at line 44 of file testxpath.cpp.
Definition at line 46 of file testxpath.cpp.
| typedef org::w3c::dom::DOMString DOMString |
Definition at line 42 of file testxpath.cpp.
| typedef org::w3c::dom::ls::LSInput LSInput |
Definition at line 49 of file testxpath.cpp.
| typedef org::w3c::dom::ls::LSOutput LSOutput |
Definition at line 48 of file testxpath.cpp.
| typedef org::w3c::dom::ls::LSParser LSParser |
Definition at line 50 of file testxpath.cpp.
Definition at line 47 of file testxpath.cpp.
| typedef org::w3c::dom::Node Node |
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.
| typedef org::w3c::dom::NodeList NodeList |
Definition at line 41 of file testxpath.cpp.
| typedef org::w3c::dom::NodePtr NodePtr |
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().
01337 { 01338 XPathParser xp; 01339 xp.setDebug(true); 01340 01341 if (!xp.parse(str)) 01342 return false; 01343 01344 01345 return true; 01346 }
| bool doStringTests | ( | ) |
Definition at line 1350 of file testxpath.cpp.
References doStringTest(), and XpathTest::xpathStr.
01351 { 01352 for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++) 01353 { 01354 if (!doStringTest(xpt->xpathStr)) 01355 return false; 01356 } 01357 return true; 01358 }
| bool doTests | ( | ) |
Definition at line 1411 of file testxpath.cpp.
References doXmlTests().
01412 { 01413 /* 01414 if (!doStringTests()) 01415 { 01416 printf("## Failed string tests\n"); 01417 return false; 01418 } 01419 */ 01420 if (!doXmlTests()) 01421 { 01422 printf("## Failed xml tests\n"); 01423 return false; 01424 } 01425 return true; 01426 }
| 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().
01374 { 01375 printf("################################################################\n"); 01376 01377 //### READ 01378 DOMImplementationLSImpl domImpl; 01379 LSInput input = domImpl.createLSInput(); 01380 LSParser &parser = domImpl.createLSParser(0, ""); 01381 input.setStringData(xpt->xml); 01382 DocumentPtr doc = parser.parse(input); 01383 01384 //### XPATH 01385 XPathParser xp; 01386 xp.setDebug(true); 01387 01388 DOMString xpathStr = xpt->xpathStr; 01389 NodeList list = xp.evaluate(doc, xpathStr); 01390 for (unsigned int i=0 ; i<list.getLength() ; i++) 01391 { 01392 NodePtr n = list.item(i); 01393 printf("@@ node: %s\n", n->getNodeName().c_str()); 01394 } 01395 01396 //dumpDoc(doc); 01397 01398 return true; 01399 }
| bool doXmlTests | ( | ) |
Definition at line 1401 of file testxpath.cpp.
References doXmlTest(), and XpathTest::xpathStr.
Referenced by doTests().
01402 { 01403 for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++) 01404 { 01405 if (!doXmlTest(xpt)) 01406 return false; 01407 } 01408 return true; 01409 }
| bool dumpDoc | ( | DocumentPtr | doc | ) |
Definition at line 1360 of file testxpath.cpp.
References org::w3c::dom::ls::DOMImplementationLSImpl::createLSOutput(), org::w3c::dom::ls::DOMImplementationLSImpl::createLSSerializer(), Geom::output(), org::w3c::dom::ls::LSOutput::setCharacterStream(), and org::w3c::dom::ls::LSSerializer::write().
01361 { 01362 DOMImplementationLSImpl domImpl; 01363 LSSerializer &serializer = domImpl.createLSSerializer(); 01364 LSOutput output = domImpl.createLSOutput(); 01365 StdWriter writer; 01366 output.setCharacterStream(&writer); 01367 serializer.write(doc, output); 01368 01369 return true; 01370 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 1430 of file testxpath.cpp.
References doTests().
01431 { 01432 doTests(); 01433 return 0; 01434 }
Variable Documentation
Definition at line 62 of file testxpath.cpp.
