Example #1
0
ATTR_METHOD_IMPL(CElementParser, OnMaxOccurs)
{
    TRACE_PARSE_ENTRY();

    if (cchValue==sizeof("unbounded")-1 && !wcsncmp(wszValue, L"unbounded", cchValue))
    {
        CElement * pCurr = GetElement();
        if (pCurr != NULL)
        {
            pCurr->SetMaxOccurs(MAXOCCURS_UNBOUNDED);
            return S_OK;
        }
        return E_FAIL;
    }

    int nMaxOccurs = 0;
    nMaxOccurs = _wtoi(wszValue);
    if (nMaxOccurs >= 0)
    {
        //
        // maxOccurs must be >= 0
        //

        CElement * pCurr = GetElement();
        if (pCurr != NULL)
        {
            pCurr->SetMaxOccurs(nMaxOccurs);
            return S_OK;
        }
    }

    EmitInvalidValue("maxOccurs", wszValue);

    return E_FAIL;
}