arabica/include/XSLT/impl/xslt_qname.hpp
jez b559feb7be Added several more variables tests, related the namespace prefixes
fixed internal qname resolution - 2.4 says unprefixed names are not in the default namespace
fixed xsl:element - unprefixed names, when no namespace uri is supplied are in teh default namespace
2008-08-05 22:03:33 +01:00

51 lines
1.1 KiB
C++

#ifndef ARABICA_XSLT_QNAME_HPP
#define ARABICA_XSLT_QNAME_HPP
#include <XML/strings.hpp>
namespace Arabica
{
namespace XSLT
{
struct QName
{
std::string prefix;
std::string localName;
std::string namespaceURI;
static QName createQName(const std::string& qName)
{
if(!Arabica::XML::is_qname(qName))
throw SAX::SAXException("Bad name : " + qName);
static char COLON = Arabica::text::Unicode<char>::COLON;
QName qn;
size_t colon = qName.find(COLON);
if(colon == std::string::npos)
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