Skip to content
Snippets Groups Projects
Commit a878d625 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

CCL writer shall write only id and type chunk attrs (if non-empty), in compliance with DTD

parent fe8dde34
Branches
No related merge requests found
......@@ -2,7 +2,7 @@ PROJECT(Corpus2Library)
set(corpus2_ver_major "1")
set(corpus2_ver_minor "2")
set(corpus2_ver_patch "0")
set(corpus2_ver_patch "1")
cmake_minimum_required(VERSION 2.8.0)
......
......@@ -127,9 +127,20 @@ void CclWriter::paragraph_head()
void CclWriter::paragraph_head(const Chunk& c)
{
// in CCL format chunks may have at most two attributes:
// id (unique XML-style id) and type (typically p for paragraphs)
osi() << "<chunk";
BOOST_FOREACH(const Chunk::attr_map_t::value_type& v, c.attributes()) {
os() << " " << v.first << "=\"" << v.second << "\"";
if (c.has_attribute("id")) {
const std::string &val = c.get_attribute("id");
if (!val.empty()) {
os() << " id=\"" << val << "\"";
}
}
if (c.has_attribute("type")) {
const std::string &val = c.get_attribute("type");
if (!val.empty()) {
os() << " type=\"" << val << "\"";
}
}
os() << ">\n";
}
......
......@@ -151,6 +151,10 @@ protected:
return indent_;
}
/**
* Write indentation spaces to the output stream and return the stream
* for writing. Convenience function useful when starting new lines
* in the output. */
std::ostream& osi();
private:
......
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