libxml2 получает определение xsd для узла

#xsd #libxml2

#xsd #libxml2

Вопрос:

у меня есть XML-файл и .xsd как я могу получить определение узла (ограничения, аннотации …) из схемы после синтаксического анализа и проверки файла с использованием libxml2?

 xmlInitParser();
xmlSchemaPtr schema = NULL;
xmlSchemaParserCtxtPtr schema_parser_ctxt = NULL;
int has_schema_errors = 0;
int ret = -1;
xmlSchemaValidCtxtPtr valid_ctxt = NULL;
schema_parser_ctxt = xmlSchemaNewParserCtxt("test.xsd");
xmlTextReaderPtr reader = NULL;
const char* filename = "file.xml";
reader = xmlReaderForFile(filename, NULL, 0);

if (reader != NULL)
{
    if (valid_ctxt)
        xmlTextReaderSchemaValidateCtxt(reader, valid_ctxt, 0);
    ret = xmlTextReaderRead(reader);
    while (ret == 1 amp;amp; !has_schema_errors)
    {
        ret = xmlTextReaderRead(reader);
        xmlNodePtr node;
        node = xmlTextReaderCurrentNode(reader);
        // here i want get node definition from xsd

    }
}
  

Ответ №1:

Это невозможно с libxml2.