build: Add separate configuration option for RELAX NG
Support for RELAX NG used to be enabled together with XML Schema support
(--with-schemas). Now there's a separate option and a new feature macro
LIBXML_RELAXNG_ENABLED.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 235cdf4..a31e11d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,7 +61,10 @@
LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON
"LIBXML2_WITH_PUSH" OFF)
cmake_dependent_option(
- LIBXML2_WITH_SCHEMAS "Add Relax-NG and Schemas support" ON
+ LIBXML2_WITH_RELAXNG "Add Relax-NG support" ON
+ "LIBXML2_WITH_REGEXPS;LIBXML2_WITH_SCHEMAS" OFF)
+cmake_dependent_option(
+ LIBXML2_WITH_SCHEMAS "Add XML Schemas 1.0 support" ON
"LIBXML2_WITH_PATTERN;LIBXML2_WITH_REGEXPS" OFF)
cmake_dependent_option(
LIBXML2_WITH_SCHEMATRON "Add Schematron support" ON
@@ -83,7 +86,7 @@
CACHE PATH "Python bindings install directory")
endif()
-foreach(VARIABLE IN ITEMS WITH_C14N WITH_CATALOG WITH_DEBUG WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
+foreach(VARIABLE IN ITEMS WITH_C14N WITH_CATALOG WITH_DEBUG WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RELAXNG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
else()
@@ -277,8 +280,11 @@
if(LIBXML2_WITH_REGEXPS)
list(APPEND LIBXML2_SRCS xmlregexp.c xmlunicode.c)
endif()
+if(LIBXML2_WITH_RELAXNG)
+ list(APPEND LIBXML2_SRCS relaxng.c)
+endif()
if(LIBXML2_WITH_SCHEMAS)
- list(APPEND LIBXML2_SRCS relaxng.c xmlschemas.c xmlschemastypes.c)
+ list(APPEND LIBXML2_SRCS xmlschemas.c xmlschemastypes.c)
endif()
if(LIBXML2_WITH_SCHEMATRON)
list(APPEND LIBXML2_SRCS schematron.c)
diff --git a/Makefile.am b/Makefile.am
index ff40d99..5501c30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,8 +89,11 @@
if WITH_REGEXPS_SOURCES
libxml2_la_SOURCES += xmlregexp.c xmlunicode.c
endif
+if WITH_RELAXNG_SOURCES
+libxml2_la_SOURCES += relaxng.c
+endif
if WITH_SCHEMAS_SOURCES
-libxml2_la_SOURCES += relaxng.c xmlschemas.c xmlschemastypes.c
+libxml2_la_SOURCES += xmlschemas.c xmlschemastypes.c
endif
if WITH_SCHEMATRON_SOURCES
libxml2_la_SOURCES += schematron.c
diff --git a/README.md b/README.md
index 3459684..9883209 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,9 @@
--with-python Python bindings (on)
--with-reader xmlReader parsing interface (on)
--with-regexps regular expressions support (on)
+ --with-relaxng RELAX NG support (on)
--with-sax1 older SAX1 interface (on)
- --with-schemas XML Schemas 1.0 and RELAX NG support (on)
+ --with-schemas XML Schemas 1.0 support (on)
--with-schematron Schematron support (on)
--with-threads multithreading support (on)
--with-thread-alloc per-thread malloc hooks (off)
diff --git a/configure.ac b/configure.ac
index fc77fd1..edb7491 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,10 +100,12 @@
[ --with-reader xmlReader parsing interface (on)])
AC_ARG_WITH(regexps,
[ --with-regexps regular expressions support (on)])
+AC_ARG_WITH(relaxng,
+[ --with-relaxng RELAX NG support (on)])
AC_ARG_WITH(sax1,
[ --with-sax1 older SAX1 interface (on)])
AC_ARG_WITH(schemas,
-[ --with-schemas XML Schemas 1.0 and RELAX NG support (on)])
+[ --with-schemas XML Schemas 1.0 support (on)])
AC_ARG_WITH(schematron,
[ --with-schematron Schematron support (on)])
AC_ARG_WITH(threads,
@@ -159,6 +161,16 @@
fi
with_xpath=yes
fi
+if test "$with_relaxng" = "yes"; then
+ if test "$with_regexps" = "no"; then
+ echo WARNING: --with-relaxng overrides --without-regexps
+ fi
+ with_regexps=yes
+ if test "$with_schemas" = "no"; then
+ echo WARNING: --with-relaxng overrides --without-schemas
+ fi
+ with_schemas=yes
+fi
if test "$with_schemas" = "yes"; then
if test "$with_pattern" = "no"; then
echo WARNING: --with-schemas overrides --without-pattern
@@ -232,6 +244,7 @@
test "$with_reader" = "" && with_reader=no
test "$with_readline" = "" && with_readline=no
test "$with_regexps" = "" && with_regexps=no
+ test "$with_relaxng" = "" && with_relaxng=no
test "$with_sax1" = "" && with_sax1=no
test "$with_schemas" = "" && with_schemas=no
test "$with_schematron" = "" && with_schematron=no
@@ -261,8 +274,12 @@
with_writer=no
fi
if test "$with_regexps" = "no"; then
+ with_relaxng=no
with_schemas=no
fi
+ if test "$with_schemas" = "no"; then
+ with_relaxng=no
+ fi
if test "$with_xpath" = "no"; then
with_c14n=no
with_schematron=no
@@ -577,8 +594,17 @@
fi
AC_SUBST(WITH_ISO8859X)
+if test "$with_relaxng" = "no" ; then
+ echo "Disabling Relax-NG support"
+ WITH_RELAXNG=0
+else
+ WITH_RELAXNG=1
+fi
+AC_SUBST(WITH_RELAXNG)
+AM_CONDITIONAL(WITH_RELAXNG_SOURCES, test "$WITH_RELAXNG" = "1")
+
if test "$with_schemas" = "no" ; then
- echo "Disabling Schemas/Relax-NG support"
+ echo "Disabling Schemas support"
WITH_SCHEMAS=0
else
WITH_SCHEMAS=1
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index cebf4ab..6d7b157 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -615,6 +615,7 @@
<exports symbol='XML_WITH_PUSH' type='enum'/>
<exports symbol='XML_WITH_READER' type='enum'/>
<exports symbol='XML_WITH_REGEXP' type='enum'/>
+ <exports symbol='XML_WITH_RELAXNG' type='enum'/>
<exports symbol='XML_WITH_SAX1' type='enum'/>
<exports symbol='XML_WITH_SCHEMAS' type='enum'/>
<exports symbol='XML_WITH_SCHEMATRON' type='enum'/>
@@ -5659,6 +5660,7 @@
<enum name='XML_WITH_PUSH' file='parser' value='4' type='xmlFeature'/>
<enum name='XML_WITH_READER' file='parser' value='5' type='xmlFeature'/>
<enum name='XML_WITH_REGEXP' file='parser' value='22' type='xmlFeature'/>
+ <enum name='XML_WITH_RELAXNG' file='parser' value='34' type='xmlFeature' info='since 2.14.0'/>
<enum name='XML_WITH_SAX1' file='parser' value='8' type='xmlFeature'/>
<enum name='XML_WITH_SCHEMAS' file='parser' value='25' type='xmlFeature'/>
<enum name='XML_WITH_SCHEMATRON' file='parser' value='26' type='xmlFeature'/>
@@ -12270,44 +12272,44 @@
<arg name='closeFunc' type='xmlOutputCloseCallback' info='the xmlOutputCloseCallback'/>
</function>
<function name='xmlRelaxNGCleanupTypes' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all. Cleanup the default Schemas type library associated to RelaxNG</info>
<return type='void'/>
</function>
<function name='xmlRelaxNGDump' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Dump a RelaxNG structure back</info>
<return type='void'/>
<arg name='output' type='FILE *' info='the file output'/>
<arg name='schema' type='xmlRelaxNGPtr' info='a schema structure'/>
</function>
<function name='xmlRelaxNGDumpTree' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Dump the transformed RelaxNG tree.</info>
<return type='void'/>
<arg name='output' type='FILE *' info='the file output'/>
<arg name='schema' type='xmlRelaxNGPtr' info='a schema structure'/>
</function>
<function name='xmlRelaxNGFree' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Deallocate a RelaxNG structure.</info>
<return type='void'/>
<arg name='schema' type='xmlRelaxNGPtr' info='a schema structure'/>
</function>
<function name='xmlRelaxNGFreeParserCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Free the resources associated to the schema parser context</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='the schema parser context'/>
</function>
<function name='xmlRelaxNGFreeValidCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Free the resources associated to the schema validation context</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='the schema validation context'/>
</function>
<function name='xmlRelaxNGGetParserErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Get the callback information used to handle errors for a validation context</info>
<return type='int' info='-1 in case of failure, 0 otherwise.'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a Relax-NG validation context'/>
@@ -12316,7 +12318,7 @@
<arg name='ctx' type='void **' info='contextual data for the callbacks result'/>
</function>
<function name='xmlRelaxNGGetValidErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Get the error and warning callback information</info>
<return type='int' info='-1 in case of error and 0 otherwise'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='a Relax-NG validation context'/>
@@ -12325,43 +12327,43 @@
<arg name='ctx' type='void **' info='the functions context result'/>
</function>
<function name='xmlRelaxNGInitTypes' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Initialize the default type libraries.</info>
<return type='int' info='0 in case of success and -1 in case of error.'/>
</function>
<function name='xmlRelaxNGNewDocParserCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Create an XML RelaxNGs parser context for that document. Note: since the process of compiling a RelaxNG schemas modifies the document, the @doc parameter is duplicated internally.</info>
<return type='xmlRelaxNGParserCtxtPtr' info='the parser context or NULL in case of error'/>
<arg name='doc' type='xmlDocPtr' info='a preparsed document tree'/>
</function>
<function name='xmlRelaxNGNewMemParserCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file.</info>
<return type='xmlRelaxNGParserCtxtPtr' info='the parser context or NULL in case of error'/>
<arg name='buffer' type='const char *' info='a pointer to a char array containing the schemas'/>
<arg name='size' type='int' info='the size of the array'/>
</function>
<function name='xmlRelaxNGNewParserCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file.</info>
<return type='xmlRelaxNGParserCtxtPtr' info='the parser context or NULL in case of error'/>
<arg name='URL' type='const char *' info='the location of the schema'/>
</function>
<function name='xmlRelaxNGNewValidCtxt' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Create an XML RelaxNGs validation context based on the given schema</info>
<return type='xmlRelaxNGValidCtxtPtr' info='the validation context or NULL in case of error'/>
<arg name='schema' type='xmlRelaxNGPtr' info='a precompiled XML RelaxNGs'/>
</function>
<function name='xmlRelaxNGParse' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>parse a schema definition resource and build an internal XML Schema structure which can be used to validate instances.</info>
<return type='xmlRelaxNGPtr' info='the internal XML RelaxNG structure built from the resource or NULL in case of error'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a Relax-NG parser context'/>
</function>
<function name='xmlRelaxNGSetParserErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>DEPRECATED: Use xmlRelaxNGSetParserStructuredErrors. Set the callback functions used to handle errors for a validation context</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a Relax-NG validation context'/>
@@ -12370,7 +12372,7 @@
<arg name='ctx' type='void *' info='contextual data for the callbacks'/>
</function>
<function name='xmlRelaxNGSetParserStructuredErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Set the callback functions used to handle errors for a parsing context</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a Relax-NG parser context'/>
@@ -12378,7 +12380,7 @@
<arg name='ctx' type='void *' info='contextual data for the callbacks'/>
</function>
<function name='xmlRelaxNGSetResourceLoader' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Set the callback function used to load external resources.</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a Relax-NG parser context'/>
@@ -12386,7 +12388,7 @@
<arg name='vctxt' type='void *' info='contextual data for the callbacks'/>
</function>
<function name='xmlRelaxNGSetValidErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>DEPRECATED: Use xmlRelaxNGSetValidStructuredErrors. Set the error and warning callback information</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='a Relax-NG validation context'/>
@@ -12395,7 +12397,7 @@
<arg name='ctx' type='void *' info='the functions context'/>
</function>
<function name='xmlRelaxNGSetValidStructuredErrors' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Set the structured error callback</info>
<return type='void'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='a Relax-NG validation context'/>
@@ -12403,14 +12405,14 @@
<arg name='ctx' type='void *' info='the functions context'/>
</function>
<function name='xmlRelaxNGValidateDoc' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Validate a document tree in memory.</info>
<return type='int' info='0 if the document is valid, a positive error code number otherwise and -1 in case of internal or API error.'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='a Relax-NG validation context'/>
<arg name='doc' type='xmlDocPtr' info='a parsed document tree'/>
</function>
<function name='xmlRelaxNGValidateFullElement' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Validate a full subtree when xmlRelaxNGValidatePushElement() returned 0 and the content of the node has been expanded.</info>
<return type='int' info='1 if no validation problem was found or -1 in case of error.'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='the validation context'/>
@@ -12418,7 +12420,7 @@
<arg name='elem' type='xmlNodePtr' info='an element instance'/>
</function>
<function name='xmlRelaxNGValidatePopElement' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Pop the element end from the RelaxNG validation stack.</info>
<return type='int' info='1 if no validation problem was found or 0 otherwise'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='the RelaxNG validation context'/>
@@ -12426,7 +12428,7 @@
<arg name='elem' type='xmlNodePtr' info='an element instance'/>
</function>
<function name='xmlRelaxNGValidatePushCData' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>check the CData parsed for validation in the current stack</info>
<return type='int' info='1 if no validation problem was found or -1 otherwise'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='the RelaxNG validation context'/>
@@ -12434,7 +12436,7 @@
<arg name='len' type='int' info='the length of the data'/>
</function>
<function name='xmlRelaxNGValidatePushElement' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Push a new element start on the RelaxNG validation stack.</info>
<return type='int' info='1 if no validation problem was found or 0 if validating the element requires a full node, and -1 in case of error.'/>
<arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='the validation context'/>
@@ -12442,7 +12444,7 @@
<arg name='elem' type='xmlNodePtr' info='an element instance'/>
</function>
<functype name='xmlRelaxNGValidityErrorFunc' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Signature of an error callback from a Relax-NG validation</info>
<return type='void'/>
<arg name='ctx' type='void *' info='the validation context'/>
@@ -12450,7 +12452,7 @@
<arg name='...' type='...' info='extra arguments'/>
</functype>
<functype name='xmlRelaxNGValidityWarningFunc' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Signature of a warning callback from a Relax-NG validation</info>
<return type='void'/>
<arg name='ctx' type='void *' info='the validation context'/>
@@ -12458,7 +12460,7 @@
<arg name='...' type='...' info='extra arguments'/>
</functype>
<function name='xmlRelaxParserSetFlag' file='relaxng' module='relaxng'>
- <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Semi private function used to pass information to a parser context which are a combination of xmlRelaxNGParserFlag .</info>
<return type='int' info='0 if success and -1 in case of error'/>
<arg name='ctxt' type='xmlRelaxNGParserCtxtPtr' info='a RelaxNG parser context'/>
@@ -14277,21 +14279,21 @@
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
</function>
<function name='xmlTextReaderRelaxNGSetSchema' file='xmlreader' module='xmlreader'>
- <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Use RelaxNG to validate the document as it is processed. Activation is only possible before the first Read(). if @schema is NULL, then RelaxNG validation is deactivated. @ The @schema should not be freed until the reader is deallocated or its use has been deactivated.</info>
<return type='int' info='0 in case the RelaxNG validation could be (de)activated and -1 in case of error.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
<arg name='schema' type='xmlRelaxNGPtr' info='a precompiled RelaxNG schema'/>
</function>
<function name='xmlTextReaderRelaxNGValidate' file='xmlreader' module='xmlreader'>
- <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Use RelaxNG schema to validate the document as it is processed. Activation is only possible before the first Read(). If @rng is NULL, then RelaxNG schema validation is deactivated.</info>
<return type='int' info='0 in case the schemas validation could be (de)activated and -1 in case of error.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
<arg name='rng' type='const char *' info='the path to a RelaxNG schema or NULL'/>
</function>
<function name='xmlTextReaderRelaxNGValidateCtxt' file='xmlreader' module='xmlreader'>
- <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)</cond>
+ <cond>defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)</cond>
<info>Use RelaxNG schema context to validate the document as it is processed. Activation is only possible before the first Read(). If @ctxt is NULL, then RelaxNG schema validation is deactivated.</info>
<return type='int' info='0 in case the schemas validation could be (de)activated and -1 in case of error.'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
diff --git a/include/libxml/meson.build b/include/libxml/meson.build
index cbc29b9..1da29aa 100644
--- a/include/libxml/meson.build
+++ b/include/libxml/meson.build
@@ -21,6 +21,7 @@
xmlversion_h.set10('WITH_PUSH', want_push)
xmlversion_h.set10('WITH_READER', want_reader)
xmlversion_h.set10('WITH_REGEXPS', want_regexps)
+xmlversion_h.set10('WITH_RELAXNG', want_relaxng)
xmlversion_h.set10('WITH_SAX1', want_sax1)
xmlversion_h.set10('WITH_SCHEMAS', want_schemas)
xmlversion_h.set10('WITH_SCHEMATRON', want_schematron)
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 3ca2ff5..1f878ad 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1613,6 +1613,7 @@
XML_WITH_ZLIB = 31,
XML_WITH_ICU = 32,
XML_WITH_LZMA = 33,
+ XML_WITH_RELAXNG = 34, /* since 2.14.0 */
XML_WITH_NONE = 99999 /* just to be sure of allocation size */
} xmlFeature;
diff --git a/include/libxml/relaxng.h b/include/libxml/relaxng.h
index 96cf499..e9cb1ec 100644
--- a/include/libxml/relaxng.h
+++ b/include/libxml/relaxng.h
@@ -16,7 +16,7 @@
#include <libxml/tree.h>
#include <libxml/parser.h>
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#ifdef __cplusplus
extern "C" {
@@ -219,6 +219,6 @@
}
#endif
-#endif /* LIBXML_SCHEMAS_ENABLED */
+#endif /* LIBXML_RELAXNG_ENABLED */
#endif /* __XML_RELAX_NG__ */
diff --git a/include/libxml/xmlreader.h b/include/libxml/xmlreader.h
index 65e5cc7..2344901 100644
--- a/include/libxml/xmlreader.h
+++ b/include/libxml/xmlreader.h
@@ -14,8 +14,10 @@
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlIO.h>
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#endif
#include <libxml/parser.h>
@@ -287,7 +289,7 @@
xmlTextReaderNextSibling (xmlTextReaderPtr reader);
XMLPUBFUN int
xmlTextReaderIsValid (xmlTextReaderPtr reader);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
XMLPUBFUN int
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
const char *rng);
@@ -299,6 +301,8 @@
XMLPUBFUN int
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
xmlRelaxNGPtr schema);
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
XMLPUBFUN int
xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
const char *xsd);
diff --git a/include/libxml/xmlversion.h.in b/include/libxml/xmlversion.h.in
index 000a0fa..c285a82 100644
--- a/include/libxml/xmlversion.h.in
+++ b/include/libxml/xmlversion.h.in
@@ -270,6 +270,15 @@
#endif
/**
+ * LIBXML_RELAXNG_ENABLED:
+ *
+ * Whether the RelaxNG validation interfaces are compiled in
+ */
+#if @WITH_RELAXNG@
+#define LIBXML_RELAXNG_ENABLED
+#endif
+
+/**
* LIBXML_SCHEMAS_ENABLED:
*
* Whether the Schemas validation interfaces are compiled in
diff --git a/meson.build b/meson.build
index 8538e78..37d7f0a 100644
--- a/meson.build
+++ b/meson.build
@@ -151,6 +151,7 @@
feature = get_option('regexps')
want_regexps = not want_minimum \
+ or get_option('relaxng').enabled() \
or get_option('schemas').enabled() ? \
feature.allowed() : feature.enabled()
@@ -187,7 +188,14 @@
feature = get_option('schemas') \
.require(want_pattern, error_message: 'schemas requires pattern') \
.require(want_regexps, error_message: 'schemas requires regexps')
-want_schemas = want_minimum ? feature.enabled() : feature.allowed()
+want_schemas = not want_minimum \
+ or get_option('relaxng') ? \
+ feature.allowed() : feature.enabled()
+
+feature = get_option('relaxng') \
+ .require(want_regexps, error_message: 'relaxng requires regexps') \
+ .require(want_schemas, error_message: 'relaxng requires schemas')
+want_relaxng = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('schematron') \
.require(want_pattern, error_message: 'schematron requires pattern') \
@@ -451,7 +459,8 @@
[want_pattern, ['pattern.c']],
[want_reader, ['xmlreader.c']],
[want_regexps, ['xmlregexp.c', 'xmlunicode.c']],
- [want_schemas, ['relaxng.c', 'xmlschemas.c', 'xmlschemastypes.c']],
+ [want_relaxng, ['relaxng.c']],
+ [want_schemas, ['xmlschemas.c', 'xmlschemastypes.c']],
[want_schematron, ['schematron.c']],
[want_writer, ['xmlwriter.c']],
[want_xinclude, ['xinclude.c']],
@@ -616,6 +625,7 @@
'reader': want_reader,
'readline': want_readline,
'regexps': want_regexps,
+ 'relaxng': want_relaxng,
'sax1': want_sax1,
'schemas': want_schemas,
'schematron': want_schematron,
diff --git a/meson_options.txt b/meson_options.txt
index 1137aef..0bfbebb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -132,6 +132,11 @@
description: 'Regular expressions support'
)
+option('relaxng',
+ type: 'feature',
+ description: 'RELAX NG support'
+)
+
option('sax1',
type: 'feature',
description: 'Older SAX1 interface'
@@ -139,7 +144,7 @@
option('schemas',
type: 'feature',
- description: 'XML Schemas 1.0 and RELAX NG support'
+ description: 'XML Schemas 1.0 support'
)
option('schematron',
diff --git a/parser.c b/parser.c
index 20fedfa..8e66b1b 100644
--- a/parser.c
+++ b/parser.c
@@ -658,6 +658,12 @@
#else
return(0);
#endif
+ case XML_WITH_RELAXNG:
+#ifdef LIBXML_RELAXNG_ENABLED
+ return(1);
+#else
+ return(0);
+#endif
case XML_WITH_SCHEMAS:
#ifdef LIBXML_SCHEMAS_ENABLED
return(1);
diff --git a/python/libxml.c b/python/libxml.c
index d47e63a..b944465 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -2876,14 +2876,13 @@
}
#endif /* LIBXML_CATALOG_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
-
/************************************************************************
* *
* RelaxNG error handler registration *
* *
************************************************************************/
+#ifdef LIBXML_RELAXNG_ENABLED
typedef struct
{
PyObject *warn;
@@ -3035,7 +3034,9 @@
Py_INCREF(Py_None);
return(Py_None);
}
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
typedef struct
{
PyObject *warn;
@@ -3188,8 +3189,7 @@
Py_INCREF(Py_None);
return(Py_None);
}
-
-#endif
+#endif /* LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
@@ -3594,9 +3594,11 @@
#ifdef LIBXML_CATALOG_ENABLED
{(char *)"addLocalCatalog", libxml_addLocalCatalog, METH_VARARGS, NULL },
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
{(char *)"xmlRelaxNGSetValidErrors", libxml_xmlRelaxNGSetValidErrors, METH_VARARGS, NULL},
{(char *)"xmlRelaxNGFreeValidCtxt", libxml_xmlRelaxNGFreeValidCtxt, METH_VARARGS, NULL},
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
{(char *)"xmlSchemaSetValidErrors", libxml_xmlSchemaSetValidErrors, METH_VARARGS, NULL},
{(char *)"xmlSchemaFreeValidCtxt", libxml_xmlSchemaFreeValidCtxt, METH_VARARGS, NULL},
#endif
diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h
index 1908b26..d3fdb69 100644
--- a/python/libxml_wrap.h
+++ b/python/libxml_wrap.h
@@ -19,8 +19,10 @@
#include <libxml/xmlreader.h>
#include <libxml/globals.h>
#include <libxml/xmlsave.h>
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#endif
@@ -204,7 +206,7 @@
#define PyFile_Release(f)
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
typedef struct {
PyObject_HEAD
xmlRelaxNGPtr obj;
@@ -229,6 +231,9 @@
#define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
(((PyrelaxNgValidCtxt_Object *)(v))->obj))
+#endif /* LIBXML_RELAXNG_ENABLED */
+
+#ifdef LIBXML_SCHEMAS_ENABLED
typedef struct {
PyObject_HEAD
xmlSchemaPtr obj;
@@ -292,10 +297,12 @@
PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
PyObject * libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt);
PyObject * libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt);
PyObject * libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid);
diff --git a/python/types.c b/python/types.c
index 664e955..90ca7d8 100644
--- a/python/types.c
+++ b/python/types.c
@@ -771,7 +771,7 @@
}
#endif /* LIBXML_READER_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
PyObject *
libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt)
{
@@ -815,7 +815,9 @@
(char *) "xmlRelaxNGValidCtxtPtr", NULL);
return (ret);
}
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
PyObject *
libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt)
{
diff --git a/relaxng.c b/relaxng.c
index 7211017..c223dbb 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -16,7 +16,7 @@
#define IN_LIBXML
#include "libxml.h"
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <string.h>
#include <stdio.h>
@@ -29,7 +29,6 @@
#include <libxml/relaxng.h>
-#include <libxml/xmlschemastypes.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
#include <libxml/xmlschemastypes.h>
@@ -10867,4 +10866,4 @@
return (ret);
}
-#endif /* LIBXML_SCHEMAS_ENABLED */
+#endif /* LIBXML_RELAXNG_ENABLED */
diff --git a/runsuite.c b/runsuite.c
index c92b818..126e181 100644
--- a/runsuite.c
+++ b/runsuite.c
@@ -17,7 +17,8 @@
#include <libxml/parserInternals.h>
#include <libxml/tree.h>
#include <libxml/uri.h>
-#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#if (defined(LIBXML_RELAXNG_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)) && \
+ defined(LIBXML_XPATH_ENABLED)
#include <libxml/xmlreader.h>
#include <libxml/xpath.h>
@@ -55,16 +56,6 @@
return(1);
}
-static xmlChar *composeDir(const xmlChar *dir, const xmlChar *path) {
- char buf[500];
-
- if (dir == NULL) return(xmlStrdup(path));
- if (path == NULL) return(NULL);
-
- snprintf(buf, 500, "%s/%s", (const char *) dir, (const char *) path);
- return(xmlStrdup((const xmlChar *) buf));
-}
-
/************************************************************************
* *
* Libxml2 specific routines *
@@ -78,60 +69,6 @@
static int nb_unimplemented = 0;
static int nb_leaks = 0;
-static int
-fatalError(void) {
- fprintf(stderr, "Exitting tests on fatal error\n");
- exit(1);
-}
-
-/*
- * that's needed to implement <resource>
- */
-#define MAX_ENTITIES 20
-static char *testEntitiesName[MAX_ENTITIES];
-static char *testEntitiesValue[MAX_ENTITIES];
-static int nb_entities = 0;
-static void resetEntities(void) {
- int i;
-
- for (i = 0;i < nb_entities;i++) {
- if (testEntitiesName[i] != NULL)
- xmlFree(testEntitiesName[i]);
- if (testEntitiesValue[i] != NULL)
- xmlFree(testEntitiesValue[i]);
- }
- nb_entities = 0;
-}
-static int addEntity(char *name, char *content) {
- if (nb_entities >= MAX_ENTITIES) {
- fprintf(stderr, "Too many entities defined\n");
- return(-1);
- }
- testEntitiesName[nb_entities] = name;
- testEntitiesValue[nb_entities] = content;
- nb_entities++;
- return(0);
-}
-
-static int
-testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL,
- const char *ID ATTRIBUTE_UNUSED,
- xmlResourceType type ATTRIBUTE_UNUSED,
- int flags ATTRIBUTE_UNUSED, xmlParserInputPtr *out) {
- int i;
-
- for (i = 0; i < nb_entities; i++) {
- if (!strcmp(testEntitiesName[i], URL)) {
- *out = xmlNewInputFromString(testEntitiesName[i],
- testEntitiesValue[i],
- XML_INPUT_BUF_STATIC);
- return(XML_ERR_OK);
- }
- }
-
- return(xmlNewInputFromUrl(URL, 0, out));
-}
-
/*
* Trapping the error messages at the generic level to grab the equivalent of
* stderr messages on CLI tools.
@@ -206,6 +143,8 @@
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
xmlSchemaInitTypes();
+#endif
+#ifdef LIBXML_RELAXNG_ENABLED
xmlRelaxNGInitTypes();
#endif
}
@@ -271,6 +210,62 @@
* *
************************************************************************/
+#ifdef LIBXML_RELAXNG_ENABLED
+
+/*
+ * that's needed to implement <resource>
+ */
+#define MAX_ENTITIES 20
+static char *testEntitiesName[MAX_ENTITIES];
+static char *testEntitiesValue[MAX_ENTITIES];
+static int nb_entities = 0;
+static void resetEntities(void) {
+ int i;
+
+ for (i = 0;i < nb_entities;i++) {
+ if (testEntitiesName[i] != NULL)
+ xmlFree(testEntitiesName[i]);
+ if (testEntitiesValue[i] != NULL)
+ xmlFree(testEntitiesValue[i]);
+ }
+ nb_entities = 0;
+}
+static int addEntity(char *name, char *content) {
+ if (nb_entities >= MAX_ENTITIES) {
+ fprintf(stderr, "Too many entities defined\n");
+ return(-1);
+ }
+ testEntitiesName[nb_entities] = name;
+ testEntitiesValue[nb_entities] = content;
+ nb_entities++;
+ return(0);
+}
+
+static int
+testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL,
+ const char *ID ATTRIBUTE_UNUSED,
+ xmlResourceType type ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED, xmlParserInputPtr *out) {
+ int i;
+
+ for (i = 0; i < nb_entities; i++) {
+ if (!strcmp(testEntitiesName[i], URL)) {
+ *out = xmlNewInputFromString(testEntitiesName[i],
+ testEntitiesValue[i],
+ XML_INPUT_BUF_STATIC);
+ return(XML_ERR_OK);
+ }
+ }
+
+ return(xmlNewInputFromUrl(URL, 0, out));
+}
+
+static int
+fatalError(void) {
+ fprintf(stderr, "Exitting tests on fatal error\n");
+ exit(1);
+}
+
static int
xsdIncorrectTestCase(xmlNodePtr cur) {
xmlNodePtr test;
@@ -330,6 +325,16 @@
return(ret);
}
+static xmlChar *composeDir(const xmlChar *dir, const xmlChar *path) {
+ char buf[500];
+
+ if (dir == NULL) return(xmlStrdup(path));
+ if (path == NULL) return(NULL);
+
+ snprintf(buf, 500, "%s/%s", (const char *) dir, (const char *) path);
+ return(xmlStrdup((const xmlChar *) buf));
+}
+
static void
installResources(xmlNodePtr tst, const xmlChar *base) {
xmlNodePtr test;
@@ -732,6 +737,7 @@
xmlFreeDoc(doc);
return(ret);
}
+#endif /* LIBXML_RELAXNG_ENABLED */
/************************************************************************
* *
@@ -739,6 +745,7 @@
* *
************************************************************************/
+#ifdef LIBXML_SCHEMAS_ENABLED
static int
xstcTestInstance(xmlNodePtr cur, xmlSchemaPtr schemas,
const xmlChar *spath, const char *base) {
@@ -998,6 +1005,7 @@
xmlFreeDoc(doc);
return(ret);
}
+#endif /* LIBXML_SCHEMAS_ENABLED */
/************************************************************************
* *
@@ -1008,7 +1016,10 @@
int
main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
int ret = 0;
- int old_errors, old_tests, old_leaks, expected_errors;
+ int old_errors, old_tests, old_leaks;
+#ifdef LIBXML_RELAXNG_ENABLED
+ int expected_errors;
+#endif
logfile = fopen(LOGFILE, "wb");
if (logfile == NULL) {
@@ -1021,7 +1032,7 @@
if ((argc >= 2) && (!strcmp(argv[1], "-v")))
verbose = 1;
-
+#ifdef LIBXML_RELAXNG_ENABLED
old_errors = nb_errors;
old_tests = nb_tests;
old_leaks = nb_leaks;
@@ -1063,7 +1074,9 @@
nb_tests - old_tests,
nb_errors - old_errors,
nb_leaks - old_leaks);
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
old_errors = nb_errors;
old_tests = nb_tests;
old_leaks = nb_leaks;
@@ -1123,6 +1136,7 @@
printf("Some errors were expected.\n");
nb_errors = old_errors;
}
+#endif /* LIBXML_SCHEMAS_ENABLED */
if ((nb_errors == 0) && (nb_leaks == 0)) {
ret = 0;
@@ -1140,7 +1154,7 @@
fclose(logfile);
return(ret);
}
-#else /* !SCHEMAS */
+#else /* !RELAXNG && !SCHEMAS */
int
main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
fprintf(stderr, "runsuite requires support for schemas and xpath in libxml2\n");
diff --git a/runtest.c b/runtest.c
index f1d7a75..1d36ea0 100644
--- a/runtest.c
+++ b/runtest.c
@@ -52,8 +52,11 @@
#endif
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
+#endif
+
+#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>
#endif
@@ -313,9 +316,11 @@
#endif
xmlInitializeCatalog();
#endif
+#ifdef LIBXML_RELAXNG_ENABLED
+ xmlRelaxNGInitTypes();
+#endif
#ifdef LIBXML_SCHEMAS_ENABLED
xmlSchemaInitTypes();
- xmlRelaxNGInitTypes();
#endif
}
@@ -2732,7 +2737,7 @@
return(-1);
}
}
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (rng != NULL) {
ret = xmlTextReaderRelaxNGValidate(reader, rng);
if (ret < 0) {
@@ -3527,12 +3532,13 @@
return(failures);
}
-#ifdef LIBXML_SCHEMAS_ENABLED
/************************************************************************
* *
* Schemas tests *
* *
************************************************************************/
+
+#ifdef LIBXML_SCHEMAS_ENABLED
static int
schemasOneTest(const char *sch,
const char *filename,
@@ -3687,12 +3693,15 @@
return(res);
}
+#endif /* LIBXML_SCHEMAS_ENABLED */
/************************************************************************
* *
- * Schemas tests *
+ * RELAX NG tests *
* *
************************************************************************/
+
+#ifdef LIBXML_RELAXNG_ENABLED
static int
rngOneTest(const char *sch,
const char *filename,
@@ -3915,7 +3924,7 @@
}
#endif /* READER */
-#endif
+#endif /* LIBXML_RELAX_ENABLED */
/************************************************************************
* *
@@ -5272,6 +5281,8 @@
{ "Schemas regression tests" ,
schemasTest, "./test/schemas/*_*.xsd", NULL, NULL, NULL,
0 },
+#endif
+#ifdef LIBXML_RELAXNG_ENABLED
{ "Relax-NG regression tests" ,
rngTest, "./test/relaxng/*.rng", NULL, NULL, NULL,
XML_PARSE_DTDATTR | XML_PARSE_NOENT },
diff --git a/shell.c b/shell.c
index ebefb50..623cc77 100644
--- a/shell.c
+++ b/shell.c
@@ -31,7 +31,7 @@
#include <libxml/uri.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
#endif
@@ -599,7 +599,7 @@
return (0);
}
-#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_RELAXNG_ENABLED)
static void
xmllintShellPrintf(void *ctx, const char *msg, ...) {
xmllintShellCtxtPtr sctxt = ctx;
@@ -609,9 +609,9 @@
vfprintf(sctxt->output, msg, ap);
va_end(ap);
}
-#endif /* defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
+#endif /* defined(LIBXML_VALID_ENABLED) || defined(LIBXML_RELAXNG_ENABLED) */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
/**
* xmllintShellRNGValidate:
* @ctxt: the shell context
@@ -1227,7 +1227,7 @@
#ifdef LIBXML_VALID_ENABLED
fprintf(ctxt->output, "\tvalidate check the document for errors\n");
#endif /* LIBXML_VALID_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
fprintf(ctxt->output, "\trelaxng rng validate the document against the Relax-NG schemas\n");
#endif
fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
@@ -1237,7 +1237,7 @@
#endif /* LIBXML_VALID_ENABLED */
} else if (!strcmp(command, "load")) {
xmllintShellLoad(ctxt, arg, NULL, NULL);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
} else if (!strcmp(command, "relaxng")) {
xmllintShellRNGValidate(ctxt, arg, NULL, NULL);
#endif
diff --git a/testModule.c b/testModule.c
index c6c81a1..4baf426 100644
--- a/testModule.c
+++ b/testModule.c
@@ -81,4 +81,4 @@
printf("%s : Module support not compiled in\n", argv[0]);
return(0);
}
-#endif /* LIBXML_SCHEMAS_ENABLED */
+#endif /* LIBXML_MODULES_ENABLED */
diff --git a/testapi.c b/testapi.c
index 10427c4..94af5e8 100644
--- a/testapi.c
+++ b/testapi.c
@@ -142,7 +142,7 @@
#ifdef LIBXML_CATALOG_ENABLED
xmlInitializeCatalog();
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
xmlRelaxNGInitTypes();
#endif
@@ -852,6 +852,8 @@
}
static void desret_xmlSchemaTypePtr(xmlSchemaTypePtr val ATTRIBUTE_UNUSED) {
}
+#endif
+#ifdef LIBXML_RELAXNG_ENABLED
static void desret_xmlRelaxNGParserCtxtPtr(xmlRelaxNGParserCtxtPtr val) {
xmlRelaxNGFreeParserCtxt(val);
}
@@ -17535,7 +17537,7 @@
test_xmlRelaxNGDump(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
int mem_base;
FILE * output; /* the file output */
int n_output;
@@ -17574,7 +17576,7 @@
test_xmlRelaxNGDumpTree(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
int mem_base;
FILE * output; /* the file output */
int n_output;
@@ -17608,21 +17610,21 @@
return(test_ret);
}
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#define gen_nb_xmlRelaxNGParserCtxtPtr 1
#define gen_xmlRelaxNGParserCtxtPtr(no, nr) NULL
#define des_xmlRelaxNGParserCtxtPtr(no, val, nr)
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#define gen_nb_xmlRelaxNGValidityErrorFunc_ptr 1
#define gen_xmlRelaxNGValidityErrorFunc_ptr(no, nr) NULL
#define des_xmlRelaxNGValidityErrorFunc_ptr(no, val, nr)
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#define gen_nb_xmlRelaxNGValidityWarningFunc_ptr 1
#define gen_xmlRelaxNGValidityWarningFunc_ptr(no, nr) NULL
@@ -17634,7 +17636,7 @@
test_xmlRelaxNGGetParserErrors(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGParserCtxtPtr ctxt; /* a Relax-NG validation context */
@@ -17684,7 +17686,7 @@
return(test_ret);
}
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#define gen_nb_xmlRelaxNGValidCtxtPtr 1
#define gen_xmlRelaxNGValidCtxtPtr(no, nr) NULL
@@ -17696,7 +17698,7 @@
test_xmlRelaxNGGetValidErrors(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* a Relax-NG validation context */
@@ -17751,7 +17753,7 @@
test_xmlRelaxNGInitTypes(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
@@ -17778,7 +17780,7 @@
test_xmlRelaxNGNewDocParserCtxt(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
xmlRelaxNGParserCtxtPtr ret_val;
xmlDocPtr doc; /* a preparsed document tree */
@@ -17812,7 +17814,7 @@
test_xmlRelaxNGNewMemParserCtxt(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
xmlRelaxNGParserCtxtPtr ret_val;
const char * buffer; /* a pointer to a char array containing the schemas */
@@ -17856,7 +17858,7 @@
test_xmlRelaxNGNewParserCtxt(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
xmlRelaxNGParserCtxtPtr ret_val;
const char * URL; /* the location of the schema */
@@ -17960,7 +17962,7 @@
test_xmlRelaxNGValidateDoc(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* a Relax-NG validation context */
@@ -18001,7 +18003,7 @@
test_xmlRelaxNGValidateFullElement(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* the validation context */
@@ -18049,7 +18051,7 @@
test_xmlRelaxNGValidatePopElement(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG validation context */
@@ -18097,7 +18099,7 @@
test_xmlRelaxNGValidatePushCData(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG validation context */
@@ -18148,7 +18150,7 @@
test_xmlRelaxNGValidatePushElement(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGValidCtxtPtr ctxt; /* the validation context */
@@ -18196,7 +18198,7 @@
test_xmlRelaxParserSetFlag(void) {
int test_ret = 0;
-#if defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlRelaxNGParserCtxtPtr ctxt; /* a RelaxNG parser context */
@@ -33080,7 +33082,7 @@
test_xmlTextReaderRelaxNGSetSchema(void) {
int test_ret = 0;
-#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */
@@ -33121,7 +33123,7 @@
test_xmlTextReaderRelaxNGValidate(void) {
int test_ret = 0;
-#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */
@@ -33162,7 +33164,7 @@
test_xmlTextReaderRelaxNGValidateCtxt(void) {
int test_ret = 0;
-#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_RELAXNG_ENABLED)
int mem_base;
int ret_val;
xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */
diff --git a/threads.c b/threads.c
index a8a07f6..9671072 100644
--- a/threads.c
+++ b/threads.c
@@ -19,9 +19,11 @@
#ifdef LIBXML_CATALOG_ENABLED
#include <libxml/catalog.h>
#endif
+#ifdef LIBXML_RELAXNG_ENABLED
+#include <libxml/relaxng.h>
+#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemastypes.h>
-#include <libxml/relaxng.h>
#endif
#if defined(SOLARIS)
@@ -494,6 +496,8 @@
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
xmlSchemaCleanupTypes();
+#endif
+#ifdef LIBXML_RELAXNG_ENABLED
xmlRelaxNGCleanupTypes();
#endif
diff --git a/tools/gentest.py b/tools/gentest.py
index fcdf206..d7c5139 100755
--- a/tools/gentest.py
+++ b/tools/gentest.py
@@ -30,7 +30,7 @@
"HTMLparser": "LIBXML_HTML_ENABLED",
"catalog": "LIBXML_CATALOG_ENABLED",
"xmlreader": "LIBXML_READER_ENABLED",
- "relaxng": "LIBXML_SCHEMAS_ENABLED",
+ "relaxng": "LIBXML_RELAXNG_ENABLED",
"schemasInternals": "LIBXML_SCHEMAS_ENABLED",
"xmlschemas": "LIBXML_SCHEMAS_ENABLED",
"xmlschemastypes": "LIBXML_SCHEMAS_ENABLED",
diff --git a/xmllint.c b/xmllint.c
index b003288..797098e 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -53,8 +53,10 @@
#ifdef LIBXML_SCHEMATRON_ENABLED
#include <libxml/schematron.h>
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#endif
#ifdef LIBXML_PATTERN_ENABLED
@@ -144,9 +146,11 @@
const char *dtdvalidfpi;
int insert;
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
const char *relaxng;
xmlRelaxNGPtr relaxngschemas;
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
const char *schema;
xmlSchemaPtr wxschemas;
#endif
@@ -1773,7 +1777,7 @@
if (lint->maxAmpl > 0)
xmlTextReaderSetMaxAmplification(reader, lint->maxAmpl);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (lint->relaxng != NULL) {
if ((lint->timing) && (lint->repeat == 1)) {
startTimer(lint);
@@ -1789,6 +1793,8 @@
endTimer(lint, "Compiling the schemas");
}
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (lint->schema != NULL) {
if ((lint->timing) && (lint->repeat == 1)) {
startTimer(lint);
@@ -1823,7 +1829,7 @@
ret = xmlTextReaderRead(reader);
}
if ((lint->timing) && (lint->repeat == 1)) {
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (lint->relaxng != NULL)
endTimer(lint, "Parsing and validating");
else
@@ -1845,14 +1851,26 @@
}
}
#endif /* LIBXML_VALID_ENABLED */
+#if defined(LIBXML_RELAXNG_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+ {
+ int hasSchema = 0;
+
+#ifdef LIBXML_RELAXNG_ENABLED
+ if (lint->relaxng != NULL)
+ hasSchema = 1;
+#endif
#ifdef LIBXML_SCHEMAS_ENABLED
- if ((lint->relaxng != NULL) || (lint->schema != NULL)) {
- if (xmlTextReaderIsValid(reader) != 1) {
- fprintf(errStream, "%s fails to validate\n", filename);
- lint->progresult = XMLLINT_ERR_VALID;
- } else {
- if (!lint->quiet) {
- fprintf(errStream, "%s validates\n", filename);
+ if (lint->schema != NULL)
+ hasSchema = 1;
+#endif
+ if (hasSchema) {
+ if (xmlTextReaderIsValid(reader) != 1) {
+ fprintf(errStream, "%s fails to validate\n", filename);
+ lint->progresult = XMLLINT_ERR_VALID;
+ } else {
+ if (!lint->quiet) {
+ fprintf(errStream, "%s validates\n", filename);
+ }
}
}
}
@@ -2588,7 +2606,8 @@
}
}
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+
+#ifdef LIBXML_RELAXNG_ENABLED
if (lint->relaxngschemas != NULL) {
xmlRelaxNGValidCtxtPtr ctxt;
int ret;
@@ -2620,7 +2639,11 @@
if ((lint->timing) && (lint->repeat == 1)) {
endTimer(lint, "Validating");
}
- } else if (lint->wxschemas != NULL) {
+ }
+#endif /* LIBXML_RELAXNG_ENABLED */
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+ if (lint->wxschemas != NULL) {
xmlSchemaValidCtxtPtr ctxt;
int ret;
@@ -2652,7 +2675,7 @@
endTimer(lint, "Validating");
}
}
-#endif
+#endif /* LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_DEBUG_ENABLED
if ((lint->debugent)
@@ -2712,6 +2735,7 @@
if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(errStream, "Regexps ");
if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(errStream, "Automata ");
if (xmlHasFeature(XML_WITH_EXPR)) fprintf(errStream, "Expr ");
+ if (xmlHasFeature(XML_WITH_RELAXNG)) fprintf(errStream, "RelaxNG ");
if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(errStream, "Schemas ");
if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(errStream, "Schematron ");
if (xmlHasFeature(XML_WITH_MODULES)) fprintf(errStream, "Modules ");
@@ -2819,8 +2843,10 @@
fprintf(f, "\t--pattern pattern_value : test the pattern support\n");
#endif
#endif /* LIBXML_READER_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
fprintf(f, "\t--relaxng schema : do RelaxNG validation against the schema\n");
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
fprintf(f, "\t--schema schema : do validation against the WXS schema\n");
#endif
#ifdef LIBXML_SCHEMATRON_ENABLED
@@ -2880,9 +2906,11 @@
(!strcmp(arg, "-dtdvalidfpi")) ||
(!strcmp(arg, "--dtdvalidfpi")) ||
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
(!strcmp(arg, "-relaxng")) ||
(!strcmp(arg, "--relaxng")) ||
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
(!strcmp(arg, "-schema")) ||
(!strcmp(arg, "--schema")) ||
#endif
@@ -3159,12 +3187,14 @@
} else if ((!strcmp(argv[i], "-sax")) ||
(!strcmp(argv[i], "--sax"))) {
lint->sax = 1;
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
} else if ((!strcmp(argv[i], "-relaxng")) ||
(!strcmp(argv[i], "--relaxng"))) {
i++;
lint->relaxng = argv[i];
lint->options |= XML_PARSE_NOENT;
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
} else if ((!strcmp(argv[i], "-schema")) ||
(!strcmp(argv[i], "--schema"))) {
i++;
@@ -3333,7 +3363,7 @@
}
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if ((lint->relaxng != NULL) && (lint->sax == 0)
#ifdef LIBXML_READER_ENABLED
&& (lint->stream == 0)
@@ -3363,9 +3393,13 @@
if (lint->timing) {
endTimer(lint, "Compiling the schemas");
}
- } else if ((lint->schema != NULL)
+ }
+#endif /* LIBXML_RELAXNG_ENABLED */
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+ if ((lint->schema != NULL)
#ifdef LIBXML_READER_ENABLED
- && (lint->stream == 0)
+ && (lint->stream == 0)
#endif
) {
xmlSchemaParserCtxtPtr ctxt;
@@ -3570,9 +3604,11 @@
if (lint->wxschematron != NULL)
xmlSchematronFree(lint->wxschematron);
#endif
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (lint->relaxngschemas != NULL)
xmlRelaxNGFree(lint->relaxngschemas);
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (lint->wxschemas != NULL)
xmlSchemaFree(lint->wxschemas);
#endif
diff --git a/xmlreader.c b/xmlreader.c
index 6d815a9..fc87be7 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -27,8 +27,10 @@
#include <libxml/xmlIO.h>
#include <libxml/xmlreader.h>
#include <libxml/parserInternals.h>
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemas.h>
#endif
#include <libxml/uri.h>
@@ -127,13 +129,15 @@
xmlTextReaderErrorFunc errorFunc; /* callback function */
void *errorFuncArg; /* callback function user argument */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
/* Handling of RelaxNG validation */
xmlRelaxNGPtr rngSchemas; /* The Relax NG schemas */
xmlRelaxNGValidCtxtPtr rngValidCtxt;/* The Relax NG validation context */
int rngPreserveCtxt; /* 1 if the context was provided by the user */
int rngValidErrors;/* The number of errors detected */
xmlNodePtr rngFullNode; /* the node if RNG not progressive */
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
/* Handling of Schemas validation */
xmlSchemaPtr xsdSchemas; /* The Schemas schemas */
xmlSchemaValidCtxtPtr xsdValidCtxt;/* The Schemas validation context */
@@ -916,7 +920,7 @@
}*/
}
#endif /* LIBXML_VALID_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if ((reader->validate == XML_TEXTREADER_VALIDATE_RNG) &&
(reader->rngValidCtxt != NULL)) {
int ret;
@@ -965,7 +969,7 @@
data, len);
}
#endif /* LIBXML_VALID_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if ((reader->validate == XML_TEXTREADER_VALIDATE_RNG) &&
(reader->rngValidCtxt != NULL)) {
int ret;
@@ -1015,7 +1019,7 @@
}*/
}
#endif /* LIBXML_VALID_ENABLED */
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if ((reader->validate == XML_TEXTREADER_VALIDATE_RNG) &&
(reader->rngValidCtxt != NULL)) {
int ret;
@@ -2132,7 +2136,7 @@
xmlFreeTextReader(xmlTextReaderPtr reader) {
if (reader == NULL)
return;
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->rngSchemas != NULL) {
xmlRelaxNGFree(reader->rngSchemas);
reader->rngSchemas = NULL;
@@ -2142,6 +2146,8 @@
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
reader->rngValidCtxt = NULL;
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->xsdPlug != NULL) {
xmlSchemaSAXUnplug(reader->xsdPlug);
reader->xsdPlug = NULL;
@@ -4003,7 +4009,7 @@
return(reader->ctxt->myDoc);
}
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
/**
* xmlTextReaderRelaxNGSetSchema:
* @reader: the xmlTextReaderPtr used
@@ -4058,7 +4064,9 @@
reader->validate = XML_TEXTREADER_VALIDATE_RNG;
return(0);
}
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
/**
* xmlTextReaderLocator:
* @ctx: the xmlTextReaderPtr used
@@ -4191,7 +4199,9 @@
reader->validate = XML_TEXTREADER_VALIDATE_XSD;
return(0);
}
+#endif /* LIBXML_SCHEMAS_ENABLED */
+#ifdef LIBXML_RELAXNG_ENABLED
/**
* xmlTextReaderRelaxNGValidateInternal:
* @reader: the xmlTextReaderPtr used
@@ -4279,7 +4289,9 @@
reader->validate = XML_TEXTREADER_VALIDATE_RNG;
return(0);
}
+#endif /* LIBXML_RELAXNG_ENABLED */
+#ifdef LIBXML_SCHEMAS_ENABLED
/**
* xmlTextReaderSchemaValidateInternal:
* @reader: the xmlTextReaderPtr used
@@ -4427,7 +4439,9 @@
{
return(xmlTextReaderSchemaValidateInternal(reader, xsd, NULL, 0));
}
+#endif /* LIBXML_SCHEMAS_ENABLED */
+#ifdef LIBXML_RELAXNG_ENABLED
/**
* xmlTextReaderRelaxNGValidateCtxt:
* @reader: the xmlTextReaderPtr used
@@ -4466,8 +4480,7 @@
{
return(xmlTextReaderRelaxNGValidateInternal(reader, rng, NULL, 0));
}
-
-#endif
+#endif /* LIBXML_RELAXNG_ENABLED */
/**
* xmlTextReaderIsNamespaceDecl:
@@ -4651,11 +4664,13 @@
reader->errorFuncArg = arg;
xmlCtxtSetErrorHandler(reader->ctxt,
xmlTextReaderStructuredRelay, reader);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->rngValidCtxt) {
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
xmlTextReaderStructuredRelay, reader);
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->xsdValidCtxt) {
xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
xmlTextReaderStructuredRelay, reader);
@@ -4667,11 +4682,13 @@
reader->sErrorFunc = NULL;
reader->errorFuncArg = NULL;
xmlCtxtSetErrorHandler(reader->ctxt, NULL, NULL);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->rngValidCtxt) {
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
NULL);
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->xsdValidCtxt) {
xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
NULL);
@@ -4700,11 +4717,13 @@
reader->errorFuncArg = arg;
xmlCtxtSetErrorHandler(reader->ctxt,
xmlTextReaderStructuredRelay, reader);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->rngValidCtxt) {
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
xmlTextReaderStructuredRelay, reader);
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->xsdValidCtxt) {
xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
xmlTextReaderStructuredRelay, reader);
@@ -4716,11 +4735,13 @@
reader->sErrorFunc = NULL;
reader->errorFuncArg = NULL;
xmlCtxtSetErrorHandler(reader->ctxt, NULL, NULL);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->rngValidCtxt) {
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
NULL);
}
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->xsdValidCtxt) {
xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
NULL);
@@ -4783,9 +4804,11 @@
{
if (reader == NULL)
return (-1);
-#ifdef LIBXML_SCHEMAS_ENABLED
+#ifdef LIBXML_RELAXNG_ENABLED
if (reader->validate == XML_TEXTREADER_VALIDATE_RNG)
return (reader->rngValidErrors == 0);
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->validate == XML_TEXTREADER_VALIDATE_XSD)
return (reader->xsdValidErrors == 0);
#endif