mirror of
https://github.com/jezhiggins/arabica
synced 2024-12-26 21:58:39 +01:00
Removed last of the std::string-isms.
This commit is contained in:
parent
bdc7db5da8
commit
51f1912534
28 changed files with 1182 additions and 1126 deletions
|
@ -1,18 +1,14 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4250)
|
#pragma warning(disable : 4250 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <SAX/InputSource.hpp>
|
|
||||||
#include <DOM/SAX2DOM/SAX2DOM.hpp>
|
|
||||||
#include <DOM/io/Stream.hpp>
|
|
||||||
#include <XSLT/XSLT.hpp>
|
#include <XSLT/XSLT.hpp>
|
||||||
|
|
||||||
Arabica::DOM::Document<std::wstring> buildDOM(const std::wstring& xml);
|
Arabica::DOM::Document<std::string> buildDOM(const std::string & xml);
|
||||||
typedef Arabica::default_string_adaptor<std::wstring> adaptor;
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
|
@ -24,12 +20,12 @@ int main(int argc, const char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
Arabica::XSLT::StylesheetCompiler<std::wstring> compiler;
|
Arabica::XSLT::StylesheetCompiler<std::string> compiler;
|
||||||
std::wostringstream errors;
|
std::ostringstream errors;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Arabica::SAX::InputSource<std::wstring> source(adaptor::construct_from_utf8(argv[2]));
|
Arabica::SAX::InputSource<std::string> source(argv[2]);
|
||||||
std::auto_ptr<Arabica::XSLT::Stylesheet<std::wstring> > stylesheet = compiler.compile(source);
|
std::auto_ptr<Arabica::XSLT::Stylesheet<std::string> > stylesheet = compiler.compile(source);
|
||||||
if(stylesheet.get() == 0)
|
if(stylesheet.get() == 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Couldn't compile stylesheet: " << compiler.error() << std::endl;
|
std::cerr << "Couldn't compile stylesheet: " << compiler.error() << std::endl;
|
||||||
|
@ -38,41 +34,28 @@ int main(int argc, const char* argv[])
|
||||||
|
|
||||||
stylesheet->set_error_output(errors);
|
stylesheet->set_error_output(errors);
|
||||||
|
|
||||||
Arabica::DOM::Document<std::wstring> document = buildDOM(adaptor::construct_from_utf8(argv[1]));
|
Arabica::DOM::Document<std::string> document = buildDOM(argv[1]);
|
||||||
if(document == 0)
|
if(document == 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not parse XML source" << std::endl;
|
std::cerr << "Could not parse XML source" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
} // if ...
|
} // if ...
|
||||||
//document.normalize();
|
|
||||||
stylesheet->execute(document);
|
stylesheet->execute(document);
|
||||||
|
|
||||||
/*
|
|
||||||
std::cout << "\n==============" << std::endl;
|
|
||||||
|
|
||||||
Arabica::XSLT::DOMSink output;
|
|
||||||
stylesheet->set_output(output);
|
|
||||||
|
|
||||||
stylesheet->execute(document);
|
|
||||||
|
|
||||||
Arabica::DOM::Node<std::wstring> node = output.node();
|
|
||||||
std::cout << node << std::endl;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
catch(const std::runtime_error& ex)
|
catch(const std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
std::cerr << ex.what() << std::endl;
|
std::cerr << ex.what() << std::endl;
|
||||||
} // catch
|
} // catch
|
||||||
|
|
||||||
std::wcerr << "\n\n" << errors.str() << std::endl;
|
std::cerr << "\n\n" << errors.str() << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
Arabica::DOM::Document<std::wstring> buildDOM(const std::wstring& filename)
|
Arabica::DOM::Document<std::string> buildDOM(const std::string & filename)
|
||||||
{
|
{
|
||||||
Arabica::SAX::InputSource<std::wstring> is(filename);
|
Arabica::SAX::InputSource<std::string> is(filename);
|
||||||
Arabica::SAX2DOM::Parser<std::wstring> parser;
|
Arabica::SAX2DOM::Parser<std::string> parser;
|
||||||
parser.parse(is);
|
parser.parse(is);
|
||||||
|
|
||||||
return parser.getDocument();
|
return parser.getDocument();
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
typedef stringT string_type;
|
typedef stringT string_type;
|
||||||
typedef typename string_type::const_iterator const_iterator;
|
typedef typename string_type::const_iterator const_iterator;
|
||||||
typedef typename string_type::iterator mutable_iterator;
|
typedef typename string_type::iterator mutable_iterator;
|
||||||
|
typedef typename string_type::const_reverse_iterator const_reverse_iterator;
|
||||||
typedef typename string_type::iterator iterator;
|
typedef typename string_type::iterator iterator;
|
||||||
typedef typename string_type::value_type value_type;
|
typedef typename string_type::value_type value_type;
|
||||||
typedef typename string_type::size_type size_type;
|
typedef typename string_type::size_type size_type;
|
||||||
|
@ -42,6 +43,10 @@ public:
|
||||||
return string_type(from, to);
|
return string_type(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline string_type construct(const std::basic_string<value_type>& str)
|
||||||
|
{
|
||||||
|
return construct(str.begin(), str.end());
|
||||||
|
} // construct
|
||||||
|
|
||||||
static string_type construct(const value_type* str)
|
static string_type construct(const value_type* str)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +67,9 @@ public:
|
||||||
static string_type substr(const string_type& str, const size_type& offset) { return str.substr(offset); }
|
static string_type substr(const string_type& str, const size_type& offset) { return str.substr(offset); }
|
||||||
static string_type substr(const string_type& str, const size_type& offset, const size_type& count) { return str.substr(offset, count); }
|
static string_type substr(const string_type& str, const size_type& offset, const size_type& count) { return str.substr(offset, count); }
|
||||||
static void append(string_type& str, const string_type& a) { str.append(a); }
|
static void append(string_type& str, const string_type& a) { str.append(a); }
|
||||||
|
static void append(string_type& str, const value_type& a) { str += a; }
|
||||||
|
static string_type concat(const string_type& str, const string_type& a) { return str + a; }
|
||||||
|
static string_type concat(const string_type& str, const value_type& a) { return str + a; }
|
||||||
static void insert(string_type& str, size_type offset, const string_type& a) { str.insert(offset, a); }
|
static void insert(string_type& str, size_type offset, const string_type& a) { str.insert(offset, a); }
|
||||||
static void replace(string_type& str, size_type offset, size_type count, const string_type& a) { str.replace(offset, count, a); }
|
static void replace(string_type& str, size_type offset, size_type count, const string_type& a) { str.replace(offset, count, a); }
|
||||||
|
|
||||||
|
@ -71,6 +79,7 @@ public:
|
||||||
static iterator begin(string_type& str) { return str.begin(); }
|
static iterator begin(string_type& str) { return str.begin(); }
|
||||||
static iterator end(string_type& str) { return str.end(); }
|
static iterator end(string_type& str) { return str.end(); }
|
||||||
|
|
||||||
|
static const_reverse_iterator rbegin(const string_type& str) { return str.rbegin(); }
|
||||||
|
|
||||||
// only used to constuct error strings - don't have to be highly efficient!
|
// only used to constuct error strings - don't have to be highly efficient!
|
||||||
static std::string asStdString(const string_type& str);
|
static std::string asStdString(const string_type& str);
|
||||||
|
|
|
@ -304,7 +304,7 @@ class NamespaceSupport
|
||||||
for(typename contextListT::const_reverse_iterator i = contexts_.rbegin(); i != contexts_.rend(); ++i)
|
for(typename contextListT::const_reverse_iterator i = contexts_.rbegin(); i != contexts_.rend(); ++i)
|
||||||
{
|
{
|
||||||
for(typename stringMapT::const_iterator u = i->begin(); u != i->end(); ++u)
|
for(typename stringMapT::const_iterator u = i->begin(); u != i->end(); ++u)
|
||||||
if(!u->first.empty())
|
if(!string_adaptor::empty(u->first))
|
||||||
prefixes.push_back(u->first);
|
prefixes.push_back(u->first);
|
||||||
} // for ...
|
} // for ...
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
{
|
{
|
||||||
++depth_;
|
++depth_;
|
||||||
string_type base = atts.getValue(xbc_.xml_uri, xbc_.base);
|
string_type base = atts.getValue(xbc_.xml_uri, xbc_.base);
|
||||||
if(base.empty())
|
if(string_adaptor::empty(base))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string_type baseURI = absolutise(currentBase(), base);
|
string_type baseURI = absolutise(currentBase(), base);
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
virtual void characters(const string_type& ch)
|
virtual void characters(const string_type& ch)
|
||||||
{
|
{
|
||||||
if(no_content_)
|
if(no_content_)
|
||||||
verifyNoCharacterData<string_type, string_adaptor>(ch, SC::include + SC::import);
|
verifyNoCharacterData<string_type, string_adaptor>(ch, SC::include); // + SC::import
|
||||||
context_->parentHandler().characters(ch);
|
context_->parentHandler().characters(ch);
|
||||||
} // characters
|
} // characters
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
||||||
std::vector<InlineAttribute<string_type, string_adaptor> > inlineAtts;
|
std::vector<InlineAttribute<string_type, string_adaptor> > inlineAtts;
|
||||||
for(int i = 0; i != atts.getLength(); ++i)
|
for(int i = 0; i != atts.getLength(); ++i)
|
||||||
{
|
{
|
||||||
if(atts.getQName(i).find(SC::xmlns_colon) == 0)
|
if(string_adaptor::find(atts.getQName(i), SC::xmlns_colon) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(atts.getURI(i) == StylesheetConstant<string_type, string_adaptor>::NamespaceURI)
|
if(atts.getURI(i) == StylesheetConstant<string_type, string_adaptor>::NamespaceURI)
|
||||||
continue;
|
continue;
|
||||||
|
@ -42,9 +42,9 @@ protected:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::pair<string_type, string_type> remap = baseT::context().remappedNamespace(atts.getURI(i));
|
std::pair<string_type, string_type> remap = baseT::context().remappedNamespace(atts.getURI(i));
|
||||||
if(remap.first.empty() && !remap.second.empty())
|
if(string_adaptor::empty(remap.first) && !string_adaptor::empty(remap.second))
|
||||||
remap.first = baseT::context().autoNamespacePrefix();
|
remap.first = baseT::context().autoNamespacePrefix();
|
||||||
string_type name = remap.first + SC::COLON + atts.getLocalName(i);
|
string_type name = makeName(remap.first, atts.getLocalName(i));
|
||||||
inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(name,
|
inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(name,
|
||||||
remap.second,
|
remap.second,
|
||||||
baseT::context().xpath_attribute_value_template(atts.getValue(i))));
|
baseT::context().xpath_attribute_value_template(atts.getValue(i))));
|
||||||
|
@ -55,9 +55,18 @@ protected:
|
||||||
return new InlineElement<string_type, string_adaptor>(qName, namespaceURI, inlineAtts);
|
return new InlineElement<string_type, string_adaptor>(qName, namespaceURI, inlineAtts);
|
||||||
|
|
||||||
const std::pair<string_type, string_type>& remap = baseT::context().remappedNamespace(namespaceURI);
|
const std::pair<string_type, string_type>& remap = baseT::context().remappedNamespace(namespaceURI);
|
||||||
string_type name = remap.first + SC::COLON + localName;
|
string_type name = makeName(remap.first, localName);
|
||||||
return new InlineElement<string_type, string_adaptor>(name, remap.second, inlineAtts);
|
return new InlineElement<string_type, string_adaptor>(name, remap.second, inlineAtts);
|
||||||
} // createContainer
|
} // createContainer
|
||||||
|
|
||||||
|
private:
|
||||||
|
string_type makeName(const string_type prefix, const string_type localName) const
|
||||||
|
{
|
||||||
|
string_type n = prefix;
|
||||||
|
string_adaptor::append(n, SC::COLON);
|
||||||
|
string_adaptor::append(n, localName);
|
||||||
|
return n;
|
||||||
|
} // makeName
|
||||||
}; // class InlineElementHandler
|
}; // class InlineElementHandler
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
virtual void characters(const string_type& ch)
|
virtual void characters(const string_type& ch)
|
||||||
{
|
{
|
||||||
for(typename string_type::const_iterator i = ch.begin(), e = ch.end(); i != e; ++i)
|
for(typename string_adaptor::const_iterator i = string_adaptor::begin(ch), e = string_adaptor::end(ch); i != e; ++i)
|
||||||
if(!Arabica::XML::is_space(*i))
|
if(!Arabica::XML::is_space(*i))
|
||||||
{
|
{
|
||||||
container_->add_item(new Text<string_type, string_adaptor>(ch));
|
container_->add_item(new Text<string_type, string_adaptor>(ch));
|
||||||
|
|
|
@ -44,10 +44,10 @@ public:
|
||||||
|
|
||||||
std::map<string_type, string_type> namespaces = context_.inScopeNamespaces();
|
std::map<string_type, string_type> namespaces = context_.inScopeNamespaces();
|
||||||
if((namespaces.find(stylesheet_prefix) == namespaces.end()) &&
|
if((namespaces.find(stylesheet_prefix) == namespaces.end()) &&
|
||||||
(!stylesheet_prefix.empty()))
|
(!string_adaptor::empty(stylesheet_prefix)))
|
||||||
throw SAX::SAXException(string_adaptor::asStdString(SC::namespace_alias) + " " + string_adaptor::asStdString(stylesheet_prefix) + " is not a declared namespace prefix");
|
throw SAX::SAXException(string_adaptor::asStdString(SC::namespace_alias) + " " + string_adaptor::asStdString(stylesheet_prefix) + " is not a declared namespace prefix");
|
||||||
if((namespaces.find(result_prefix) == namespaces.end()) &&
|
if((namespaces.find(result_prefix) == namespaces.end()) &&
|
||||||
(!result_prefix.empty()))
|
(!string_adaptor::empty(result_prefix)))
|
||||||
throw SAX::SAXException(string_adaptor::asStdString(SC::namespace_alias) + " " + string_adaptor::asStdString(result_prefix) + " is not a declared namespace prefix");
|
throw SAX::SAXException(string_adaptor::asStdString(SC::namespace_alias) + " " + string_adaptor::asStdString(result_prefix) + " is not a declared namespace prefix");
|
||||||
|
|
||||||
context_.addNamespaceAlias(namespaces[stylesheet_prefix], result_prefix, namespaces[result_prefix]);
|
context_.addNamespaceAlias(namespaces[stylesheet_prefix], result_prefix, namespaces[result_prefix]);
|
||||||
|
|
|
@ -66,17 +66,17 @@ private:
|
||||||
{
|
{
|
||||||
CDATAElements elements;
|
CDATAElements elements;
|
||||||
|
|
||||||
if(cdata_section_elements.empty())
|
if(string_adaptor::empty(cdata_section_elements))
|
||||||
return elements;
|
return elements;
|
||||||
|
|
||||||
std::basic_istringstream<typename string_adaptor::value_type>
|
string_type norm_cdata_sec_elements = text::normalize_whitespace<string_type, string_adaptor>(cdata_section_elements);
|
||||||
is(text::normalize_whitespace<string_type, string_adaptor>(cdata_section_elements));
|
std::basic_istringstream<typename string_adaptor::value_type> is(string_adaptor::asStdString(norm_cdata_sec_elements));
|
||||||
while(!is.eof())
|
while(!is.eof())
|
||||||
{
|
{
|
||||||
string_type e;
|
std::basic_string<typename string_adaptor::value_type> e;
|
||||||
is >> e;
|
is >> e;
|
||||||
|
|
||||||
XML::QualifiedName<string_type, string_adaptor> qualifiedName = context_.processElementQName(e);
|
XML::QualifiedName<string_type, string_adaptor> qualifiedName = context_.processElementQName(string_adaptor::construct(e));
|
||||||
elements.insert(QName<string_type, string_adaptor>::create(qualifiedName));
|
elements.insert(QName<string_type, string_adaptor>::create(qualifiedName));
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
order = context_.xpath_attribute_value_template(attr[SC::order]);
|
order = context_.xpath_attribute_value_template(attr[SC::order]);
|
||||||
caseorder = context_.xpath_attribute_value_template(attr[SC::case_order]);
|
caseorder = context_.xpath_attribute_value_template(attr[SC::case_order]);
|
||||||
|
|
||||||
if(attr[SC::lang].length() != 0)
|
if(string_adaptor::length(attr[SC::lang]) != 0)
|
||||||
std::cerr << "Sorry! Don't support xsl:sort lang attribute yet" << std::endl;
|
std::cerr << "Sorry! Don't support xsl:sort lang attribute yet" << std::endl;
|
||||||
|
|
||||||
sort_ = new Sort<string_type, string_adaptor>(select,
|
sort_ = new Sort<string_type, string_adaptor>(select,
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
{
|
{
|
||||||
if(!done_params_)
|
if(!done_params_)
|
||||||
{
|
{
|
||||||
for(typename string_type::const_iterator i = ch.begin(), e = ch.end(); i != e; ++i)
|
for(typename string_adaptor::const_iterator i = string_adaptor::begin(ch), e = string_adaptor::end(ch); i != e; ++i)
|
||||||
if(!Arabica::XML::is_space(*i))
|
if(!Arabica::XML::is_space(*i))
|
||||||
{
|
{
|
||||||
done_params_ = true;
|
done_params_ = true;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
virtual void characters(const string_type& ch)
|
virtual void characters(const string_type& ch)
|
||||||
{
|
{
|
||||||
buffer_ += ch;
|
string_adaptor::append(buffer_, ch);
|
||||||
} // characters
|
} // characters
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
{
|
{
|
||||||
const string_type& name = r->first;
|
const string_type& name = r->first;
|
||||||
const AttributeValidator<string_type, string_adaptor>& av = r->second;
|
const AttributeValidator<string_type, string_adaptor>& av = r->second;
|
||||||
if((av.mandatory()) && (atts.getValue(name).empty()))
|
if((av.mandatory()) && (string_adaptor::empty(atts.getValue(name))))
|
||||||
throw SAX::SAXException(string_adaptor::asStdString(parentElement) + ": Attribute " + string_adaptor::asStdString(name) + " must be specified");
|
throw SAX::SAXException(string_adaptor::asStdString(parentElement) + ": Attribute " + string_adaptor::asStdString(name) + " must be specified");
|
||||||
if(av.has_default())
|
if(av.has_default())
|
||||||
results[name] = av.default_value();
|
results[name] = av.default_value();
|
||||||
|
@ -300,7 +300,7 @@ template<class string_type, class string_adaptor>
|
||||||
void verifyNoCharacterData(const string_type& ch,
|
void verifyNoCharacterData(const string_type& ch,
|
||||||
const string_type& name)
|
const string_type& name)
|
||||||
{
|
{
|
||||||
for(typename string_type::const_iterator i = ch.begin(), e = ch.end(); i != e; ++i)
|
for(typename string_adaptor::const_iterator i = string_adaptor::begin(ch), e = string_adaptor::end(ch); i != e; ++i)
|
||||||
if(!Arabica::XML::is_space(*i))
|
if(!Arabica::XML::is_space(*i))
|
||||||
throw SAX::SAXException(string_adaptor::asStdString(name) + " element can not contain character data.");
|
throw SAX::SAXException(string_adaptor::asStdString(name) + " element can not contain character data.");
|
||||||
} // verifyNoCharacterContent
|
} // verifyNoCharacterContent
|
||||||
|
|
|
@ -63,7 +63,7 @@ protected:
|
||||||
{
|
{
|
||||||
if(has_select_)
|
if(has_select_)
|
||||||
{
|
{
|
||||||
for(typename string_type::const_iterator i = ch.begin(), e = ch.end(); i != e; ++i)
|
for(typename string_adaptor::const_iterator i = string_adaptor::begin(ch), e = string_adaptor::end(ch); i != e; ++i)
|
||||||
if(!Arabica::XML::is_space(*i))
|
if(!Arabica::XML::is_space(*i))
|
||||||
throw SAX::SAXException("A variable or param can not have both a select attribute and text context");
|
throw SAX::SAXException("A variable or param can not have both a select attribute and text context");
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
ExecutionContext<string_type, string_adaptor>& context) const
|
ExecutionContext<string_type, string_adaptor>& context) const
|
||||||
{
|
{
|
||||||
string_type name = name_->evaluateAsString(node, context.xpathContext());
|
string_type name = name_->evaluateAsString(node, context.xpathContext());
|
||||||
if(name.empty())
|
if(string_adaptor::empty(name))
|
||||||
throw SAX::SAXException("xsl:attribute name attribute must evaluate to a valid element name");
|
throw SAX::SAXException("xsl:attribute name attribute must evaluate to a valid element name");
|
||||||
|
|
||||||
string_type namesp;
|
string_type namesp;
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QName<string_type, string_adaptor> qn = QName<string_type, string_adaptor>::create(name);
|
QName<string_type, string_adaptor> qn = QName<string_type, string_adaptor>::create(name);
|
||||||
if(!qn.prefix.empty())
|
if(!string_adaptor::empty(qn.prefix))
|
||||||
{
|
{
|
||||||
typename std::map<string_type, string_type>::const_iterator ns = namespaces_.find(qn.prefix);
|
typename std::map<string_type, string_type>::const_iterator ns = namespaces_.find(qn.prefix);
|
||||||
if(ns == namespaces_.end())
|
if(ns == namespaces_.end())
|
||||||
|
|
|
@ -171,7 +171,7 @@ public:
|
||||||
{
|
{
|
||||||
std::basic_ostringstream<typename string_adaptor::value_type> ss;
|
std::basic_ostringstream<typename string_adaptor::value_type> ss;
|
||||||
ss << SC::auto_ns << autoNs_++;
|
ss << SC::auto_ns << autoNs_++;
|
||||||
return ss.str();
|
return string_adaptor::construct(ss.str());
|
||||||
} // autoNamespacePrefix
|
} // autoNamespacePrefix
|
||||||
|
|
||||||
void set_precedence(const Precedence& prec)
|
void set_precedence(const Precedence& prec)
|
||||||
|
@ -204,7 +204,7 @@ private:
|
||||||
const string_type& name,
|
const string_type& name,
|
||||||
const std::vector<Arabica::XPath::XPathExpression<string_type> >& argExprs) const
|
const std::vector<Arabica::XPath::XPathExpression<string_type> >& argExprs) const
|
||||||
{
|
{
|
||||||
if(!namespace_uri.empty())
|
if(!string_adaptor::empty(namespace_uri))
|
||||||
return new UndefinedFunction<string_type, string_adaptor>(namespace_uri, name, argExprs);
|
return new UndefinedFunction<string_type, string_adaptor>(namespace_uri, name, argExprs);
|
||||||
|
|
||||||
// document
|
// document
|
||||||
|
|
|
@ -236,7 +236,7 @@ protected:
|
||||||
|
|
||||||
std::basic_ostringstream<typename string_adaptor::value_type> os;
|
std::basic_ostringstream<typename string_adaptor::value_type> os;
|
||||||
os << node.underlying_impl();
|
os << node.underlying_impl();
|
||||||
return os.str();
|
return string_adaptor::construct(os.str());
|
||||||
} // doEvaluate
|
} // doEvaluate
|
||||||
}; // class GenerateIdFunction
|
}; // class GenerateIdFunction
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ protected:
|
||||||
const QualifiedName expandedName = QualifiedName::parseQName(functionName, true, namespaces_);
|
const QualifiedName expandedName = QualifiedName::parseQName(functionName, true, namespaces_);
|
||||||
|
|
||||||
if((expandedName.namespaceUri() != StylesheetConstant<string_type, string_adaptor>::NamespaceURI) &&
|
if((expandedName.namespaceUri() != StylesheetConstant<string_type, string_adaptor>::NamespaceURI) &&
|
||||||
(!expandedName.namespaceUri().empty()))
|
(!string_adaptor::empty(expandedName.namespaceUri())))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
static string_type XSLTNames[] = { SC::apply_imports,
|
static string_type XSLTNames[] = { SC::apply_imports,
|
||||||
|
@ -414,14 +414,14 @@ public:
|
||||||
{
|
{
|
||||||
typedef Arabica::text::Unicode<typename string_adaptor::value_type> UnicodeT;
|
typedef Arabica::text::Unicode<typename string_adaptor::value_type> UnicodeT;
|
||||||
|
|
||||||
if(!namespace_uri.empty())
|
if(!string_adaptor::empty(namespace_uri))
|
||||||
{
|
{
|
||||||
error_ += UnicodeT::LEFT_SQUARE_BRACKET;
|
string_adaptor::append(error_, UnicodeT::LEFT_SQUARE_BRACKET);
|
||||||
error_ += namespace_uri;
|
string_adaptor::append(error_, namespace_uri);
|
||||||
error_ += UnicodeT::RIGHT_SQUARE_BRACKET;
|
string_adaptor::append(error_, UnicodeT::RIGHT_SQUARE_BRACKET);
|
||||||
} // if ..
|
} // if ..
|
||||||
|
|
||||||
error_ += name;
|
string_adaptor::append(error_, name);
|
||||||
} // UndefinedFunction
|
} // UndefinedFunction
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
if(findPrefix(namespaceURI) != EMPTY_STRING)
|
if(findPrefix(namespaceURI) != EMPTY_STRING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool remap = (attr && given_prefix.empty()) || (given_prefix == SC::xmlns);
|
bool remap = (attr && string_adaptor::empty(given_prefix)) || (given_prefix == SC::xmlns);
|
||||||
|
|
||||||
string_type prefix = !remap ? given_prefix : autoNamespacePrefix();
|
string_type prefix = !remap ? given_prefix : autoNamespacePrefix();
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ private:
|
||||||
{
|
{
|
||||||
std::basic_ostringstream<typename string_adaptor::value_type> ss;
|
std::basic_ostringstream<typename string_adaptor::value_type> ss;
|
||||||
ss << SC::auto_ns << autoNs_++;
|
ss << SC::auto_ns << autoNs_++;
|
||||||
return ss.str();
|
return string_adaptor::construct(ss.str());
|
||||||
} // autoNamespacePrefix
|
} // autoNamespacePrefix
|
||||||
|
|
||||||
ScopeStack prefixStack_;
|
ScopeStack prefixStack_;
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
flush_current();
|
flush_current();
|
||||||
|
|
||||||
namespaceStack_.pushScope();
|
namespaceStack_.pushScope();
|
||||||
if(!namespaceURI.empty())
|
if(!string_adaptor::empty(namespaceURI))
|
||||||
namespaceStack_.declareNamespace(prefix, namespaceURI);
|
namespaceStack_.declareNamespace(prefix, namespaceURI);
|
||||||
|
|
||||||
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
||||||
|
@ -95,13 +95,21 @@ public:
|
||||||
if(!text_mode_)
|
if(!text_mode_)
|
||||||
{
|
{
|
||||||
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
||||||
do_end_element((!mapped_prefix.empty()) ? mapped_prefix + SC::COLON + localName : localName, namespaceURI);
|
do_end_element((!string_adaptor::empty(mapped_prefix)) ? makeName(mapped_prefix, localName) : localName, namespaceURI);
|
||||||
element_stack_.pop();
|
element_stack_.pop();
|
||||||
} // end_element
|
} // end_element
|
||||||
|
|
||||||
namespaceStack_.popScope();
|
namespaceStack_.popScope();
|
||||||
} // end_element
|
} // end_element
|
||||||
|
|
||||||
|
string_type makeName(const string_type& prefix, const string_type& localName) const
|
||||||
|
{
|
||||||
|
string_type n = prefix;
|
||||||
|
string_adaptor::append(n, SC::COLON);
|
||||||
|
string_adaptor::append(n, localName);
|
||||||
|
return n;
|
||||||
|
} // makeName
|
||||||
|
|
||||||
void start_attribute(const string_type& qName, const string_type& namespaceURI)
|
void start_attribute(const string_type& qName, const string_type& namespaceURI)
|
||||||
{
|
{
|
||||||
QName<string_type, string_adaptor> qn = QName<string_type, string_adaptor>::create(qName, namespaceURI);
|
QName<string_type, string_adaptor> qn = QName<string_type, string_adaptor>::create(qName, namespaceURI);
|
||||||
|
@ -119,11 +127,11 @@ public:
|
||||||
return;
|
return;
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
if(!namespaceURI.empty())
|
if(!string_adaptor::empty(namespaceURI))
|
||||||
namespaceStack_.declareNamespace(prefix, namespaceURI, true);
|
namespaceStack_.declareNamespace(prefix, namespaceURI, true);
|
||||||
|
|
||||||
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
string_type mapped_prefix = namespaceStack_.findPrefix(namespaceURI);
|
||||||
string_type qName = (!mapped_prefix.empty()) ? mapped_prefix + SC::COLON + localName : localName;
|
string_type qName = (!string_adaptor::empty(mapped_prefix)) ? makeName(mapped_prefix, localName) : localName;
|
||||||
|
|
||||||
atts_.addOrReplaceAttribute(namespaceURI,
|
atts_.addOrReplaceAttribute(namespaceURI,
|
||||||
localName,
|
localName,
|
||||||
|
@ -141,7 +149,6 @@ public:
|
||||||
if(pending_attribute_ == -1)
|
if(pending_attribute_ == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
atts_.setValue(pending_attribute_, buffer_.str());
|
|
||||||
|
|
||||||
pending_attribute_ = -1;
|
pending_attribute_ = -1;
|
||||||
} // end_attribute
|
} // end_attribute
|
||||||
|
@ -173,7 +180,7 @@ public:
|
||||||
|
|
||||||
if(pending_attribute_ != -1)
|
if(pending_attribute_ != -1)
|
||||||
{
|
{
|
||||||
atts_.setValue(pending_attribute_, atts_.getValue(pending_attribute_) + ch);
|
atts_.setValue(pending_attribute_, string_adaptor::concat(atts_.getValue(pending_attribute_), ch));
|
||||||
return;
|
return;
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
|
@ -204,9 +211,9 @@ public:
|
||||||
|
|
||||||
if(!text_mode_)
|
if(!text_mode_)
|
||||||
{
|
{
|
||||||
string_type comment = escape(buffer_.str(), SC::double_hyphen, SC::escaped_double_hyphen);
|
string_type comment = escape(string_adaptor::construct(buffer_.str()), SC::double_hyphen, SC::escaped_double_hyphen);
|
||||||
if(comment.length() && *(comment.rbegin()) == SC::HYPHEN_MINUS)
|
if(string_adaptor::length(comment) && *(string_adaptor::rbegin(comment)) == SC::HYPHEN_MINUS)
|
||||||
comment += SC::SPACE;
|
string_adaptor::append(comment, SC::SPACE);
|
||||||
do_comment(comment);
|
do_comment(comment);
|
||||||
} // if ...
|
} // if ...
|
||||||
} // end_comment
|
} // end_comment
|
||||||
|
@ -228,7 +235,7 @@ public:
|
||||||
|
|
||||||
if(!text_mode_)
|
if(!text_mode_)
|
||||||
{
|
{
|
||||||
string_type data = escape(buffer_.str(), SC::PIEnd, SC::escaped_pi_end);
|
string_type data = escape(string_adaptor::construct(buffer_.str()), SC::PIEnd, SC::escaped_pi_end);
|
||||||
do_processing_instruction(target_, data);
|
do_processing_instruction(target_, data);
|
||||||
} // if ...
|
} // if ...
|
||||||
} // end_processing_instruction
|
} // end_processing_instruction
|
||||||
|
@ -260,11 +267,14 @@ protected:
|
||||||
private:
|
private:
|
||||||
string_type escape(string_type str, const string_type& t, const string_type& r) const
|
string_type escape(string_type str, const string_type& t, const string_type& r) const
|
||||||
{
|
{
|
||||||
typename string_type::size_type naughty = str.find(t);
|
typename string_adaptor::size_type naughty = string_adaptor::find(str, t);
|
||||||
while(naughty != string_type::npos)
|
while(naughty != string_adaptor::npos())
|
||||||
{
|
{
|
||||||
str.replace(naughty, t.length(), r, 0, r.length());
|
string_type newstr = string_adaptor::substr(str, 0, naughty);
|
||||||
naughty = str.find(t, naughty);
|
string_adaptor::append(newstr, r);
|
||||||
|
string_adaptor::append(newstr, string_adaptor::substr(str, naughty + string_adaptor::length(t)));
|
||||||
|
str = newstr;
|
||||||
|
naughty = string_adaptor::find(str, t, naughty);
|
||||||
} // while
|
} // while
|
||||||
return str;
|
return str;
|
||||||
} // escape
|
} // escape
|
||||||
|
@ -277,7 +287,7 @@ private:
|
||||||
if(is_buf)
|
if(is_buf)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
buffer_.str(string_adaptor::empty_string());
|
buffer_.str(std::basic_string<typename string_adaptor::value_type>());
|
||||||
return false;
|
return false;
|
||||||
} // push_buffering
|
} // push_buffering
|
||||||
|
|
||||||
|
@ -349,7 +359,7 @@ private:
|
||||||
if(n->first == SC::xml)
|
if(n->first == SC::xml)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string_type qName = (n->first.empty()) ? SC::xmlns : SC::xmlns_colon + n->first;
|
string_type qName = (string_adaptor::empty(n->first)) ? SC::xmlns : string_adaptor::concat(SC::xmlns_colon, n->first);
|
||||||
atts_.addAttribute(SC::xmlns_uri,
|
atts_.addAttribute(SC::xmlns_uri,
|
||||||
n->first,
|
n->first,
|
||||||
qName,
|
qName,
|
||||||
|
|
|
@ -37,25 +37,29 @@ public:
|
||||||
private:
|
private:
|
||||||
void validate_name(const string_type& name) const
|
void validate_name(const string_type& name) const
|
||||||
{
|
{
|
||||||
if(name.empty())
|
if(string_adaptor::empty(name))
|
||||||
throw SAX::SAXException("xsl:processing-instruction : name attribute must evaluate to a valid name");
|
throw SAX::SAXException("xsl:processing-instruction : name attribute must evaluate to a valid name");
|
||||||
|
|
||||||
if(!Arabica::XML::is_ncname<string_adaptor>(name))
|
if(!Arabica::XML::is_ncname<string_adaptor>(name))
|
||||||
throw SAX::SAXException("xsl:processing-instruction : '" + string_adaptor::asStdString(name) + "' is not valid as the name");
|
throw SAX::SAXException("xsl:processing-instruction : '" + string_adaptor::asStdString(name) + "' is not valid as the name");
|
||||||
|
|
||||||
if(name.length() != 3)
|
if(string_adaptor::length(name) != 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
typedef Arabica::text::Unicode<char> UnicodeT;
|
typedef Arabica::text::Unicode<char> UnicodeT;
|
||||||
|
|
||||||
if((name[0] != UnicodeT::CAPITAL_X) &&
|
typename string_adaptor::const_iterator i = string_adaptor::begin(name);
|
||||||
(name[0] != UnicodeT::LOWERCASE_X))
|
|
||||||
|
if((*i != UnicodeT::CAPITAL_X) &&
|
||||||
|
(*i != UnicodeT::LOWERCASE_X))
|
||||||
return;
|
return;
|
||||||
if((name[1] != UnicodeT::CAPITAL_M) &&
|
++i;
|
||||||
(name[1] != UnicodeT::LOWERCASE_M))
|
if((*i != UnicodeT::CAPITAL_M) &&
|
||||||
|
(*i != UnicodeT::LOWERCASE_M))
|
||||||
return;
|
return;
|
||||||
if((name[2] != UnicodeT::CAPITAL_L) &&
|
++i;
|
||||||
(name[2] != UnicodeT::LOWERCASE_L))
|
if((*i != UnicodeT::CAPITAL_L) &&
|
||||||
|
(*i != UnicodeT::LOWERCASE_L))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
throw SAX::SAXException("xsl:processing-instruction name can not be 'xml'");
|
throw SAX::SAXException("xsl:processing-instruction name can not be 'xml'");
|
||||||
|
|
|
@ -25,13 +25,19 @@ struct QName
|
||||||
prefix(p),
|
prefix(p),
|
||||||
localName(lN),
|
localName(lN),
|
||||||
namespaceURI(uri),
|
namespaceURI(uri),
|
||||||
qname(p.empty() ? lN : (p + SC::COLON + lN))
|
qname()
|
||||||
{
|
{
|
||||||
|
if(!string_adaptor::empty(p))
|
||||||
|
{
|
||||||
|
string_adaptor::append(qname, p);
|
||||||
|
string_adaptor::append(qname, SC::COLON);
|
||||||
|
} // if ...
|
||||||
|
string_adaptor::append(qname, lN);
|
||||||
} // QName
|
} // QName
|
||||||
|
|
||||||
static QName create(const XML::QualifiedName<string_type>& qName)
|
static QName create(const XML::QualifiedName<string_type>& qName)
|
||||||
{
|
{
|
||||||
if(qName.prefix().length() && qName.namespaceUri().empty())
|
if(string_adaptor::length(qName.prefix()) && string_adaptor::empty(qName.namespaceUri()))
|
||||||
throw SAX::SAXException("Prefix " + string_adaptor::asStdString(qName.prefix()) + " is not declared.");
|
throw SAX::SAXException("Prefix " + string_adaptor::asStdString(qName.prefix()) + " is not declared.");
|
||||||
return QName(qName.prefix(), qName.localName(), qName.namespaceUri());
|
return QName(qName.prefix(), qName.localName(), qName.namespaceUri());
|
||||||
} // create
|
} // create
|
||||||
|
@ -49,14 +55,14 @@ struct QName
|
||||||
string_type prefix;
|
string_type prefix;
|
||||||
string_type localName;
|
string_type localName;
|
||||||
|
|
||||||
size_t colon = qName.find(SC::COLON);
|
size_t colon = string_adaptor::find(qName, SC::COLON);
|
||||||
|
|
||||||
if(colon == string_type::npos)
|
if(colon == string_adaptor::npos())
|
||||||
localName = qName;
|
localName = qName;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prefix = qName.substr(0, colon);
|
prefix = string_adaptor::substr(qName, 0, colon);
|
||||||
localName = qName.substr(colon+1);
|
localName = string_adaptor::substr(qName, colon+1);
|
||||||
}
|
}
|
||||||
return QName(prefix, localName, namespaceURI);
|
return QName(prefix, localName, namespaceURI);
|
||||||
} // create
|
} // create
|
||||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
||||||
{
|
{
|
||||||
stream_ << ' ' << atts.getQName(a) << '=' << '\"';
|
stream_ << ' ' << atts.getQName(a) << '=' << '\"';
|
||||||
string_type ch = atts.getValue(a);
|
string_type ch = atts.getValue(a);
|
||||||
std::for_each(ch.begin(), ch.end(), Arabica::XML::attribute_escaper<typename string_adaptor::value_type>(stream_));
|
std::for_each(string_adaptor::begin(ch), string_adaptor::end(ch), Arabica::XML::attribute_escaper<typename string_adaptor::value_type>(stream_));
|
||||||
stream_ << '\"';
|
stream_ << '\"';
|
||||||
}
|
}
|
||||||
empty_ = true;
|
empty_ = true;
|
||||||
|
@ -175,11 +175,11 @@ protected:
|
||||||
close_element_if_empty();
|
close_element_if_empty();
|
||||||
|
|
||||||
if(!disable_output_escaping_ && !in_cdata_)
|
if(!disable_output_escaping_ && !in_cdata_)
|
||||||
std::for_each(ch.begin(), ch.end(), Arabica::XML::text_escaper<typename string_adaptor::value_type>(stream_));
|
std::for_each(string_adaptor::begin(ch), string_adaptor::end(ch), Arabica::XML::text_escaper<typename string_adaptor::value_type>(stream_));
|
||||||
else if(in_cdata_)
|
else if(in_cdata_)
|
||||||
{
|
{
|
||||||
size_t breakAt = ch.find(SC::CDATAEnd);
|
size_t breakAt = string_adaptor::find(ch, SC::CDATAEnd);
|
||||||
if(breakAt == string_type::npos)
|
if(breakAt == string_adaptor::npos())
|
||||||
{
|
{
|
||||||
stream_ << ch;
|
stream_ << ch;
|
||||||
return;
|
return;
|
||||||
|
@ -188,14 +188,14 @@ protected:
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
breakAt += 2;
|
breakAt += 2;
|
||||||
stream_ << ch.substr(start, breakAt);
|
stream_ << string_adaptor::substr(ch, start, breakAt);
|
||||||
do_end_CDATA();
|
do_end_CDATA();
|
||||||
start = breakAt;
|
start = breakAt;
|
||||||
do_start_CDATA();
|
do_start_CDATA();
|
||||||
breakAt = ch.find(SC::CDATAEnd, breakAt);
|
breakAt = string_adaptor::find(ch, SC::CDATAEnd, breakAt);
|
||||||
}
|
}
|
||||||
while(breakAt != string_type::npos);
|
while(breakAt != string_adaptor::npos());
|
||||||
stream_ << ch.substr(start);
|
stream_ << string_adaptor::substr(ch, start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stream_ << ch;
|
stream_ << ch;
|
||||||
|
@ -294,26 +294,26 @@ private:
|
||||||
|
|
||||||
{
|
{
|
||||||
string_type version = setting(SC::version);
|
string_type version = setting(SC::version);
|
||||||
if(version.empty())
|
if(string_adaptor::empty(version))
|
||||||
version = SC::Version;
|
version = SC::Version;
|
||||||
stream_ << "<?xml version=\"" << version << "\"";
|
stream_ << "<?xml version=\"" << version << "\"";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
string_type s = setting(SC::standalone);
|
string_type s = setting(SC::standalone);
|
||||||
if(!s.empty())
|
if(!string_adaptor::empty(s))
|
||||||
stream_ << " standalone=\"" << s << "\"";
|
stream_ << " standalone=\"" << s << "\"";
|
||||||
}
|
}
|
||||||
stream_ << "?>\n";
|
stream_ << "?>\n";
|
||||||
|
|
||||||
if(!qName.empty())
|
if(!string_adaptor::empty(qName))
|
||||||
{
|
{
|
||||||
string_type pub = setting(SC::doctype_public);
|
string_type pub = setting(SC::doctype_public);
|
||||||
string_type sys = setting(SC::doctype_system);
|
string_type sys = setting(SC::doctype_system);
|
||||||
|
|
||||||
if(!sys.empty())
|
if(!string_adaptor::empty(sys))
|
||||||
{
|
{
|
||||||
stream_ << "<!DOCTYPE " << qName << "\n";
|
stream_ << "<!DOCTYPE " << qName << "\n";
|
||||||
if(!pub.empty())
|
if(!string_adaptor::empty(pub))
|
||||||
stream_ << " PUBLIC \"" << pub << "\" \"" << sys << "\">\n";
|
stream_ << " PUBLIC \"" << pub << "\" \"" << sys << "\">\n";
|
||||||
else
|
else
|
||||||
stream_ << " SYSTEM \"" << sys << "\">\n";
|
stream_ << " SYSTEM \"" << sys << "\">\n";
|
||||||
|
@ -382,7 +382,7 @@ protected:
|
||||||
if(lc == 0 || lc.getNodeType() != DOM::Node_base::TEXT_NODE)
|
if(lc == 0 || lc.getNodeType() != DOM::Node_base::TEXT_NODE)
|
||||||
current().appendChild(document().createTextNode(ch));
|
current().appendChild(document().createTextNode(ch));
|
||||||
else
|
else
|
||||||
lc.setNodeValue(lc.getNodeValue() + ch);
|
lc.setNodeValue(string_adaptor::concat(lc.getNodeValue(), ch));
|
||||||
} // do_characters
|
} // do_characters
|
||||||
|
|
||||||
void do_start_CDATA()
|
void do_start_CDATA()
|
||||||
|
@ -462,9 +462,10 @@ private:
|
||||||
string_type sps;
|
string_type sps;
|
||||||
if(indent_ != 0)
|
if(indent_ != 0)
|
||||||
{
|
{
|
||||||
sps += '\n';
|
std::basic_string<typename string_adaptor::value_type> sps;
|
||||||
std::fill_n(std::back_inserter<string_type>(sps), indent_, ' ');
|
sps += SC::CARRIAGE_RETURN;
|
||||||
do_characters(sps);
|
std::fill_n(std::back_inserter<std::basic_string<typename string_adaptor::value_type> >(sps), indent_, SC::SPACE);
|
||||||
|
do_characters(string_adaptor::construct(sps));
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
indent_ += 2;
|
indent_ += 2;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
|
|
||||||
if(namespaceURI == SC::NamespaceURI)
|
if(namespaceURI == SC::NamespaceURI)
|
||||||
startXSLTElement(namespaceURI, localName, qName, atts);
|
startXSLTElement(namespaceURI, localName, qName, atts);
|
||||||
else if(!namespaceURI.empty())
|
else if(!string_adaptor::empty(namespaceURI))
|
||||||
startForeignElement(namespaceURI, localName, qName, atts);
|
startForeignElement(namespaceURI, localName, qName, atts);
|
||||||
else
|
else
|
||||||
oops(qName);
|
oops(qName);
|
||||||
|
@ -103,7 +103,7 @@ private:
|
||||||
std::map<string_type, string_type> attributes = rules.gather(qName, atts);
|
std::map<string_type, string_type> attributes = rules.gather(qName, atts);
|
||||||
if(attributes[SC::version] != SC::Version)
|
if(attributes[SC::version] != SC::Version)
|
||||||
throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer.");
|
throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer.");
|
||||||
if(!attributes[SC::extension_element_prefixes].empty())
|
if(!string_adaptor::empty(attributes[SC::extension_element_prefixes]))
|
||||||
throw SAX::SAXException("Haven't implemented extension-element-prefixes yet");
|
throw SAX::SAXException("Haven't implemented extension-element-prefixes yet");
|
||||||
} // startStylesheet
|
} // startStylesheet
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ private:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version.empty())
|
if(string_adaptor::empty(version))
|
||||||
throw SAX::SAXException("The source file does not look like a stylesheet.");
|
throw SAX::SAXException("The source file does not look like a stylesheet.");
|
||||||
if(version != SC::Version)
|
if(version != SC::Version)
|
||||||
throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer.");
|
throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer.");
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
mode_(mode),
|
mode_(mode),
|
||||||
precedence_(precedence)
|
precedence_(precedence)
|
||||||
{
|
{
|
||||||
if(!priority.empty())
|
if(!string_adaptor::empty(priority))
|
||||||
{
|
{
|
||||||
double p = boost::lexical_cast<double>(Arabica::text::normalize_whitespace<string_type, string_adaptor>(priority));
|
double p = boost::lexical_cast<double>(Arabica::text::normalize_whitespace<string_type, string_adaptor>(priority));
|
||||||
for(typename MatchExprList::iterator m = matches_.begin(), me = matches_.end(); m != me; ++m)
|
for(typename MatchExprList::iterator m = matches_.begin(), me = matches_.end(); m != me; ++m)
|
||||||
|
@ -58,7 +58,7 @@ public:
|
||||||
} // execute
|
} // execute
|
||||||
|
|
||||||
const MatchExprList& compiled_matches() const { return matches_; }
|
const MatchExprList& compiled_matches() const { return matches_; }
|
||||||
bool has_name() const { return !name_.empty(); }
|
bool has_name() const { return !string_adaptor::empty(name_); }
|
||||||
const string_type& name() const { return name_; }
|
const string_type& name() const { return name_; }
|
||||||
const string_type& mode() const { return mode_; }
|
const string_type& mode() const { return mode_; }
|
||||||
const Precedence& precedence() const { return precedence_; }
|
const Precedence& precedence() const { return precedence_; }
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
{
|
{
|
||||||
typedef Arabica::text::Unicode<typename string_adaptor::value_type> UnicodeT;
|
typedef Arabica::text::Unicode<typename string_adaptor::value_type> UnicodeT;
|
||||||
|
|
||||||
string_type clarkName = namespace_uri.empty() ? name : make_clark_name(namespace_uri, name);
|
string_type clarkName = string_adaptor::empty(namespace_uri) ? name : make_clark_name(namespace_uri, name);
|
||||||
if(std::find(resolutionStack_.begin(), resolutionStack_.end(), clarkName) != resolutionStack_.end())
|
if(std::find(resolutionStack_.begin(), resolutionStack_.end(), clarkName) != resolutionStack_.end())
|
||||||
throw std::runtime_error("Circular dependency: " + string_adaptor::asStdString(clarkName) + " refers to itself directly or indirectly.");
|
throw std::runtime_error("Circular dependency: " + string_adaptor::asStdString(clarkName) + " refers to itself directly or indirectly.");
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@ bool operator<(const silly_string& lhs, const silly_string& rhs)
|
||||||
return lhs.s_ < rhs.s_;
|
return lhs.s_ < rhs.s_;
|
||||||
} // operator<
|
} // operator<
|
||||||
|
|
||||||
|
bool operator>(const silly_string& lhs, const silly_string& rhs)
|
||||||
|
{
|
||||||
|
return lhs.s_ > rhs.s_;
|
||||||
|
} // operator<
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
char silly_string_adaptor::convert_from_utf8(char c)
|
char silly_string_adaptor::convert_from_utf8(char c)
|
||||||
|
@ -125,6 +130,22 @@ void silly_string_adaptor::append(silly_string& str, const silly_string& a)
|
||||||
str.s_.append(a.s_);
|
str.s_.append(a.s_);
|
||||||
} // append
|
} // append
|
||||||
|
|
||||||
|
void silly_string_adaptor::append(silly_string& str, const char& a)
|
||||||
|
{
|
||||||
|
str.s_ += a;
|
||||||
|
} // append
|
||||||
|
|
||||||
|
silly_string silly_string_adaptor::concat(const silly_string& str, const silly_string& a)
|
||||||
|
{
|
||||||
|
return construct(str.s_ + a.s_);
|
||||||
|
}
|
||||||
|
|
||||||
|
silly_string silly_string_adaptor::concat(const silly_string& str, const char& a)
|
||||||
|
{
|
||||||
|
return construct(str.s_ + a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void silly_string_adaptor::insert(silly_string& str, size_type offset, const silly_string& a)
|
void silly_string_adaptor::insert(silly_string& str, size_type offset, const silly_string& a)
|
||||||
{
|
{
|
||||||
str.s_.insert(offset, a.s_);
|
str.s_.insert(offset, a.s_);
|
||||||
|
|
|
@ -26,9 +26,12 @@ private:
|
||||||
friend class silly_string_adaptor;
|
friend class silly_string_adaptor;
|
||||||
friend bool operator<(const silly_string& lhs,
|
friend bool operator<(const silly_string& lhs,
|
||||||
const silly_string& rhs);
|
const silly_string& rhs);
|
||||||
|
friend bool operator>(const silly_string& lhs,
|
||||||
|
const silly_string& rhs);
|
||||||
}; // class silly_string
|
}; // class silly_string
|
||||||
|
|
||||||
bool operator<(const silly_string& lhs, const silly_string& rhs);
|
bool operator<(const silly_string& lhs, const silly_string& rhs);
|
||||||
|
bool operator>(const silly_string& lhs, const silly_string& rhs);
|
||||||
|
|
||||||
class silly_string_adaptor : public Arabica::string_adaptor_tag
|
class silly_string_adaptor : public Arabica::string_adaptor_tag
|
||||||
{
|
{
|
||||||
|
@ -36,6 +39,7 @@ public:
|
||||||
typedef silly_string string_type;
|
typedef silly_string string_type;
|
||||||
typedef std::string::const_iterator const_iterator;
|
typedef std::string::const_iterator const_iterator;
|
||||||
typedef std::string::iterator mutable_iterator;
|
typedef std::string::iterator mutable_iterator;
|
||||||
|
typedef std::string::const_reverse_iterator const_reverse_iterator;
|
||||||
typedef char value_type;
|
typedef char value_type;
|
||||||
typedef std::string::size_type size_type;
|
typedef std::string::size_type size_type;
|
||||||
static size_type npos()
|
static size_type npos()
|
||||||
|
@ -60,6 +64,11 @@ public:
|
||||||
return ss;
|
return ss;
|
||||||
} // construct
|
} // construct
|
||||||
|
|
||||||
|
static silly_string construct(const std::basic_string<value_type>& str)
|
||||||
|
{
|
||||||
|
return construct(str.c_str());
|
||||||
|
} // construct
|
||||||
|
|
||||||
static char convert_from_utf8(char c);
|
static char convert_from_utf8(char c);
|
||||||
static silly_string construct_from_utf8(const char* str);
|
static silly_string construct_from_utf8(const char* str);
|
||||||
static silly_string construct_from_utf8(const char* str, int length);
|
static silly_string construct_from_utf8(const char* str, int length);
|
||||||
|
@ -78,12 +87,16 @@ public:
|
||||||
static silly_string substr(const silly_string& str, const size_type& offset, const size_type& count);
|
static silly_string substr(const silly_string& str, const size_type& offset, const size_type& count);
|
||||||
static size_type length(const silly_string& str);
|
static size_type length(const silly_string& str);
|
||||||
static void append(silly_string& str, const silly_string& a);
|
static void append(silly_string& str, const silly_string& a);
|
||||||
|
static void append(silly_string& str, const char& a);
|
||||||
|
static silly_string concat(const silly_string& str, const silly_string& a);
|
||||||
|
static silly_string concat(const silly_string& str, const char& a);
|
||||||
static void insert(silly_string& str, size_type offset, const silly_string& a);
|
static void insert(silly_string& str, size_type offset, const silly_string& a);
|
||||||
static void replace(silly_string& str, size_type offset, size_type count, const silly_string& a);
|
static void replace(silly_string& str, size_type offset, size_type count, const silly_string& a);
|
||||||
static const_iterator begin(const silly_string& str) { return str.s_.begin(); }
|
static const_iterator begin(const silly_string& str) { return str.s_.begin(); }
|
||||||
static mutable_iterator begin(silly_string& str) { return str.s_.begin(); }
|
static mutable_iterator begin(silly_string& str) { return str.s_.begin(); }
|
||||||
static const_iterator end(const silly_string& str) { return str.s_.end(); }
|
static const_iterator end(const silly_string& str) { return str.s_.end(); }
|
||||||
static mutable_iterator end(silly_string& str) { return str.s_.end(); }
|
static mutable_iterator end(silly_string& str) { return str.s_.end(); }
|
||||||
|
static const_reverse_iterator rbegin(const silly_string& str) { return str.s_.rbegin(); }
|
||||||
|
|
||||||
// mainly used to constuct error strings - don't have to be highly efficient!
|
// mainly used to constuct error strings - don't have to be highly efficient!
|
||||||
static std::string asStdString(const silly_string& str);
|
static std::string asStdString(const silly_string& str);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
@ -40,10 +40,10 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\..\bin\</OutDir>
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\..\bin\</OutDir>
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug_test_xslt\</IntDir>
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug_test_xslt_wide\</IntDir>
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\..\bin\</OutDir>
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\..\bin\</OutDir>
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\Release_test_xslt\</IntDir>
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\Release_test_xslt_wide\</IntDir>
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">xslt_test_wide</TargetName>
|
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">xslt_test_wide</TargetName>
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">xslt_test_wide</TargetName>
|
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">xslt_test_wide</TargetName>
|
||||||
|
|
Loading…
Reference in a new issue