add xinclude support for libxml2 based parser - thanks oldtopos - closes #567
This commit is contained in:
parent
787374d1b7
commit
6da5983e94
4 changed files with 37 additions and 11 deletions
|
@ -14,6 +14,8 @@ For a complete change history, see the SVN log.
|
||||||
Mapnik Trunk
|
Mapnik Trunk
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
- Added xinclude (http://www.w3.org/TR/xinclude/) support to libxml2-based xml parser (oldtopos) (#567)
|
||||||
|
|
||||||
- Optimized rendering speeds by avoiding locking in the projection code (r2063)
|
- Optimized rendering speeds by avoiding locking in the projection code (r2063)
|
||||||
|
|
||||||
- Added support for setting global alignment of polygon pattern fills (#203)
|
- Added support for setting global alignment of polygon pattern fills (#203)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
|
#include <libxml/xinclude.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -147,8 +148,18 @@ public:
|
||||||
throw config_error(os.str());
|
throw config_error(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iXIncludeReturn = xmlXIncludeProcessFlags( doc, options_ );
|
||||||
|
|
||||||
|
if (iXIncludeReturn < 0)
|
||||||
|
{
|
||||||
|
xmlFreeDoc(doc);
|
||||||
|
throw config_error("XML XInclude error. One or more files failed to load.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmlNode * root = xmlDocGetRootElement( doc );
|
xmlNode * root = xmlDocGetRootElement( doc );
|
||||||
if ( ! root ) {
|
if ( ! root ) {
|
||||||
|
xmlFreeDoc(doc);
|
||||||
throw config_error("XML document is empty.");
|
throw config_error("XML document is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
|
|
||||||
void parse_map(Map & map, ptree const & sty);
|
void parse_map(Map & map, ptree const & sty);
|
||||||
private:
|
private:
|
||||||
|
void parse_map_include( Map & map, ptree const & include);
|
||||||
void parse_style(Map & map, ptree const & sty);
|
void parse_style(Map & map, ptree const & sty);
|
||||||
void parse_layer(Map & map, ptree const & lay);
|
void parse_layer(Map & map, ptree const & lay);
|
||||||
void parse_metawriter(Map & map, ptree const & lay);
|
void parse_metawriter(Map & map, ptree const & lay);
|
||||||
|
@ -244,14 +245,28 @@ void map_parser::parse_map( Map & map, ptree const & pt )
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptree::const_iterator itr = map_node.begin();
|
parse_map_include( map, map_node );
|
||||||
ptree::const_iterator end = map_node.end();
|
}
|
||||||
|
catch (const boost::property_tree::ptree_bad_path &)
|
||||||
|
{
|
||||||
|
throw config_error("Not a map file. Node 'Map' not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void map_parser::parse_map_include( Map & map, ptree const & include )
|
||||||
|
{
|
||||||
|
ptree::const_iterator itr = include.begin();
|
||||||
|
ptree::const_iterator end = include.end();
|
||||||
|
|
||||||
for (; itr != end; ++itr)
|
for (; itr != end; ++itr)
|
||||||
{
|
{
|
||||||
ptree::value_type const& v = *itr;
|
ptree::value_type const& v = *itr;
|
||||||
|
|
||||||
if (v.first == "Style")
|
if (v.first == "Include")
|
||||||
|
{
|
||||||
|
parse_map_include( map, v.second );
|
||||||
|
}
|
||||||
|
else if (v.first == "Style")
|
||||||
{
|
{
|
||||||
parse_style( map, v.second );
|
parse_style( map, v.second );
|
||||||
}
|
}
|
||||||
|
@ -307,11 +322,8 @@ void map_parser::parse_map( Map & map, ptree const & pt )
|
||||||
v.first + "'");
|
v.first + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (const boost::property_tree::ptree_bad_path &)
|
|
||||||
{
|
|
||||||
throw config_error("Not a map file. Node 'Map' not found.");
|
|
||||||
}
|
|
||||||
map.init_metawriters();
|
map.init_metawriters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
xml = sys.argv[1]
|
xml = sys.argv[1]
|
||||||
tree = objectify.parse(xml)
|
tree = objectify.parse(xml)
|
||||||
|
tree.xinclude()
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
# rename 'bgcolor' to 'background-color'
|
# rename 'bgcolor' to 'background-color'
|
||||||
|
|
Loading…
Add table
Reference in a new issue