mirror of
https://github.com/jezhiggins/arabica
synced 2024-12-27 21:58:30 +01:00
b559feb7be
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
51 lines
1.1 KiB
C++
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
|