summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvntcreutz <svntcreutz@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f>2007-08-12 01:01:19 +0000
committersvntcreutz <svntcreutz@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f>2007-08-12 01:01:19 +0000
commitb2ba006be05dcc45e81f54942ceeb62819440b83 (patch)
treef20266a57efbee15ecf882ee37a114f675ab2f18
parentd123bbd5d05c7a1ba6581b4cf8ac76f2273bc0e5 (diff)
downloadvdr-plugin-menuorg-b2ba006be05dcc45e81f54942ceeb62819440b83.tar.gz
vdr-plugin-menuorg-b2ba006be05dcc45e81f54942ceeb62819440b83.tar.bz2
first try to validate the xml file
git-svn-id: file:///home/tobias/sandbox/vdr/--/vdr-pkg/vdr-pkg/submenu/trunk@5686 cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f
-rw-r--r--src/xmlmenu.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/xmlmenu.cpp b/src/xmlmenu.cpp
index f085eba..60dc628 100644
--- a/src/xmlmenu.cpp
+++ b/src/xmlmenu.cpp
@@ -43,23 +43,40 @@ MenuNode* XmlMenu::LoadXmlMenu(string menuFileName)
//TODO: patch the xmlfile with the xsd definition for validate the schema
//parser.set_validate();
parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically.
- parser.parse_file(menuFileName);
-
+// parser.parse_file(menuFileName);
+ parser.parse_file("/var/lib/vdr/plugins/menuorg.xml");
- const Element* rootElement = parser.get_document()->get_root_node();
+ //DtdValidator validator( dtdFileName );
+ DtdValidator validator( "/var/lib/vdr/plugins/menuorg.dtd" );
+ Document *pDoc = parser.get_document();
+ validator.validate( pDoc );
+
+ const Element* rootElement = parser.get_document()->get_root_node();
ParseElement(rootElement, menuRoot);
}
catch(const std::exception& ex)
{
delete menuRoot;
menuRoot = NULL;
-
+
//TODO: print output to syslog (isyslog or dsyslog?)
cout << "Exception caught: " << ex.what() << endl;
isyslog("Exception caught: %s", ex.what());
//TODO: display message on osd
}
-
+/*
+ catch(const xmlpp::parse_error& ex)
+ {
+ // DTD or document is not well-formed
+ delete menuRoot;
+ menuRoot = NULL;
+ }
+ catch (const xmlpp::validation_error& ex)
+ {
+ // document is not valid
+ delete menuRoot;
+ menuRoot = NULL;
+ }*/
return menuRoot;
}
@@ -78,7 +95,7 @@ void XmlMenu::ParseElement(const Element* element, MenuNode* menuNode)
{
string type = childElement->get_name();
string name = nameAttribute->get_value();
-
+
if ( type == "menu")
{
MenuNode* subMenu = AddSubMenuItem(name, menuNode);