mirror of
https://github.com/jezhiggins/arabica
synced 2024-12-28 22:23:21 +01:00
90 lines
3.5 KiB
C++
90 lines
3.5 KiB
C++
#ifndef ARABICA_XSLT_INLINE_ELEMENT_HANDLER_HPP
|
|
#define ARABICA_XSLT_INLINE_ELEMENT_HANDLER_HPP
|
|
|
|
#include "../xslt_inline_element.hpp"
|
|
#include "xslt_item_container_handler.hpp"
|
|
#include "xslt_constants.hpp"
|
|
|
|
namespace Arabica
|
|
{
|
|
namespace XSLT
|
|
{
|
|
|
|
template<class string_type, class string_adaptor>
|
|
class InlineElementHandler : public ItemContainerHandler<InlineElement<string_type, string_adaptor> >
|
|
{
|
|
typedef ItemContainerHandler<InlineElement<string_type, string_adaptor> > baseT;
|
|
public:
|
|
InlineElementHandler(CompilationContext<string_type, string_adaptor>& context) :
|
|
baseT(context)
|
|
{
|
|
} // InlineElementHandler
|
|
|
|
protected:
|
|
virtual InlineElement<string_type, string_adaptor>* createContainer(const string_type& namespaceURI,
|
|
const string_type& localName,
|
|
const string_type& qName,
|
|
const SAX::Attributes<string_type, string_adaptor>& atts)
|
|
{
|
|
std::vector<InlineAttribute<string_type, string_adaptor> > inlineAtts;
|
|
for(int i = 0; i != atts.getLength(); ++i)
|
|
{
|
|
if(atts.getQName(i).find("xmlns:") == 0)
|
|
continue;
|
|
if(atts.getURI(i) == StylesheetConstant::NamespaceURI())
|
|
continue;
|
|
if(!baseT::context().isRemapped(atts.getURI(i)))
|
|
inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(atts.getQName(i),
|
|
atts.getURI(i),
|
|
baseT::context().xpath_attribute_value_template(atts.getValue(i))));
|
|
else
|
|
{
|
|
std::pair<string_type, string_type> remap = baseT::context().remappedNamespace(atts.getURI(i));
|
|
if(remap.first.empty() && !remap.second.empty())
|
|
remap.first = baseT::context().autoNamespacePrefix();
|
|
string_type name = remap.first + ":" + atts.getLocalName(i);
|
|
inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(name,
|
|
remap.second,
|
|
baseT::context().xpath_attribute_value_template(atts.getValue(i))));
|
|
} // if ...
|
|
} // for ...
|
|
|
|
if(!baseT::context().isRemapped(namespaceURI))
|
|
return new InlineElement<string_type, string_adaptor>(qName, namespaceURI, inlineAtts);
|
|
|
|
const std::pair<string_type, string_type>& remap = baseT::context().remappedNamespace(namespaceURI);
|
|
string_type name = remap.first + ":" + localName;
|
|
return new InlineElement<string_type, string_adaptor>(name, remap.second, inlineAtts);
|
|
} // createContainer
|
|
}; // class InlineElementHandler
|
|
|
|
|
|
template<class string_type, class string_adaptor>
|
|
class LREStylesheetHandler : public InlineElementHandler<string_type, string_adaptor>
|
|
{
|
|
typedef InlineElementHandler<string_type, string_adaptor> baseT;
|
|
public:
|
|
LREStylesheetHandler(CompilationContext<string_type, string_adaptor>& context, Template* lreStylesheet) :
|
|
baseT(context),
|
|
lreStylesheet_(lreStylesheet)
|
|
{
|
|
} // LREStylesheetHandler
|
|
|
|
virtual void endElement(const string_type& namespaceURI,
|
|
const string_type& localName,
|
|
const string_type& qName)
|
|
{
|
|
baseT::context().stylesheet().add_template(lreStylesheet_);
|
|
baseT::endElement(namespaceURI, localName, qName);
|
|
} // endElement
|
|
|
|
private:
|
|
Template* lreStylesheet_;
|
|
}; // class LREStylesheetHandler
|
|
|
|
|
|
} // namespace XSLT
|
|
} // namespace Arabica
|
|
|
|
#endif
|
|
|