2001-02-23 20:55:21 +03:00
/*
* debugXML . c : This is a set of routines used for debugging the tree
* produced by the XML parser .
*
* See Copyright for the status of this software .
*
2001-06-24 16:13:24 +04:00
* Daniel Veillard < daniel @ veillard . com >
2001-02-23 20:55:21 +03:00
*/
2002-03-18 22:37:11 +03:00
# define IN_LIBXML
2001-04-21 20:57:29 +04:00
# include "libxml.h"
2001-02-23 20:55:21 +03:00
# ifdef LIBXML_DEBUG_ENABLED
# include <string.h>
# include <stdlib.h>
2022-03-02 02:29:17 +03:00
2024-06-16 18:57:12 +03:00
# include <libxml/debugXML.h>
2001-02-23 20:55:21 +03:00
# include <libxml/xmlmemory.h>
# include <libxml/tree.h>
# include <libxml/parser.h>
2001-08-01 19:53:47 +04:00
# include <libxml/parserInternals.h>
2001-02-23 20:55:21 +03:00
# include <libxml/HTMLtree.h>
# include <libxml/HTMLparser.h>
# include <libxml/xmlerror.h>
2022-08-26 02:22:33 +03:00
# include "private/error.h"
2005-08-25 18:03:56 +04:00
# define DUMP_TEXT_TYPE 1
2004-10-04 18:09:17 +04:00
typedef struct _xmlDebugCtxt xmlDebugCtxt ;
typedef xmlDebugCtxt * xmlDebugCtxtPtr ;
struct _xmlDebugCtxt {
FILE * output ; /* the output file */
char shift [ 101 ] ; /* used for indenting */
int depth ; /* current depth */
xmlDocPtr doc ; /* current document */
2004-10-07 17:14:19 +04:00
xmlNodePtr node ; /* current node */
2016-04-13 17:56:07 +03:00
xmlDictPtr dict ; /* the doc dictionary */
2004-10-04 18:09:17 +04:00
int check ; /* do just checkings */
2004-10-07 17:14:19 +04:00
int errors ; /* number of errors found */
2016-04-13 17:56:07 +03:00
int nodict ; /* if the document has no dictionary */
2005-08-25 18:03:56 +04:00
int options ; /* options */
2004-10-04 18:09:17 +04:00
} ;
static void xmlCtxtDumpNodeList ( xmlDebugCtxtPtr ctxt , xmlNodePtr node ) ;
static void
xmlCtxtDumpInitCtxt ( xmlDebugCtxtPtr ctxt )
2001-07-18 23:30:27 +04:00
{
2001-02-23 20:55:21 +03:00
int i ;
2001-07-18 23:30:27 +04:00
2004-10-04 18:09:17 +04:00
ctxt - > depth = 0 ;
ctxt - > check = 0 ;
2004-10-07 17:14:19 +04:00
ctxt - > errors = 0 ;
2004-10-04 18:09:17 +04:00
ctxt - > output = stdout ;
2004-10-26 20:06:51 +04:00
ctxt - > doc = NULL ;
ctxt - > node = NULL ;
ctxt - > dict = NULL ;
2004-10-27 21:29:04 +04:00
ctxt - > nodict = 0 ;
2005-08-25 18:18:56 +04:00
ctxt - > options = 0 ;
2004-10-04 18:09:17 +04:00
for ( i = 0 ; i < 100 ; i + + )
ctxt - > shift [ i ] = ' ' ;
ctxt - > shift [ 100 ] = 0 ;
}
2004-10-10 00:39:04 +04:00
static void
2004-10-15 22:25:33 +04:00
xmlCtxtDumpCleanCtxt ( xmlDebugCtxtPtr ctxt ATTRIBUTE_UNUSED )
2004-10-10 00:39:04 +04:00
{
2004-10-15 22:25:33 +04:00
/* remove the ATTRIBUTE_UNUSED when this is added */
2004-10-10 00:39:04 +04:00
}
/**
2004-10-11 16:28:34 +04:00
* xmlNsCheckScope :
* @ node : the node
* @ ns : the namespace node
2004-10-10 00:39:04 +04:00
*
2004-10-11 16:28:34 +04:00
* Check that a given namespace is in scope on a node .
2004-10-10 00:39:04 +04:00
*
2012-09-11 09:26:36 +04:00
* Returns 1 if in scope , - 1 in case of argument error ,
2004-10-11 16:28:34 +04:00
* - 2 if the namespace is not in scope , and - 3 if not on
* an ancestor node .
2004-10-10 00:39:04 +04:00
*/
static int
2004-10-11 16:28:34 +04:00
xmlNsCheckScope ( xmlNodePtr node , xmlNsPtr ns )
2004-10-10 00:39:04 +04:00
{
2004-10-11 16:28:34 +04:00
xmlNsPtr cur ;
2004-10-10 00:39:04 +04:00
2004-10-11 16:28:34 +04:00
if ( ( node = = NULL ) | | ( ns = = NULL ) )
return ( - 1 ) ;
if ( ( node - > type ! = XML_ELEMENT_NODE ) & &
( node - > type ! = XML_ATTRIBUTE_NODE ) & &
( node - > type ! = XML_DOCUMENT_NODE ) & &
( node - > type ! = XML_TEXT_NODE ) & &
( node - > type ! = XML_HTML_DOCUMENT_NODE ) & &
( node - > type ! = XML_XINCLUDE_START ) )
return ( - 2 ) ;
2004-10-10 00:39:04 +04:00
2004-10-11 16:28:34 +04:00
while ( ( node ! = NULL ) & &
( ( node - > type = = XML_ELEMENT_NODE ) | |
( node - > type = = XML_ATTRIBUTE_NODE ) | |
( node - > type = = XML_TEXT_NODE ) | |
( node - > type = = XML_XINCLUDE_START ) ) ) {
if ( ( node - > type = = XML_ELEMENT_NODE ) | |
( node - > type = = XML_XINCLUDE_START ) ) {
cur = node - > nsDef ;
while ( cur ! = NULL ) {
if ( cur = = ns )
return ( 1 ) ;
if ( xmlStrEqual ( cur - > prefix , ns - > prefix ) )
return ( - 2 ) ;
cur = cur - > next ;
}
}
node = node - > parent ;
2004-10-10 00:39:04 +04:00
}
2024-03-17 18:23:31 +03:00
/* the xml namespace may be declared on the document node */
if ( ( node ! = NULL ) & &
( ( node - > type = = XML_DOCUMENT_NODE ) | |
( node - > type = = XML_HTML_DOCUMENT_NODE ) ) ) {
xmlNsPtr oldNs = ( ( xmlDocPtr ) node ) - > oldNs ;
if ( oldNs = = ns )
return ( 1 ) ;
}
2004-10-11 16:28:34 +04:00
return ( - 3 ) ;
2004-10-10 00:39:04 +04:00
}
2004-10-11 16:28:34 +04:00
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpSpaces ( xmlDebugCtxtPtr ctxt )
{
if ( ctxt - > check )
return ;
if ( ( ctxt - > output ! = NULL ) & & ( ctxt - > depth > 0 ) ) {
if ( ctxt - > depth < 50 )
2009-06-04 13:22:45 +04:00
fprintf ( ctxt - > output , " %s " , & ctxt - > shift [ 100 - 2 * ctxt - > depth ] ) ;
2004-10-04 18:09:17 +04:00
else
2009-06-04 13:22:45 +04:00
fprintf ( ctxt - > output , " %s " , ctxt - > shift ) ;
2004-10-04 18:09:17 +04:00
}
}
2004-10-07 17:14:19 +04:00
/**
* xmlDebugErr :
* @ ctxt : a debug context
* @ error : the error code
*
* Handle a debug error .
*/
static void
xmlDebugErr ( xmlDebugCtxtPtr ctxt , int error , const char * msg )
{
ctxt - > errors + + ;
2023-12-18 23:09:39 +03:00
fprintf ( ctxt - > output , " ERROR %d: %s " , error , msg ) ;
2004-10-07 17:14:19 +04:00
}
2016-05-13 10:13:17 +03:00
static void LIBXML_ATTR_FORMAT ( 3 , 0 )
2004-10-07 17:14:19 +04:00
xmlDebugErr2 ( xmlDebugCtxtPtr ctxt , int error , const char * msg , int extra )
{
ctxt - > errors + + ;
2023-12-18 23:09:39 +03:00
fprintf ( ctxt - > output , " ERROR %d: " , error ) ;
fprintf ( ctxt - > output , msg , extra ) ;
2004-10-07 17:14:19 +04:00
}
2016-05-13 10:13:17 +03:00
static void LIBXML_ATTR_FORMAT ( 3 , 0 )
2004-10-15 18:50:10 +04:00
xmlDebugErr3 ( xmlDebugCtxtPtr ctxt , int error , const char * msg , const char * extra )
2004-10-07 17:14:19 +04:00
{
ctxt - > errors + + ;
2023-12-18 23:09:39 +03:00
fprintf ( ctxt - > output , " ERROR %d: " , error ) ;
fprintf ( ctxt - > output , msg , extra ) ;
2004-10-07 17:14:19 +04:00
}
2004-10-11 16:28:34 +04:00
/**
* xmlCtxtNsCheckScope :
* @ ctxt : the debugging context
* @ node : the node
* @ ns : the namespace node
*
* Report if a given namespace is is not in scope .
*/
static void
xmlCtxtNsCheckScope ( xmlDebugCtxtPtr ctxt , xmlNodePtr node , xmlNsPtr ns )
{
int ret ;
ret = xmlNsCheckScope ( node , ns ) ;
if ( ret = = - 2 ) {
if ( ns - > prefix = = NULL )
xmlDebugErr ( ctxt , XML_CHECK_NS_SCOPE ,
" Reference to default namespace not in scope \n " ) ;
else
xmlDebugErr3 ( ctxt , XML_CHECK_NS_SCOPE ,
" Reference to namespace '%s' not in scope \n " ,
( char * ) ns - > prefix ) ;
}
if ( ret = = - 3 ) {
if ( ns - > prefix = = NULL )
xmlDebugErr ( ctxt , XML_CHECK_NS_ANCESTOR ,
" Reference to default namespace not on ancestor \n " ) ;
else
xmlDebugErr3 ( ctxt , XML_CHECK_NS_ANCESTOR ,
" Reference to namespace '%s' not on ancestor \n " ,
( char * ) ns - > prefix ) ;
}
}
2004-10-15 18:50:10 +04:00
/**
* xmlCtxtCheckString :
* @ ctxt : the debug context
* @ str : the string
*
* Do debugging on the string , currently it just checks the UTF - 8 content
*/
static void
xmlCtxtCheckString ( xmlDebugCtxtPtr ctxt , const xmlChar * str )
{
if ( str = = NULL ) return ;
if ( ctxt - > check ) {
if ( ! xmlCheckUTF8 ( str ) ) {
2004-10-26 20:06:51 +04:00
xmlDebugErr3 ( ctxt , XML_CHECK_NOT_UTF8 ,
2004-10-15 18:50:10 +04:00
" String is not UTF-8 %s " , ( const char * ) str ) ;
}
}
}
2004-10-26 20:06:51 +04:00
/**
* xmlCtxtCheckName :
* @ ctxt : the debug context
* @ name : the name
*
2016-04-13 17:56:07 +03:00
* Do debugging on the name , for example the dictionary status and
2004-10-26 20:06:51 +04:00
* conformance to the Name production .
*/
static void
xmlCtxtCheckName ( xmlDebugCtxtPtr ctxt , const xmlChar * name )
{
if ( ctxt - > check ) {
if ( name = = NULL ) {
xmlDebugErr ( ctxt , XML_CHECK_NO_NAME , " Name is NULL " ) ;
return ;
}
if ( xmlValidateName ( name , 0 ) ) {
xmlDebugErr3 ( ctxt , XML_CHECK_NOT_NCNAME ,
" Name is not an NCName '%s' " , ( const char * ) name ) ;
}
if ( ( ctxt - > dict ! = NULL ) & &
2009-07-29 13:34:50 +04:00
( ! xmlDictOwns ( ctxt - > dict , name ) ) & &
( ( ctxt - > doc = = NULL ) | |
( ( ctxt - > doc - > parseFlags & ( XML_PARSE_SAX1 | XML_PARSE_NODICT ) ) = = 0 ) ) ) {
2004-10-26 20:06:51 +04:00
xmlDebugErr3 ( ctxt , XML_CHECK_OUTSIDE_DICT ,
2016-04-13 17:56:07 +03:00
" Name is not from the document dictionary '%s' " ,
2004-10-26 20:06:51 +04:00
( const char * ) name ) ;
}
}
}
2004-10-07 17:14:19 +04:00
static void
xmlCtxtGenericNodeCheck ( xmlDebugCtxtPtr ctxt , xmlNodePtr node ) {
2004-10-26 20:06:51 +04:00
xmlDocPtr doc ;
xmlDictPtr dict ;
doc = node - > doc ;
2004-10-07 17:14:19 +04:00
if ( node - > parent = = NULL )
xmlDebugErr ( ctxt , XML_CHECK_NO_PARENT ,
" Node has no parent \n " ) ;
2004-10-26 20:06:51 +04:00
if ( node - > doc = = NULL ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_DOC ,
" Node has no doc \n " ) ;
2004-10-26 20:06:51 +04:00
dict = NULL ;
} else {
dict = doc - > dict ;
if ( ( dict = = NULL ) & & ( ctxt - > nodict = = 0 ) ) {
2004-10-27 21:29:04 +04:00
#if 0
2019-09-30 18:04:54 +03:00
/* deactivated right now as it raises too many errors */
2004-10-27 21:29:04 +04:00
if ( doc - > type = = XML_DOCUMENT_NODE )
xmlDebugErr ( ctxt , XML_CHECK_NO_DICT ,
2016-04-13 17:56:07 +03:00
" Document has no dictionary \n " ) ;
2004-10-27 21:29:04 +04:00
# endif
2004-10-26 20:06:51 +04:00
ctxt - > nodict = 1 ;
}
if ( ctxt - > doc = = NULL )
ctxt - > doc = doc ;
if ( ctxt - > dict = = NULL ) {
ctxt - > dict = dict ;
}
}
2004-10-07 17:14:19 +04:00
if ( ( node - > parent ! = NULL ) & & ( node - > doc ! = node - > parent - > doc ) & &
( ! xmlStrEqual ( node - > name , BAD_CAST " pseudoroot " ) ) )
xmlDebugErr ( ctxt , XML_CHECK_WRONG_DOC ,
" Node doc differs from parent's one \n " ) ;
if ( node - > prev = = NULL ) {
if ( node - > type = = XML_ATTRIBUTE_NODE ) {
if ( ( node - > parent ! = NULL ) & &
( node ! = ( xmlNodePtr ) node - > parent - > properties ) )
xmlDebugErr ( ctxt , XML_CHECK_NO_PREV ,
" Attr has no prev and not first of attr list \n " ) ;
2012-09-11 09:26:36 +04:00
2004-10-07 17:14:19 +04:00
} else if ( ( node - > parent ! = NULL ) & & ( node - > parent - > children ! = node ) )
xmlDebugErr ( ctxt , XML_CHECK_NO_PREV ,
" Node has no prev and not first of parent list \n " ) ;
} else {
if ( node - > prev - > next ! = node )
xmlDebugErr ( ctxt , XML_CHECK_WRONG_PREV ,
" Node prev->next : back link wrong \n " ) ;
}
if ( node - > next = = NULL ) {
if ( ( node - > parent ! = NULL ) & & ( node - > type ! = XML_ATTRIBUTE_NODE ) & &
2008-03-25 19:52:41 +03:00
( node - > parent - > last ! = node ) & &
( node - > parent - > type = = XML_ELEMENT_NODE ) )
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_NEXT ,
" Node has no next and not last of parent list \n " ) ;
} else {
if ( node - > next - > prev ! = node )
xmlDebugErr ( ctxt , XML_CHECK_WRONG_NEXT ,
" Node next->prev : forward link wrong \n " ) ;
2004-10-11 16:28:34 +04:00
if ( node - > next - > parent ! = node - > parent )
xmlDebugErr ( ctxt , XML_CHECK_WRONG_PARENT ,
" Node next->prev : forward link wrong \n " ) ;
2004-10-07 17:14:19 +04:00
}
2004-10-11 16:28:34 +04:00
if ( node - > type = = XML_ELEMENT_NODE ) {
xmlNsPtr ns ;
ns = node - > nsDef ;
while ( ns ! = NULL ) {
xmlCtxtNsCheckScope ( ctxt , node , ns ) ;
ns = ns - > next ;
}
if ( node - > ns ! = NULL )
xmlCtxtNsCheckScope ( ctxt , node , node - > ns ) ;
} else if ( node - > type = = XML_ATTRIBUTE_NODE ) {
if ( node - > ns ! = NULL )
xmlCtxtNsCheckScope ( ctxt , node , node - > ns ) ;
}
2004-10-15 18:50:10 +04:00
if ( ( node - > type ! = XML_ELEMENT_NODE ) & &
2004-10-15 22:25:33 +04:00
( node - > type ! = XML_ATTRIBUTE_NODE ) & &
2005-06-30 17:04:44 +04:00
( node - > type ! = XML_ELEMENT_DECL ) & &
2004-10-15 22:25:33 +04:00
( node - > type ! = XML_ATTRIBUTE_DECL ) & &
( node - > type ! = XML_DTD_NODE ) & &
( node - > type ! = XML_HTML_DOCUMENT_NODE ) & &
( node - > type ! = XML_DOCUMENT_NODE ) ) {
2004-10-15 18:50:10 +04:00
if ( node - > content ! = NULL )
2004-10-15 22:25:33 +04:00
xmlCtxtCheckString ( ctxt , ( const xmlChar * ) node - > content ) ;
2004-10-15 18:50:10 +04:00
}
2004-10-26 20:06:51 +04:00
switch ( node - > type ) {
case XML_ELEMENT_NODE :
case XML_ATTRIBUTE_NODE :
xmlCtxtCheckName ( ctxt , node - > name ) ;
break ;
case XML_TEXT_NODE :
if ( ( node - > name = = xmlStringText ) | |
( node - > name = = xmlStringTextNoenc ) )
break ;
/* some case of entity substitution can lead to this */
if ( ( ctxt - > dict ! = NULL ) & &
2004-10-27 21:29:04 +04:00
( node - > name = = xmlDictLookup ( ctxt - > dict , BAD_CAST " nbktext " ,
7 ) ) )
2004-10-26 20:06:51 +04:00
break ;
xmlDebugErr3 ( ctxt , XML_CHECK_WRONG_NAME ,
" Text node has wrong name '%s' " ,
( const char * ) node - > name ) ;
break ;
case XML_COMMENT_NODE :
if ( node - > name = = xmlStringComment )
break ;
xmlDebugErr3 ( ctxt , XML_CHECK_WRONG_NAME ,
" Comment node has wrong name '%s' " ,
( const char * ) node - > name ) ;
break ;
case XML_PI_NODE :
xmlCtxtCheckName ( ctxt , node - > name ) ;
break ;
case XML_CDATA_SECTION_NODE :
if ( node - > name = = NULL )
break ;
xmlDebugErr3 ( ctxt , XML_CHECK_NAME_NOT_NULL ,
" CData section has non NULL name '%s' " ,
( const char * ) node - > name ) ;
break ;
case XML_ENTITY_REF_NODE :
case XML_ENTITY_NODE :
case XML_DOCUMENT_TYPE_NODE :
case XML_DOCUMENT_FRAG_NODE :
case XML_NOTATION_NODE :
case XML_DTD_NODE :
case XML_ELEMENT_DECL :
case XML_ATTRIBUTE_DECL :
case XML_ENTITY_DECL :
case XML_NAMESPACE_DECL :
case XML_XINCLUDE_START :
case XML_XINCLUDE_END :
case XML_DOCUMENT_NODE :
case XML_HTML_DOCUMENT_NODE :
break ;
}
2004-10-07 17:14:19 +04:00
}
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpString ( xmlDebugCtxtPtr ctxt , const xmlChar * str )
{
int i ;
2004-10-15 18:50:10 +04:00
if ( ctxt - > check ) {
2004-10-04 18:09:17 +04:00
return ;
2004-10-15 18:50:10 +04:00
}
2004-10-04 18:09:17 +04:00
/* TODO: check UTF8 content of the string */
2001-02-23 20:55:21 +03:00
if ( str = = NULL ) {
2004-10-04 18:09:17 +04:00
fprintf ( ctxt - > output , " (NULL) " ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
for ( i = 0 ; i < 40 ; i + + )
if ( str [ i ] = = 0 )
return ;
2003-10-18 20:20:14 +04:00
else if ( IS_BLANK_CH ( str [ i ] ) )
2004-10-04 18:09:17 +04:00
fputc ( ' ' , ctxt - > output ) ;
2001-07-18 23:30:27 +04:00
else if ( str [ i ] > = 0x80 )
2004-10-04 18:09:17 +04:00
fprintf ( ctxt - > output , " #%X " , str [ i ] ) ;
2001-07-18 23:30:27 +04:00
else
2004-10-04 18:09:17 +04:00
fputc ( str [ i ] , ctxt - > output ) ;
fprintf ( ctxt - > output , " ... " ) ;
2001-02-23 20:55:21 +03:00
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpDtdNode ( xmlDebugCtxtPtr ctxt , xmlDtdPtr dtd )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( dtd = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " DTD node is NULL \n " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2001-02-23 20:55:21 +03:00
if ( dtd - > type ! = XML_DTD_NODE ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NOT_DTD ,
" Node is not a DTD " ) ;
2004-10-04 18:09:17 +04:00
return ;
}
if ( ! ctxt - > check ) {
if ( dtd - > name ! = NULL )
fprintf ( ctxt - > output , " DTD(%s) " , ( char * ) dtd - > name ) ;
else
fprintf ( ctxt - > output , " DTD " ) ;
if ( dtd - > ExternalID ! = NULL )
fprintf ( ctxt - > output , " , PUBLIC %s " , ( char * ) dtd - > ExternalID ) ;
if ( dtd - > SystemID ! = NULL )
fprintf ( ctxt - > output , " , SYSTEM %s " , ( char * ) dtd - > SystemID ) ;
fprintf ( ctxt - > output , " \n " ) ;
2001-02-23 20:55:21 +03:00
}
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , ( xmlNodePtr ) dtd ) ;
2001-02-23 20:55:21 +03:00
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpAttrDecl ( xmlDebugCtxtPtr ctxt , xmlAttributePtr attr )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( attr = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Attribute declaration is NULL \n " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2001-02-23 20:55:21 +03:00
if ( attr - > type ! = XML_ATTRIBUTE_DECL ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NOT_ATTR_DECL ,
" Node is not an attribute declaration " ) ;
2004-10-04 18:09:17 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
if ( attr - > name ! = NULL ) {
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " ATTRDECL(%s) " , ( char * ) attr - > name ) ;
} else
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_NAME ,
" Node attribute declaration has no name " ) ;
2004-10-04 18:09:17 +04:00
if ( attr - > elem ! = NULL ) {
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " for %s " , ( char * ) attr - > elem ) ;
} else
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_ELEM ,
" Node attribute declaration has no element name " ) ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
switch ( attr - > atype ) {
case XML_ATTRIBUTE_CDATA :
fprintf ( ctxt - > output , " CDATA " ) ;
break ;
case XML_ATTRIBUTE_ID :
fprintf ( ctxt - > output , " ID " ) ;
break ;
case XML_ATTRIBUTE_IDREF :
fprintf ( ctxt - > output , " IDREF " ) ;
break ;
case XML_ATTRIBUTE_IDREFS :
fprintf ( ctxt - > output , " IDREFS " ) ;
break ;
case XML_ATTRIBUTE_ENTITY :
fprintf ( ctxt - > output , " ENTITY " ) ;
break ;
case XML_ATTRIBUTE_ENTITIES :
fprintf ( ctxt - > output , " ENTITIES " ) ;
break ;
case XML_ATTRIBUTE_NMTOKEN :
fprintf ( ctxt - > output , " NMTOKEN " ) ;
break ;
case XML_ATTRIBUTE_NMTOKENS :
fprintf ( ctxt - > output , " NMTOKENS " ) ;
break ;
case XML_ATTRIBUTE_ENUMERATION :
fprintf ( ctxt - > output , " ENUMERATION " ) ;
break ;
case XML_ATTRIBUTE_NOTATION :
fprintf ( ctxt - > output , " NOTATION " ) ;
break ;
}
if ( attr - > tree ! = NULL ) {
int indx ;
xmlEnumerationPtr cur = attr - > tree ;
for ( indx = 0 ; indx < 5 ; indx + + ) {
if ( indx ! = 0 )
fprintf ( ctxt - > output , " |%s " , ( char * ) cur - > name ) ;
else
fprintf ( ctxt - > output , " (%s " , ( char * ) cur - > name ) ;
cur = cur - > next ;
if ( cur = = NULL )
break ;
}
if ( cur = = NULL )
fprintf ( ctxt - > output , " ) " ) ;
else
fprintf ( ctxt - > output , " ...) " ) ;
}
switch ( attr - > def ) {
case XML_ATTRIBUTE_NONE :
break ;
case XML_ATTRIBUTE_REQUIRED :
fprintf ( ctxt - > output , " REQUIRED " ) ;
break ;
case XML_ATTRIBUTE_IMPLIED :
fprintf ( ctxt - > output , " IMPLIED " ) ;
break ;
case XML_ATTRIBUTE_FIXED :
fprintf ( ctxt - > output , " FIXED " ) ;
break ;
}
if ( attr - > defaultValue ! = NULL ) {
fprintf ( ctxt - > output , " \" " ) ;
xmlCtxtDumpString ( ctxt , attr - > defaultValue ) ;
fprintf ( ctxt - > output , " \" " ) ;
}
fprintf ( ctxt - > output , " \n " ) ;
2001-02-23 20:55:21 +03:00
}
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , ( xmlNodePtr ) attr ) ;
2001-02-23 20:55:21 +03:00
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpElemDecl ( xmlDebugCtxtPtr ctxt , xmlElementPtr elem )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( elem = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Element declaration is NULL \n " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2001-02-23 20:55:21 +03:00
if ( elem - > type ! = XML_ELEMENT_DECL ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NOT_ELEM_DECL ,
" Node is not an element declaration " ) ;
2004-10-04 18:09:17 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
if ( elem - > name ! = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
fprintf ( ctxt - > output , " ELEMDECL( " ) ;
xmlCtxtDumpString ( ctxt , elem - > name ) ;
fprintf ( ctxt - > output , " ) " ) ;
}
2001-02-23 20:55:21 +03:00
} else
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_NAME ,
" Element declaration has no name " ) ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
switch ( elem - > etype ) {
case XML_ELEMENT_TYPE_UNDEFINED :
fprintf ( ctxt - > output , " , UNDEFINED " ) ;
break ;
case XML_ELEMENT_TYPE_EMPTY :
fprintf ( ctxt - > output , " , EMPTY " ) ;
break ;
case XML_ELEMENT_TYPE_ANY :
fprintf ( ctxt - > output , " , ANY " ) ;
break ;
case XML_ELEMENT_TYPE_MIXED :
fprintf ( ctxt - > output , " , MIXED " ) ;
break ;
case XML_ELEMENT_TYPE_ELEMENT :
fprintf ( ctxt - > output , " , MIXED " ) ;
break ;
}
if ( ( elem - > type ! = XML_ELEMENT_NODE ) & & ( elem - > content ! = NULL ) ) {
char buf [ 5001 ] ;
buf [ 0 ] = 0 ;
xmlSnprintfElementContent ( buf , 5000 , elem - > content , 1 ) ;
buf [ 5000 ] = 0 ;
fprintf ( ctxt - > output , " %s " , buf ) ;
}
fprintf ( ctxt - > output , " \n " ) ;
2001-02-23 20:55:21 +03:00
}
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , ( xmlNodePtr ) elem ) ;
2001-02-23 20:55:21 +03:00
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpEntityDecl ( xmlDebugCtxtPtr ctxt , xmlEntityPtr ent )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( ent = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Entity declaration is NULL \n " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2001-02-23 20:55:21 +03:00
if ( ent - > type ! = XML_ENTITY_DECL ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NOT_ENTITY_DECL ,
" Node is not an entity declaration " ) ;
2004-10-04 18:09:17 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
if ( ent - > name ! = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
fprintf ( ctxt - > output , " ENTITYDECL( " ) ;
xmlCtxtDumpString ( ctxt , ent - > name ) ;
fprintf ( ctxt - > output , " ) " ) ;
}
2001-02-23 20:55:21 +03:00
} else
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_NAME ,
" Entity declaration has no name " ) ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
switch ( ent - > etype ) {
case XML_INTERNAL_GENERAL_ENTITY :
fprintf ( ctxt - > output , " , internal \n " ) ;
break ;
case XML_EXTERNAL_GENERAL_PARSED_ENTITY :
fprintf ( ctxt - > output , " , external parsed \n " ) ;
break ;
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY :
fprintf ( ctxt - > output , " , unparsed \n " ) ;
break ;
case XML_INTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " , parameter \n " ) ;
break ;
case XML_EXTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " , external parameter \n " ) ;
break ;
case XML_INTERNAL_PREDEFINED_ENTITY :
fprintf ( ctxt - > output , " , predefined \n " ) ;
break ;
}
if ( ent - > ExternalID ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " ExternalID=%s \n " ,
( char * ) ent - > ExternalID ) ;
}
if ( ent - > SystemID ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " SystemID=%s \n " ,
( char * ) ent - > SystemID ) ;
}
if ( ent - > URI ! = NULL ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " URI=%s \n " , ( char * ) ent - > URI ) ;
}
if ( ent - > content ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " content= " ) ;
xmlCtxtDumpString ( ctxt , ent - > content ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
2001-02-23 20:55:21 +03:00
}
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , ( xmlNodePtr ) ent ) ;
2001-02-23 20:55:21 +03:00
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespace ( xmlDebugCtxtPtr ctxt , xmlNsPtr ns )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2002-01-23 00:44:25 +03:00
if ( ns = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " namespace node is NULL \n " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2001-02-23 20:55:21 +03:00
if ( ns - > type ! = XML_NAMESPACE_DECL ) {
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NOT_NS_DECL ,
" Node is not a namespace declaration " ) ;
2004-10-04 18:09:17 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
if ( ns - > href = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ns - > prefix ! = NULL )
2004-10-07 17:14:19 +04:00
xmlDebugErr3 ( ctxt , XML_CHECK_NO_HREF ,
" Incomplete namespace %s href=NULL \n " ,
2004-10-04 18:09:17 +04:00
( char * ) ns - > prefix ) ;
else
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_NO_HREF ,
" Incomplete default namespace href=NULL \n " ) ;
2001-02-23 20:55:21 +03:00
} else {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
if ( ns - > prefix ! = NULL )
fprintf ( ctxt - > output , " namespace %s href= " ,
( char * ) ns - > prefix ) ;
else
fprintf ( ctxt - > output , " default namespace href= " ) ;
2001-02-23 20:55:21 +03:00
2004-10-04 18:09:17 +04:00
xmlCtxtDumpString ( ctxt , ns - > href ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
2001-02-23 20:55:21 +03:00
}
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespaceList ( xmlDebugCtxtPtr ctxt , xmlNsPtr ns )
{
2001-02-23 20:55:21 +03:00
while ( ns ! = NULL ) {
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespace ( ctxt , ns ) ;
ns = ns - > next ;
2001-02-23 20:55:21 +03:00
}
}
2001-03-24 20:00:36 +03:00
static void
2004-10-04 18:09:17 +04:00
xmlCtxtDumpEntity ( xmlDebugCtxtPtr ctxt , xmlEntityPtr ent )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( ent = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Entity is NULL \n " ) ;
return ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
switch ( ent - > etype ) {
case XML_INTERNAL_GENERAL_ENTITY :
fprintf ( ctxt - > output , " INTERNAL_GENERAL_ENTITY " ) ;
break ;
case XML_EXTERNAL_GENERAL_PARSED_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL_GENERAL_PARSED_ENTITY " ) ;
break ;
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL_GENERAL_UNPARSED_ENTITY " ) ;
break ;
case XML_INTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " INTERNAL_PARAMETER_ENTITY " ) ;
break ;
case XML_EXTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL_PARAMETER_ENTITY " ) ;
break ;
default :
fprintf ( ctxt - > output , " ENTITY_%d ! " , ( int ) ent - > etype ) ;
}
fprintf ( ctxt - > output , " %s \n " , ent - > name ) ;
if ( ent - > ExternalID ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " ExternalID=%s \n " ,
( char * ) ent - > ExternalID ) ;
}
if ( ent - > SystemID ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " SystemID=%s \n " , ( char * ) ent - > SystemID ) ;
}
if ( ent - > URI ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " URI=%s \n " , ( char * ) ent - > URI ) ;
}
if ( ent - > content ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " content= " ) ;
xmlCtxtDumpString ( ctxt , ent - > content ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
2001-02-23 20:55:21 +03:00
}
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpAttr :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ attr : the attribute
* @ depth : the indentation level .
*
* Dumps debug information for the attribute
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpAttr ( xmlDebugCtxtPtr ctxt , xmlAttrPtr attr )
{
xmlCtxtDumpSpaces ( ctxt ) ;
2001-02-23 20:55:21 +03:00
2002-01-23 00:44:25 +03:00
if ( attr = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Attr is NULL " ) ;
return ;
}
if ( ! ctxt - > check ) {
fprintf ( ctxt - > output , " ATTRIBUTE " ) ;
2004-10-07 17:14:19 +04:00
xmlCtxtDumpString ( ctxt , attr - > name ) ;
2004-10-04 18:09:17 +04:00
fprintf ( ctxt - > output , " \n " ) ;
if ( attr - > children ! = NULL ) {
ctxt - > depth + + ;
xmlCtxtDumpNodeList ( ctxt , attr - > children ) ;
ctxt - > depth - - ;
}
2002-01-23 00:44:25 +03:00
}
2004-10-07 17:14:19 +04:00
if ( attr - > name = = NULL )
xmlDebugErr ( ctxt , XML_CHECK_NO_NAME ,
" Attribute has no name " ) ;
2001-02-23 20:55:21 +03:00
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , ( xmlNodePtr ) attr ) ;
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpAttrList :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ attr : the attribute list
* @ depth : the indentation level .
*
* Dumps debug information for the attribute list
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpAttrList ( xmlDebugCtxtPtr ctxt , xmlAttrPtr attr )
2001-07-18 23:30:27 +04:00
{
2001-02-23 20:55:21 +03:00
while ( attr ! = NULL ) {
2004-10-04 18:09:17 +04:00
xmlCtxtDumpAttr ( ctxt , attr ) ;
2001-07-18 23:30:27 +04:00
attr = attr - > next ;
2001-02-23 20:55:21 +03:00
}
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpOneNode :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ node : the node
* @ depth : the indentation level .
*
* Dumps debug information for the element node , it is not recursive
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpOneNode ( xmlDebugCtxtPtr ctxt , xmlNodePtr node )
2001-07-18 23:30:27 +04:00
{
2002-01-23 00:44:25 +03:00
if ( node = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " node is NULL \n " ) ;
}
return ;
2002-01-23 00:44:25 +03:00
}
2004-10-07 17:14:19 +04:00
ctxt - > node = node ;
2001-02-23 20:55:21 +03:00
switch ( node - > type ) {
2001-07-18 23:30:27 +04:00
case XML_ELEMENT_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " ELEMENT " ) ;
if ( ( node - > ns ! = NULL ) & & ( node - > ns - > prefix ! = NULL ) ) {
xmlCtxtDumpString ( ctxt , node - > ns - > prefix ) ;
fprintf ( ctxt - > output , " : " ) ;
}
xmlCtxtDumpString ( ctxt , node - > name ) ;
fprintf ( ctxt - > output , " \n " ) ;
2001-07-18 23:30:27 +04:00
}
break ;
case XML_ATTRIBUTE_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " Error, ATTRIBUTE found here \n " ) ;
2004-12-18 00:38:09 +03:00
xmlCtxtGenericNodeCheck ( ctxt , node ) ;
return ;
2001-07-18 23:30:27 +04:00
case XML_TEXT_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
if ( node - > name = = ( const xmlChar * ) xmlStringTextNoenc )
2005-08-25 17:19:21 +04:00
fprintf ( ctxt - > output , " TEXT no enc " ) ;
2004-10-04 18:09:17 +04:00
else
2005-08-25 17:19:21 +04:00
fprintf ( ctxt - > output , " TEXT " ) ;
2005-08-25 18:03:56 +04:00
if ( ctxt - > options & DUMP_TEXT_TYPE ) {
if ( node - > content = = ( xmlChar * ) & ( node - > properties ) )
fprintf ( ctxt - > output , " compact \n " ) ;
else if ( xmlDictOwns ( ctxt - > dict , node - > content ) = = 1 )
fprintf ( ctxt - > output , " interned \n " ) ;
else
fprintf ( ctxt - > output , " \n " ) ;
} else
2005-08-25 17:19:21 +04:00
fprintf ( ctxt - > output , " \n " ) ;
2004-10-04 18:09:17 +04:00
}
2001-07-18 23:30:27 +04:00
break ;
case XML_CDATA_SECTION_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " CDATA_SECTION \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_ENTITY_REF_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " ENTITY_REF(%s) \n " ,
( char * ) node - > name ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_ENTITY_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " ENTITY \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_PI_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " PI %s \n " , ( char * ) node - > name ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_COMMENT_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " COMMENT \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_DOCUMENT_NODE :
case XML_HTML_DOCUMENT_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
}
2004-12-18 00:38:09 +03:00
fprintf ( ctxt - > output , " Error, DOCUMENT found here \n " ) ;
xmlCtxtGenericNodeCheck ( ctxt , node ) ;
return ;
2001-07-18 23:30:27 +04:00
case XML_DOCUMENT_TYPE_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " DOCUMENT_TYPE \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_DOCUMENT_FRAG_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " DOCUMENT_FRAG \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_NOTATION_NODE :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " NOTATION \n " ) ;
}
2001-07-18 23:30:27 +04:00
break ;
case XML_DTD_NODE :
2004-10-04 18:09:17 +04:00
xmlCtxtDumpDtdNode ( ctxt , ( xmlDtdPtr ) node ) ;
2001-07-18 23:30:27 +04:00
return ;
case XML_ELEMENT_DECL :
2004-10-04 18:09:17 +04:00
xmlCtxtDumpElemDecl ( ctxt , ( xmlElementPtr ) node ) ;
2001-07-18 23:30:27 +04:00
return ;
case XML_ATTRIBUTE_DECL :
2004-10-04 18:09:17 +04:00
xmlCtxtDumpAttrDecl ( ctxt , ( xmlAttributePtr ) node ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
case XML_ENTITY_DECL :
2004-10-04 18:09:17 +04:00
xmlCtxtDumpEntityDecl ( ctxt , ( xmlEntityPtr ) node ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
case XML_NAMESPACE_DECL :
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespace ( ctxt , ( xmlNsPtr ) node ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
case XML_XINCLUDE_START :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " INCLUDE START \n " ) ;
}
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
case XML_XINCLUDE_END :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " INCLUDE END \n " ) ;
}
2001-07-18 23:30:27 +04:00
return ;
default :
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
xmlCtxtDumpSpaces ( ctxt ) ;
2004-10-07 17:14:19 +04:00
xmlDebugErr2 ( ctxt , XML_CHECK_UNKNOWN_NODE ,
" Unknown node type %d \n " , node - > type ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
if ( node - > doc = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
}
fprintf ( ctxt - > output , " PBM: doc == NULL !!! \n " ) ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
ctxt - > depth + + ;
2005-08-25 17:19:21 +04:00
if ( ( node - > type = = XML_ELEMENT_NODE ) & & ( node - > nsDef ! = NULL ) )
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespaceList ( ctxt , node - > nsDef ) ;
2005-08-25 17:19:21 +04:00
if ( ( node - > type = = XML_ELEMENT_NODE ) & & ( node - > properties ! = NULL ) )
2004-10-04 18:09:17 +04:00
xmlCtxtDumpAttrList ( ctxt , node - > properties ) ;
2001-02-23 20:55:21 +03:00
if ( node - > type ! = XML_ENTITY_REF_NODE ) {
2001-07-18 23:30:27 +04:00
if ( ( node - > type ! = XML_ELEMENT_NODE ) & & ( node - > content ! = NULL ) ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " content= " ) ;
xmlCtxtDumpString ( ctxt , node - > content ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
2001-07-18 23:30:27 +04:00
}
2001-02-23 20:55:21 +03:00
} else {
xmlEntityPtr ent ;
2001-07-18 23:30:27 +04:00
ent = xmlGetDocEntity ( node - > doc , node - > name ) ;
if ( ent ! = NULL )
2004-10-04 18:09:17 +04:00
xmlCtxtDumpEntity ( ctxt , ent ) ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
ctxt - > depth - - ;
2001-02-23 20:55:21 +03:00
/*
* Do a bit of checking
*/
2004-10-07 17:14:19 +04:00
xmlCtxtGenericNodeCheck ( ctxt , node ) ;
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpNode :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ node : the node
* @ depth : the indentation level .
*
* Dumps debug information for the element node , it is recursive
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpNode ( xmlDebugCtxtPtr ctxt , xmlNodePtr node )
2001-07-18 23:30:27 +04:00
{
2002-01-23 00:44:25 +03:00
if ( node = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
xmlCtxtDumpSpaces ( ctxt ) ;
fprintf ( ctxt - > output , " node is NULL \n " ) ;
}
return ;
}
xmlCtxtDumpOneNode ( ctxt , node ) ;
2012-09-11 09:26:36 +04:00
if ( ( node - > type ! = XML_NAMESPACE_DECL ) & &
2005-09-07 02:16:57 +04:00
( node - > children ! = NULL ) & & ( node - > type ! = XML_ENTITY_REF_NODE ) ) {
2004-10-04 18:09:17 +04:00
ctxt - > depth + + ;
xmlCtxtDumpNodeList ( ctxt , node - > children ) ;
ctxt - > depth - - ;
}
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpNodeList :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ node : the node list
* @ depth : the indentation level .
*
* Dumps debug information for the list of element node , it is recursive
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpNodeList ( xmlDebugCtxtPtr ctxt , xmlNodePtr node )
2001-07-18 23:30:27 +04:00
{
2001-02-23 20:55:21 +03:00
while ( node ! = NULL ) {
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNode ( ctxt , node ) ;
2001-07-18 23:30:27 +04:00
node = node - > next ;
2001-02-23 20:55:21 +03:00
}
}
2004-10-04 18:09:17 +04:00
static void
2004-10-07 17:14:19 +04:00
xmlCtxtDumpDocHead ( xmlDebugCtxtPtr ctxt , xmlDocPtr doc )
2001-07-18 23:30:27 +04:00
{
2001-02-23 20:55:21 +03:00
if ( doc = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " DOCUMENT == NULL ! \n " ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
2004-10-07 17:14:19 +04:00
ctxt - > node = ( xmlNodePtr ) doc ;
2001-02-23 20:55:21 +03:00
switch ( doc - > type ) {
2001-07-18 23:30:27 +04:00
case XML_ELEMENT_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_ELEMENT ,
" Misplaced ELEMENT node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_ATTRIBUTE_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_ATTRIBUTE ,
" Misplaced ATTRIBUTE node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_TEXT_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_TEXT ,
" Misplaced TEXT node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_CDATA_SECTION_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_CDATA ,
" Misplaced CDATA node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_ENTITY_REF_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_ENTITYREF ,
" Misplaced ENTITYREF node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_ENTITY_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_ENTITY ,
" Misplaced ENTITY node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_PI_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_PI ,
" Misplaced PI node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_COMMENT_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_COMMENT ,
" Misplaced COMMENT node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_DOCUMENT_NODE :
2004-10-07 17:14:19 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " DOCUMENT \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_HTML_DOCUMENT_NODE :
2004-10-07 17:14:19 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " HTML DOCUMENT \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_DOCUMENT_TYPE_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_DOCTYPE ,
" Misplaced DOCTYPE node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_DOCUMENT_FRAG_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_FRAGMENT ,
" Misplaced FRAGMENT node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
case XML_NOTATION_NODE :
2004-10-07 17:14:19 +04:00
xmlDebugErr ( ctxt , XML_CHECK_FOUND_NOTATION ,
" Misplaced NOTATION node \n " ) ;
2001-07-18 23:30:27 +04:00
break ;
default :
2004-10-07 17:14:19 +04:00
xmlDebugErr2 ( ctxt , XML_CHECK_UNKNOWN_NODE ,
" Unknown node type %d \n " , doc - > type ) ;
2001-02-23 20:55:21 +03:00
}
2004-10-07 17:14:19 +04:00
}
/**
* xmlCtxtDumpDocumentHead :
* @ output : the FILE * for the output
* @ doc : the document
*
2019-09-30 18:04:54 +03:00
* Dumps debug information concerning the document , not recursive
2004-10-07 17:14:19 +04:00
*/
static void
xmlCtxtDumpDocumentHead ( xmlDebugCtxtPtr ctxt , xmlDocPtr doc )
{
2004-11-08 19:24:57 +03:00
if ( doc = = NULL ) return ;
2004-10-07 17:14:19 +04:00
xmlCtxtDumpDocHead ( ctxt , doc ) ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
if ( doc - > name ! = NULL ) {
fprintf ( ctxt - > output , " name= " ) ;
xmlCtxtDumpString ( ctxt , BAD_CAST doc - > name ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
if ( doc - > version ! = NULL ) {
fprintf ( ctxt - > output , " version= " ) ;
xmlCtxtDumpString ( ctxt , doc - > version ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
if ( doc - > encoding ! = NULL ) {
fprintf ( ctxt - > output , " encoding= " ) ;
xmlCtxtDumpString ( ctxt , doc - > encoding ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
if ( doc - > URL ! = NULL ) {
fprintf ( ctxt - > output , " URL= " ) ;
xmlCtxtDumpString ( ctxt , doc - > URL ) ;
fprintf ( ctxt - > output , " \n " ) ;
}
if ( doc - > standalone )
fprintf ( ctxt - > output , " standalone=true \n " ) ;
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
if ( doc - > oldNs ! = NULL )
2004-10-04 18:09:17 +04:00
xmlCtxtDumpNamespaceList ( ctxt , doc - > oldNs ) ;
2001-02-23 20:55:21 +03:00
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpDocument :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ doc : the document
*
* Dumps debug information for the document , it ' s recursive
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpDocument ( xmlDebugCtxtPtr ctxt , xmlDocPtr doc )
2001-07-18 23:30:27 +04:00
{
2001-02-23 20:55:21 +03:00
if ( doc = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " DOCUMENT == NULL ! \n " ) ;
2001-07-18 23:30:27 +04:00
return ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
xmlCtxtDumpDocumentHead ( ctxt , doc ) ;
2001-02-23 20:55:21 +03:00
if ( ( ( doc - > type = = XML_DOCUMENT_NODE ) | |
2004-10-04 18:09:17 +04:00
( doc - > type = = XML_HTML_DOCUMENT_NODE ) )
& & ( doc - > children ! = NULL ) ) {
ctxt - > depth + + ;
xmlCtxtDumpNodeList ( ctxt , doc - > children ) ;
ctxt - > depth - - ;
2001-02-23 20:55:21 +03:00
}
}
2001-03-24 20:00:36 +03:00
static void
2017-11-09 18:42:47 +03:00
xmlCtxtDumpEntityCallback ( void * payload , void * data ,
const xmlChar * name ATTRIBUTE_UNUSED )
2004-10-04 18:09:17 +04:00
{
2017-11-09 18:42:47 +03:00
xmlEntityPtr cur = ( xmlEntityPtr ) payload ;
xmlDebugCtxtPtr ctxt = ( xmlDebugCtxtPtr ) data ;
2002-01-23 00:44:25 +03:00
if ( cur = = NULL ) {
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Entity is NULL " ) ;
return ;
2002-01-23 00:44:25 +03:00
}
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check ) {
fprintf ( ctxt - > output , " %s : " , ( char * ) cur - > name ) ;
switch ( cur - > etype ) {
case XML_INTERNAL_GENERAL_ENTITY :
fprintf ( ctxt - > output , " INTERNAL GENERAL, " ) ;
break ;
case XML_EXTERNAL_GENERAL_PARSED_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL PARSED, " ) ;
break ;
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL UNPARSED, " ) ;
break ;
case XML_INTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " INTERNAL PARAMETER, " ) ;
break ;
case XML_EXTERNAL_PARAMETER_ENTITY :
fprintf ( ctxt - > output , " EXTERNAL PARAMETER, " ) ;
break ;
default :
2004-10-07 17:14:19 +04:00
xmlDebugErr2 ( ctxt , XML_CHECK_ENTITY_TYPE ,
" Unknown entity type %d \n " , cur - > etype ) ;
2004-10-04 18:09:17 +04:00
}
if ( cur - > ExternalID ! = NULL )
fprintf ( ctxt - > output , " ID \" %s \" " , ( char * ) cur - > ExternalID ) ;
if ( cur - > SystemID ! = NULL )
fprintf ( ctxt - > output , " SYSTEM \" %s \" " , ( char * ) cur - > SystemID ) ;
if ( cur - > orig ! = NULL )
fprintf ( ctxt - > output , " \n orig \" %s \" " , ( char * ) cur - > orig ) ;
if ( ( cur - > type ! = XML_ELEMENT_NODE ) & & ( cur - > content ! = NULL ) )
fprintf ( ctxt - > output , " \n content \" %s \" " ,
( char * ) cur - > content ) ;
fprintf ( ctxt - > output , " \n " ) ;
2001-02-23 20:55:21 +03:00
}
}
2001-07-18 23:30:27 +04:00
/**
2004-10-04 18:09:17 +04:00
* xmlCtxtDumpEntities :
2001-07-18 23:30:27 +04:00
* @ output : the FILE * for the output
* @ doc : the document
*
* Dumps debug information for all the entities in use by the document
*/
2004-10-04 18:09:17 +04:00
static void
xmlCtxtDumpEntities ( xmlDebugCtxtPtr ctxt , xmlDocPtr doc )
2001-07-18 23:30:27 +04:00
{
2004-11-08 19:24:57 +03:00
if ( doc = = NULL ) return ;
2004-10-07 17:14:19 +04:00
xmlCtxtDumpDocHead ( ctxt , doc ) ;
2001-02-23 20:55:21 +03:00
if ( ( doc - > intSubset ! = NULL ) & & ( doc - > intSubset - > entities ! = NULL ) ) {
2001-07-18 23:30:27 +04:00
xmlEntitiesTablePtr table = ( xmlEntitiesTablePtr )
doc - > intSubset - > entities ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Entities in internal subset \n " ) ;
2017-11-09 18:42:47 +03:00
xmlHashScan ( table , xmlCtxtDumpEntityCallback , ctxt ) ;
2001-02-23 20:55:21 +03:00
} else
2004-10-04 18:09:17 +04:00
fprintf ( ctxt - > output , " No entities in internal subset \n " ) ;
2001-02-23 20:55:21 +03:00
if ( ( doc - > extSubset ! = NULL ) & & ( doc - > extSubset - > entities ! = NULL ) ) {
2001-07-18 23:30:27 +04:00
xmlEntitiesTablePtr table = ( xmlEntitiesTablePtr )
doc - > extSubset - > entities ;
2004-10-04 18:09:17 +04:00
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " Entities in external subset \n " ) ;
2017-11-09 18:42:47 +03:00
xmlHashScan ( table , xmlCtxtDumpEntityCallback , ctxt ) ;
2004-10-04 18:09:17 +04:00
} else if ( ! ctxt - > check )
fprintf ( ctxt - > output , " No entities in external subset \n " ) ;
}
/**
* xmlCtxtDumpDTD :
* @ output : the FILE * for the output
* @ dtd : the DTD
*
* Dumps debug information for the DTD
*/
static void
xmlCtxtDumpDTD ( xmlDebugCtxtPtr ctxt , xmlDtdPtr dtd )
{
if ( dtd = = NULL ) {
if ( ! ctxt - > check )
fprintf ( ctxt - > output , " DTD is NULL \n " ) ;
return ;
}
2004-10-07 17:14:19 +04:00
xmlCtxtDumpDtdNode ( ctxt , dtd ) ;
2004-10-04 18:09:17 +04:00
if ( dtd - > children = = NULL )
fprintf ( ctxt - > output , " DTD is empty \n " ) ;
else {
ctxt - > depth + + ;
xmlCtxtDumpNodeList ( ctxt , dtd - > children ) ;
ctxt - > depth - - ;
}
}
2004-10-07 17:14:19 +04:00
2004-10-04 18:09:17 +04:00
/************************************************************************
* *
2004-10-07 17:14:19 +04:00
* Public entry points for dump *
2004-10-04 18:09:17 +04:00
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* xmlDebugDumpString :
* @ output : the FILE * for the output
* @ str : the string
*
2020-03-08 19:19:42 +03:00
* Dumps information about the string , shorten it if necessary
2004-10-04 18:09:17 +04:00
*/
void
xmlDebugDumpString ( FILE * output , const xmlChar * str )
{
int i ;
if ( output = = NULL )
output = stdout ;
if ( str = = NULL ) {
fprintf ( output , " (NULL) " ) ;
return ;
}
for ( i = 0 ; i < 40 ; i + + )
if ( str [ i ] = = 0 )
return ;
else if ( IS_BLANK_CH ( str [ i ] ) )
fputc ( ' ' , output ) ;
else if ( str [ i ] > = 0x80 )
fprintf ( output , " #%X " , str [ i ] ) ;
else
fputc ( str [ i ] , output ) ;
fprintf ( output , " ... " ) ;
}
/**
* xmlDebugDumpAttr :
* @ output : the FILE * for the output
* @ attr : the attribute
* @ depth : the indentation level .
*
* Dumps debug information for the attribute
*/
void
xmlDebugDumpAttr ( FILE * output , xmlAttrPtr attr , int depth ) {
xmlDebugCtxt ctxt ;
2004-11-08 19:24:57 +03:00
if ( output = = NULL ) return ;
2004-10-04 18:09:17 +04:00
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . depth = depth ;
xmlCtxtDumpAttr ( & ctxt , attr ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpEntities :
* @ output : the FILE * for the output
* @ doc : the document
*
* Dumps debug information for all the entities in use by the document
*/
void
xmlDebugDumpEntities ( FILE * output , xmlDocPtr doc )
{
xmlDebugCtxt ctxt ;
2004-11-08 19:24:57 +03:00
if ( output = = NULL ) return ;
2004-10-04 18:09:17 +04:00
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
xmlCtxtDumpEntities ( & ctxt , doc ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpAttrList :
* @ output : the FILE * for the output
* @ attr : the attribute list
* @ depth : the indentation level .
*
* Dumps debug information for the attribute list
*/
void
xmlDebugDumpAttrList ( FILE * output , xmlAttrPtr attr , int depth )
{
xmlDebugCtxt ctxt ;
2004-11-08 19:24:57 +03:00
if ( output = = NULL ) return ;
2004-10-04 18:09:17 +04:00
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . depth = depth ;
xmlCtxtDumpAttrList ( & ctxt , attr ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2001-02-23 20:55:21 +03:00
}
2004-10-04 18:09:17 +04:00
/**
* xmlDebugDumpOneNode :
* @ output : the FILE * for the output
* @ node : the node
* @ depth : the indentation level .
*
* Dumps debug information for the element node , it is not recursive
*/
void
xmlDebugDumpOneNode ( FILE * output , xmlNodePtr node , int depth )
{
xmlDebugCtxt ctxt ;
2004-11-08 19:24:57 +03:00
if ( output = = NULL ) return ;
2004-10-04 18:09:17 +04:00
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . depth = depth ;
xmlCtxtDumpOneNode ( & ctxt , node ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpNode :
* @ output : the FILE * for the output
* @ node : the node
* @ depth : the indentation level .
*
* Dumps debug information for the element node , it is recursive
*/
void
xmlDebugDumpNode ( FILE * output , xmlNodePtr node , int depth )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . depth = depth ;
xmlCtxtDumpNode ( & ctxt , node ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpNodeList :
* @ output : the FILE * for the output
* @ node : the node list
* @ depth : the indentation level .
*
* Dumps debug information for the list of element node , it is recursive
*/
void
xmlDebugDumpNodeList ( FILE * output , xmlNodePtr node , int depth )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . depth = depth ;
xmlCtxtDumpNodeList ( & ctxt , node ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpDocumentHead :
* @ output : the FILE * for the output
* @ doc : the document
*
2019-09-30 18:04:54 +03:00
* Dumps debug information concerning the document , not recursive
2004-10-04 18:09:17 +04:00
*/
void
xmlDebugDumpDocumentHead ( FILE * output , xmlDocPtr doc )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
2005-08-25 18:03:56 +04:00
ctxt . options | = DUMP_TEXT_TYPE ;
2004-10-04 18:09:17 +04:00
ctxt . output = output ;
xmlCtxtDumpDocumentHead ( & ctxt , doc ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpDocument :
* @ output : the FILE * for the output
* @ doc : the document
*
* Dumps debug information for the document , it ' s recursive
*/
void
xmlDebugDumpDocument ( FILE * output , xmlDocPtr doc )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
2005-08-25 18:03:56 +04:00
ctxt . options | = DUMP_TEXT_TYPE ;
2004-10-04 18:09:17 +04:00
ctxt . output = output ;
xmlCtxtDumpDocument ( & ctxt , doc ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
/**
* xmlDebugDumpDTD :
* @ output : the FILE * for the output
* @ dtd : the DTD
*
* Dumps debug information for the DTD
*/
void
xmlDebugDumpDTD ( FILE * output , xmlDtdPtr dtd )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
2005-08-25 18:03:56 +04:00
ctxt . options | = DUMP_TEXT_TYPE ;
2004-10-04 18:09:17 +04:00
ctxt . output = output ;
xmlCtxtDumpDTD ( & ctxt , dtd ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-04 18:09:17 +04:00
}
2004-10-07 17:14:19 +04:00
/************************************************************************
* *
* Public entry points for checkings *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* xmlDebugCheckDocument :
* @ output : the FILE * for the output
* @ doc : the document
*
* Check the document for potential content problems , and output
* the errors to @ output
*
* Returns the number of errors found
*/
int
xmlDebugCheckDocument ( FILE * output , xmlDocPtr doc )
{
xmlDebugCtxt ctxt ;
if ( output = = NULL )
output = stdout ;
xmlCtxtDumpInitCtxt ( & ctxt ) ;
ctxt . output = output ;
ctxt . check = 1 ;
xmlCtxtDumpDocument ( & ctxt , doc ) ;
2004-10-10 00:39:04 +04:00
xmlCtxtDumpCleanCtxt ( & ctxt ) ;
2004-10-07 17:14:19 +04:00
return ( ctxt . errors ) ;
}
2001-02-23 20:55:21 +03:00
# endif /* LIBXML_DEBUG_ENABLED */