CField* CField::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
{
    assert(pSchemaRoot != NULL);
    assert(pParentNode != NULL);
    assert(pParentNode->getNodeType() == XSD_FIELD_ARRAY);

    if (pSchemaRoot == NULL || pParentNode == NULL)
    {
        // TODO: Throw Exception
        return NULL;
    }

    CField *pField = NULL;

    if (xpath != NULL && *xpath != 0)
    {
        IPropertyTree* pTree = pSchemaRoot->queryPropTree(xpath);

        if (pTree == NULL)
        {
            return NULL;
        }

        const char* pXPath = pSchemaRoot->getPropTree(xpath)->queryProp(XML_ATTR_XPATH);

        assert(pXPath != NULL && *pXPath != 0);

        if (pXPath == NULL || *pXPath == 0)
        {
            assert(!"Throw Exception");
            // TODO: throw exception
        }

        if (pXPath != NULL)
        {
            pField = new CField(pParentNode);
            pField->setXSDXPath(xpath);
            pField->setXPath(pXPath);
        }
        else
        {
            assert(!"xpath can not be be empty!");
            // TODO: throw MakeExceptionFromMap(EX_STR_MISSING_XPATH_IN_FIELD);
        }

        const char *pID = pSchemaRoot->getPropTree(xpath)->queryProp(XML_ATTR_ID);

        if (pID != NULL)
        {
            pField->setID(pID);
        }
   }

    return pField;
}