예제 #1
0
파일: schema.c 프로젝트: r6144/wine
HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tree)
{
    schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
    cache_entry* entry;
    xmlChar const* ns = NULL;
    TRACE("(%p, %p)\n", This, tree);

    if (!tree)
        return E_POINTER;

    if ((xmlNodePtr)tree->doc == tree)
    {
        xmlNodePtr root = xmlDocGetRootElement(tree->doc);
        if (root && root->ns)
            ns = root->ns->href;
    }
    else if (tree->ns)
    {
        ns = tree->ns->href;
    }

    entry = xmlHashLookup(This->cache, ns);
    /* TODO: if the ns is not in the cache, and it's a URL,
     *       do we try to load from that? */
    if (entry)
    {
        if (entry->type == SCHEMA_TYPE_XDR)
        {
            FIXME("partial stub: XDR schema support not implemented\n");
            return S_OK;
        }
        else if (entry->type == SCHEMA_TYPE_XSD)
        {
            xmlSchemaValidCtxtPtr svctx;
            int err;
            /* TODO: if validateOnLoad property is false,
             *       we probably need to validate the schema here. */
            svctx = xmlSchemaNewValidCtxt(entry->schema);
            xmlSchemaSetValidErrors(svctx, validate_error, validate_warning, NULL);
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
            xmlSchemaSetValidStructuredErrors(svctx, validate_serror, NULL);
#endif

            if ((xmlNodePtr)tree->doc == tree)
                err = xmlSchemaValidateDoc(svctx, (xmlDocPtr)tree);
            else
                err = xmlSchemaValidateOneElement(svctx, tree);

            xmlSchemaFreeValidCtxt(svctx);
            return err? S_FALSE : S_OK;
        }
    }

    return E_FAIL;
}
예제 #2
0
파일: schema.c 프로젝트: ZoloZiak/reactos
static inline HRESULT Schema_validate_tree(xmlSchemaPtr schema, xmlNodePtr tree)
{
    xmlSchemaValidCtxtPtr svctx;
    int err;

    TRACE("(%p, %p)\n", schema, tree);
    /* TODO: if validateOnLoad property is false,
     *       we probably need to validate the schema here. */
    svctx = xmlSchemaNewValidCtxt(schema);
    xmlSchemaSetValidErrors(svctx, validate_error, validate_warning, NULL);
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
    xmlSchemaSetValidStructuredErrors(svctx, validate_serror, NULL);
#endif

    if (tree->type == XML_DOCUMENT_NODE)
        err = xmlSchemaValidateDoc(svctx, (xmlDocPtr)tree);
    else
        err = xmlSchemaValidateOneElement(svctx, tree);

    xmlSchemaFreeValidCtxt(svctx);
    return err? S_FALSE : S_OK;
}