TagDocumentSource::TagDocumentSource(String tagName)
{
	InitStatics();

	// build the document
	document = new Document();
	Element* tagElement = document->CreateElement("tag-name");
	document->AppendChild(tagElement);
	tagText = document->CreateTextNode(tagName);
	tagElement->AppendChild(tagText);
}
Exemplo n.º 2
0
Element* XMLNodeHandlerDefault::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes)
{	
	// Determine the parent
	Element* parent = parser->GetParseFrame()->element;

	// Attempt to instance the element with the instancer
	Element* element = Factory::Instance()->InstanceElement(parent, name, name, attributes);
	if (!element)
	{
		Log::Message(Log::LT_ERROR, "Failed to create element for tag %s, instancer returned NULL.", name.CString());
		return NULL;
	}

	// Add the element to its parent and remove the reference
	parent->AppendChild(element);
	element->RemoveReference();

	return element;
}
Exemplo n.º 3
0
Element* XMLNodeHandlerDynamicImg::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes)
{
    Element* element = NULL;

    ROCKET_ASSERT(name == "dynamic-img");

    if (name == "dynamic-img")
    {
        // Determine the parent
        Element* parent = parser->GetParseFrame()->element;

        // Attempt to instance the element with the instancer
        element = Factory::InstanceElement(parent, name, name, attributes);
        if (!element)
        {
            Log::Message(Log::LT_ERROR, "Failed to create element for tag %s, instancer returned NULL", name.CString());
            return NULL;
        }

        ElementDynamicImage* image = dynamic_cast< ElementDynamicImage* >(element);
        if (image == NULL)
        {
            if (element != NULL)
                element->RemoveReference();

            Log::Message(Rocket::Core::Log::LT_ERROR, "Instancer failed to create image for tag %s.", name.CString());
            return NULL;
        }

        Rocket::Core::String image_source = attributes.Get< Rocket::Core::String >("source", "");
        if (!image_source.Empty())
        {
            image->SetImageSource(image_source);
        }

        // Add the element to its parent and remove the reference
        parent->AppendChild(element);
        element->RemoveReference();
    }

    return element;
}