#include "xmlscript.h"

// ----------------------------------------------------------------------------
CXmlScript::CXmlScript(const string& pathname)
{
	m_type			= eXmlUiType_Script;
	m_pathname		= pathname;

	m_content.clear();
}

// ----------------------------------------------------------------------------
bool CXmlScript::LoadFromDOMNode(const DOMNode* node)
{
	if ( node == NULL || node->getNodeType() != DOMNode::ELEMENT_NODE )
		return false;

	// Attribute
	DOMNamedNodeMap* nodeMap = node->getAttributes();
	if (nodeMap)
	{
		const XMLCh* nodeValue;
		if ( (nodeValue = GetNodeAttribute(nodeMap, "file")) != NULL )
		{
			char* tmp = XMLString::transcode(nodeValue);
			m_file = m_pathname + tmp;
			XMLString::release(&tmp);
		}
	}

	// script content
	char* tmpStr = XMLString::transcode(node->getTextContent());
	m_content = tmpStr;
	XMLString::release(&tmpStr);	

	return true;
}