2007-07-19 19:01:42 +02:00
|
|
|
#ifndef ARABICA_XSLT_QNAME_HPP
|
|
|
|
#define ARABICA_XSLT_QNAME_HPP
|
|
|
|
|
2008-08-05 23:03:33 +02:00
|
|
|
#include <XML/strings.hpp>
|
|
|
|
|
2007-07-19 19:01:42 +02:00
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace XSLT
|
|
|
|
{
|
|
|
|
|
|
|
|
struct QName
|
|
|
|
{
|
|
|
|
std::string prefix;
|
|
|
|
std::string localName;
|
|
|
|
std::string namespaceURI;
|
|
|
|
|
|
|
|
static QName createQName(const std::string& qName)
|
|
|
|
{
|
2008-08-05 23:03:33 +02:00
|
|
|
if(!Arabica::XML::is_qname(qName))
|
|
|
|
throw SAX::SAXException("Bad name : " + qName);
|
|
|
|
|
2007-11-22 23:36:47 +01:00
|
|
|
static char COLON = Arabica::text::Unicode<char>::COLON;
|
2007-07-19 19:01:42 +02:00
|
|
|
QName qn;
|
|
|
|
|
2007-11-22 23:36:47 +01:00
|
|
|
size_t colon = qName.find(COLON);
|
|
|
|
if(colon == std::string::npos)
|
2007-07-19 19:01:42 +02:00
|
|
|
qn.localName = qName;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qn.prefix = qName.substr(0, colon);
|
|
|
|
qn.localName = qName.substr(colon+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return qn;
|
|
|
|
} // createQName
|
|
|
|
|
|
|
|
static QName createQName(const std::string& qName, const std::string namespaceURI)
|
|
|
|
{
|
|
|
|
QName qn(createQName(qName));
|
|
|
|
qn.namespaceURI = namespaceURI;
|
|
|
|
|
|
|
|
if(!qn.prefix.empty() && qn.namespaceURI.empty())
|
|
|
|
throw SAX::SAXException("Undeclared prefix " + qn.prefix);
|
|
|
|
return qn;
|
|
|
|
} // createQName
|
|
|
|
}; // QName
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace XSLT
|
|
|
|
} // namespace Arabica
|
|
|
|
#endif
|