Commit 11a5c30c authored by Cyril Deguet's avatar Cyril Deguet

* parser/xmlparser.cpp: added DTD validation

parent c381c1c1
......@@ -2,7 +2,7 @@
* xmlparser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: xmlparser.cpp,v 1.1 2004/01/24 13:08:12 asmax Exp $
* $Id: xmlparser.cpp,v 1.2 2004/01/24 14:25:16 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -33,6 +33,8 @@ XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
msg_Err( getIntf(), "Failed to open %s for parsing",
rFileName.c_str() );
}
xmlTextReaderSetParserProp( m_pReader, XML_PARSER_VALIDATE, 1 );
}
......@@ -66,6 +68,7 @@ int XMLParser::parse()
// Begin element
case 1:
{
// Read the element name
const xmlChar *eltName = xmlTextReaderConstName( m_pReader );
if( !eltName )
......@@ -86,6 +89,18 @@ int XMLParser::parse()
}
handleBeginElement( (const char*)eltName, attributes);
break;
}
// End element
case 15:
// Read the element name
const xmlChar *eltName = xmlTextReaderConstName( m_pReader );
if( !eltName )
{
return -1;
}
handleEndElement( (const char*)eltName );
break;
}
ret = xmlTextReaderRead( m_pReader );
}
......@@ -103,3 +118,9 @@ void XMLParser::handleBeginElement( const string &rName,
fprintf(stderr," %s = %s\n", (*it).first, (*it).second);
}
}
void XMLParser::handleEndElement( const string &rName )
{
fprintf(stderr,"--> %s\n", rName.c_str());
}
......@@ -2,7 +2,7 @@
* xmlparser.hpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: xmlparser.hpp,v 1.1 2004/01/24 13:08:12 asmax Exp $
* $Id: xmlparser.hpp,v 1.2 2004/01/24 14:25:16 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -56,6 +56,7 @@ class XMLParser: public SkinObject
xmlTextReaderPtr m_pReader;
void handleBeginElement( const string &rName, AttrList_t &attributes );
void handleEndElement( const string &rName );
};
#endif
......@@ -2,7 +2,7 @@
* theme_loader.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme_loader.cpp,v 1.5 2004/01/24 13:08:12 asmax Exp $
* $Id: theme_loader.cpp,v 1.6 2004/01/24 14:25:16 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -166,6 +166,9 @@ void ThemeLoader::deleteTempFiles( const string &path )
bool ThemeLoader::parse( const string &xmlFile )
{
XMLParser parser( getIntf(), xmlFile );
parser.parse();
// Set the file to parse
FILE *file = fopen( xmlFile.c_str(), "r" );
if( file == NULL )
......@@ -208,9 +211,6 @@ bool ThemeLoader::parse( const string &xmlFile )
return false;
}
XMLParser parser( getIntf(), xmlFile );
parser.parse();
// Build and store the theme
Builder builder( getIntf(), context.m_data );
getIntf()->p_sys->p_theme = builder.build();
......
<!--
-->
<!ELEMENT Theme (ThemeInfo,(Bitmap|Font|Window|Event)*)>
<!ATTLIST Theme
version CDATA "1.0"
magnet CDATA "15"
alpha CDATA "255"
movealpha CDATA "255"
fadetime CDATA "400"
>
<!-- main elements -->
<!ELEMENT Bitmap EMPTY>
<!ATTLIST Bitmap
id CDATA #REQUIRED
file CDATA #REQUIRED
alphacolor CDATA #REQUIRED
>
<!ELEMENT Event EMPTY>
<!ATTLIST Event
id CDATA #REQUIRED
event CDATA #REQUIRED
key CDATA "none"
>
<!ELEMENT Font EMPTY>
<!ATTLIST Font
id CDATA #REQUIRED
font CDATA "arial"
size CDATA "12"
color CDATA "#000000"
italic CDATA "false"
underline CDATA "false"
>
<!ELEMENT ThemeInfo EMPTY>
<!ATTLIST ThemeInfo
name CDATA #IMPLIED
author CDATA #IMPLIED
email CDATA #IMPLIED
webpage CDATA #IMPLIED
>
<!ELEMENT Window (Layout)+>
<!ATTLIST Window
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
dragdrop CDATA "true"
playondrop CDATA "true"
>
<!ELEMENT Layout (Group)>
<!ATTLIST Layout
id CDATA "none"
width CDATA #REQUIRED
height CDATA #REQUIRED
minwidth CDATA "-1"
maxwidth CDATA "-1"
minheight CDATA "-1"
maxheight CDATA "-1"
>
<!ELEMENT Group (Group|Image|Button|Playlist|Slider|RadialSlider|Text|CheckBox|
Rectangle|Anchor)+>
<!ATTLIST Group
x CDATA "\0"
y CDATA "\0"
>
<!-- Anchors -->
<!ELEMENT Anchor EMPTY>
<!ATTLIST Anchor
x CDATA "\0"
y CDATA "\0"
priority CDATA #REQUIRED
range CDATA "10"
>
<!-- Controls -->
<!ELEMENT Image EMPTY>
<!ATTLIST Image
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
image CDATA #REQUIRED
onclick CDATA "none"
help CDATA "\0"
>
<!ELEMENT Rectangle EMPTY>
<!ATTLIST Rectangle
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
w CDATA "50"
h CDATA "50"
color CDATA "#C0C0C0"
onclick CDATA "none"
help CDATA "\0"
>
<!ELEMENT Button EMPTY>
<!ATTLIST Button
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
action CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT CheckBox EMPTY>
<!ATTLIST CheckBox
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up1 CDATA #REQUIRED
down1 CDATA "none"
over1 CDATA "none"
up2 CDATA #REQUIRED
down2 CDATA "none"
over2 CDATA "none"
state CDATA #REQUIRED
action1 CDATA "none"
action2 CDATA "none"
tooltiptext1 CDATA "\0"
tooltiptext2 CDATA "\0"
help CDATA "\0"
>
<!ELEMENT Slider EMPTY>
<!ATTLIST Slider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
points CDATA #REQUIRED
thickness CDATA "10"
value CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT RadialSlider EMPTY>
<!ATTLIST RadialSlider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
sequence CDATA #REQUIRED
nbimages CDATA #REQUIRED
minangle CDATA "\0"
maxangle CDATA "360"
value CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT Text EMPTY>
<!ATTLIST Text
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
text CDATA ""
font CDATA #REQUIRED
align CDATA "left"
width CDATA "\0"
display CDATA "none"
scroll CDATA "true"
scrollspace CDATA "20"
help CDATA "\0"
>
<!ELEMENT Playlist (Slider)>
<!ATTLIST Playlist
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
width CDATA "\0"
height CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
font CDATA #REQUIRED
var CDATA "playlist"
fgcolor CDATA "#000000"
playcolor CDATA "#FF0000"
bgcolor1 CDATA "#FFFFFF"
bgcolor2 CDATA "#FFFFFF"
selcolor CDATA "#0000FF"
help CDATA "\0"
>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment