fix an error message added tree2 example from Lucas Brasilino Daniel
* xinclude.c: fix an error message
* doc/examples/*: added tree2 example from Lucas Brasilino
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6cb9d13..1a5a542 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 19 17:19:35 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * xinclude.c: fix an error message
+ * doc/examples/*: added tree2 example from Lucas Brasilino
+
Wed Nov 19 17:50:47 HKT 2003 William Brack <wbrack@mmm.com.hk>
* doc/newapi.xsl: improve the sort sequence for page content
diff --git a/doc/examples/.cvsignore b/doc/examples/.cvsignore
index aa4aa98..f1f8cbf 100644
--- a/doc/examples/.cvsignore
+++ b/doc/examples/.cvsignore
@@ -5,3 +5,4 @@
parse1
parse2
tree1
+tree2
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 24e37e5..d5e2331 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -19,9 +19,9 @@
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.out $(DESTDIR)$(TARGET_DIR)
-EXTRA_DIST=examples.xsl index.py test1.xml examples.xml test2.xml tree1.out
+EXTRA_DIST=examples.xsl index.py test1.xml examples.xml test2.xml tree1.out tree2.out
-noinst_PROGRAMS=xpath1 parse1 parse2 tree1
+noinst_PROGRAMS=xpath1 parse1 parse2 tree1 tree2
xpath1_SOURCES=xpath1.c
xpath1_LDFLAGS=
@@ -43,9 +43,15 @@
tree1_DEPENDENCIES= $(DEPS)
tree1_LDADD= @RDL_LIBS@ $(LDADDS)
+tree2_SOURCES=tree2.c
+tree2_LDFLAGS=
+tree2_DEPENDENCIES= $(DEPS)
+tree2_LDADD= @RDL_LIBS@ $(LDADDS)
+
tests: $(noinst_PROGRAMS)
parse1 test1.xml
parse2 test2.xml
tree1 test2.xml > tree1.tmp ; diff tree1.tmp tree1.out ; rm tree1.tmp
+ tree2 > tree2.tmp ; diff tree2.tmp tree2.out ; rm tree2.tmp
diff --git a/doc/examples/examples.xml b/doc/examples/examples.xml
index ec8b438..5c5e5ed 100644
--- a/doc/examples/examples.xml
+++ b/doc/examples/examples.xml
@@ -99,12 +99,40 @@
<function line='72' file='tree' name='xmlDocGetRootElement'/>
</uses>
</example>
+ <example filename='tree2.c'>
+ <synopsis>Creates a tree</synopsis>
+ <purpose>Shows how to create document, nodes and dump it to stdout or file.</purpose>
+ <usage>tree2 <filename> -Default output: stdout</usage>
+ <test>tree2 > tree2.tmp ; diff tree2.tmp tree2.out ; rm tree2.tmp</test>
+ <author>Lucas Brasilino <brasilino@recife.pe.gov.br></author>
+ <copy>see Copyright for the status of this software </copy>
+ <section>Tree</section>
+ <includes>
+ <include><libxml/tree.h></include>
+ <include><libxml/parser.h></include>
+ </includes>
+ <uses>
+ <function line='73' file='tree' name='xmlNewText'/>
+ <function line='94' file='tree' name='xmlSaveFormatFileEnc'/>
+ <function line='76' file='tree' name='xmlAddChild'/>
+ <function line='39' file='tree' name='xmlDocSetRootElement'/>
+ <function line='103' file='parser' name='xmlCleanupParser'/>
+ <macro line='32' file='xmlversion' name='LIBXML_TEST_VERSION'/>
+ <function line='87' file='tree' name='xmlNewProp'/>
+ <function line='86' file='tree' name='xmlNewChild'/>
+ <function line='72' file='tree' name='xmlNewNode'/>
+ <function line='44' file='tree' name='xmlCreateIntSubset'/>
+ <function line='97' file='tree' name='xmlFreeDoc'/>
+ <function line='37' file='tree' name='xmlNewDoc'/>
+ </uses>
+ </example>
<symbols>
<symbol name='LIBXML_TEST_VERSION'>
<ref filename='xpath1.c'/>
<ref filename='parse1.c'/>
<ref filename='parse2.c'/>
<ref filename='tree1.c'/>
+ <ref filename='tree2.c'/>
</symbol>
<symbol name='XML_ELEMENT_NODE'>
<ref filename='xpath1.c'/>
@@ -116,11 +144,18 @@
<symbol name='XML_PARSE_DTDVALID'>
<ref filename='parse2.c'/>
</symbol>
+ <symbol name='xmlAddChild'>
+ <ref filename='tree2.c'/>
+ </symbol>
<symbol name='xmlCleanupParser'>
<ref filename='xpath1.c'/>
<ref filename='parse1.c'/>
<ref filename='parse2.c'/>
<ref filename='tree1.c'/>
+ <ref filename='tree2.c'/>
+ </symbol>
+ <symbol name='xmlCreateIntSubset'>
+ <ref filename='tree2.c'/>
</symbol>
<symbol name='xmlCtxtReadFile'>
<ref filename='parse2.c'/>
@@ -133,11 +168,15 @@
<ref filename='parse1.c'/>
<ref filename='parse2.c'/>
</symbol>
+ <symbol name='xmlDocSetRootElement'>
+ <ref filename='tree2.c'/>
+ </symbol>
<symbol name='xmlFreeDoc'>
<ref filename='xpath1.c'/>
<ref filename='parse1.c'/>
<ref filename='parse2.c'/>
<ref filename='tree1.c'/>
+ <ref filename='tree2.c'/>
</symbol>
<symbol name='xmlFreeParserCtxt'>
<ref filename='parse2.c'/>
@@ -145,9 +184,24 @@
<symbol name='xmlInitParser'>
<ref filename='xpath1.c'/>
</symbol>
+ <symbol name='xmlNewChild'>
+ <ref filename='tree2.c'/>
+ </symbol>
+ <symbol name='xmlNewDoc'>
+ <ref filename='tree2.c'/>
+ </symbol>
+ <symbol name='xmlNewNode'>
+ <ref filename='tree2.c'/>
+ </symbol>
<symbol name='xmlNewParserCtxt'>
<ref filename='parse2.c'/>
</symbol>
+ <symbol name='xmlNewProp'>
+ <ref filename='tree2.c'/>
+ </symbol>
+ <symbol name='xmlNewText'>
+ <ref filename='tree2.c'/>
+ </symbol>
<symbol name='xmlNodePtr'>
<ref filename='xpath1.c'/>
</symbol>
@@ -164,6 +218,9 @@
<symbol name='xmlReadFile'>
<ref filename='parse1.c'/>
</symbol>
+ <symbol name='xmlSaveFormatFileEnc'>
+ <ref filename='tree2.c'/>
+ </symbol>
<symbol name='xmlStrchr'>
<ref filename='xpath1.c'/>
</symbol>
@@ -199,6 +256,7 @@
</section>
<section name='Tree'>
<example filename='tree1.c'/>
+ <example filename='tree2.c'/>
</section>
<section name='XPath'>
<example filename='xpath1.c'/>
diff --git a/doc/examples/index.html b/doc/examples/index.html
index 7d27f89..abf5287 100644
--- a/doc/examples/index.html
+++ b/doc/examples/index.html
@@ -8,4 +8,4 @@
H3 {font-family: Verdana,Arial,Helvetica}
A:link, A:visited, A:active { text-decoration: underline }
</style><title>Libxml2 set of examples</title></head><body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Libxml2 set of examples</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Examples Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a href="../index.html">Home</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../html/index.html">API Menu</a></li><li><a href="#Parsing">Parsing Examples</a></li><li><a href="#Tree">Tree Examples</a></li><li><a href="#XPath">XPath Examples</a></li><li><a href="../guidelines.html">XML Guidelines</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><p> The examples are stored per section depending on the main focus
- of the example:</p><ul><li><p><a href="#Tree">Tree</a> :</p><ul><li><a href="#tree1.c">tree1.c</a>: Navigates a tree to print element names</li></ul></li><li><p><a href="#XPath">XPath</a> :</p><ul><li><a href="#xpath1.c">xpath1.c</a>: Evaluate XPath expression and prints result node set.</li></ul></li><li><p><a href="#Parsing">Parsing</a> :</p><ul><li><a href="#parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</li><li><a href="#parse2.c">parse2.c</a>: Parse and validate an XML file to a tree and free the result</li></ul></li></ul><h2><a name="Parsing" id="Parsing"></a>Parsing Examples</h2><h3><a name="parse1.c" href="parse1.c" id="parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</h3><p>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 24: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 26: Function <a href="../html/libxml-parser.html#xmlReadFile">xmlReadFile</a> from parser.h</li><li> line 31: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 45: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 50: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>parse1 test1.xml</p><p>Author: Daniel Veillard</p><h3><a name="parse2.c" href="parse2.c" id="parse2.c">parse2.c</a>: Parse and validate an XML file to a tree and free the result</h3><p>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 25: Type <a href="../html/libxml-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> from tree.h</li><li> line 26: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 29: Function <a href="../html/libxml-parser.html#xmlNewParserCtxt">xmlNewParserCtxt</a> from parser.h</li><li> line 35: Function <a href="../html/libxml-parser.html#xmlCtxtReadFile">xmlCtxtReadFile</a> from parser.h</li><li> line 44: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 47: Function <a href="../html/libxml-parser.html#xmlFreeParserCtxt">xmlFreeParserCtxt</a> from parser.h</li><li> line 61: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 66: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>parse2 test2.xml</p><p>Author: Daniel Veillard</p><h2><a name="Tree" id="Tree"></a>Tree Examples</h2><h3><a name="tree1.c" href="tree1.c" id="tree1.c">tree1.c</a>: Navigates a tree to print element names</h3><p>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 65: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 65: Function <a href="../html/libxml-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li><li> line 72: Function <a href="../html/libxml-tree.html#xmlDocGetRootElement">xmlDocGetRootElement</a> from tree.h</li><li> line 77: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 83: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>tree1 filename_or_URL</p><p>Author: Dodji Seketeli</p><h2><a name="XPath" id="XPath"></a>XPath Examples</h2><h3><a name="xpath1.c" href="xpath1.c" id="xpath1.c">xpath1.c</a>: Evaluate XPath expression and prints result node set.</h3><p>Shows how to evaluate XPath expression and register known namespaces in XPath context.</p><p>Includes:</p><ul><li><a href="../html/libxml-xpath.html"><libxml/xpath.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li><li><a href="../html/libxml-xpathInternals.html"><libxml/xpathInternals.h></a></li><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li></ul><p>Uses:</p><ul><li> line 35: Function <a href="../html/libxml-parser.html#xmlInitParser">xmlInitParser</a> from parser.h</li><li> line 39: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 45: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li><li> line 78: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 79: Type <a href="../html/libxml-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li><li> line 80: Type <a href="../html/libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li><li> line 86: Function <a href="../html/libxml-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li><li> line 93: Function <a href="../html/libxml-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li><li> line 109: Function <a href="../html/libxml-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li><li> line 121: Function <a href="../html/libxml-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li><li> line 122: Function <a href="../html/libxml-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li><li> line 123: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 148: Function <a href="../html/libxml-parser.html#xmlStrdup">xmlStrdup</a> from parser.h</li><li> line 172: Function <a href="../html/libxml-parser.html#xmlStrchr">xmlStrchr</a> from parser.h</li><li> line 178: Function <a href="../html/libxml-xpathInternals.html#xmlXPathRegisterNs">xmlXPathRegisterNs</a> from xpathInternals.h</li><li> line 198: Type <a href="../html/libxml-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li><li> line 210: Type <a href="../html/libxml-tree.html#xmlNsPtr">xmlNsPtr</a> from tree.h</li></ul><p>Usage:</p><p>xpath1 <xml-file> <xpath-expr> [<known-ns-list>]</p><p>Author: Aleksey Sanin</p><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
+ of the example:</p><ul><li><p><a href="#XPath">XPath</a> :</p><ul><li><a href="#xpath1.c">xpath1.c</a>: Evaluate XPath expression and prints result node set.</li></ul></li><li><p><a href="#Parsing">Parsing</a> :</p><ul><li><a href="#parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</li><li><a href="#parse2.c">parse2.c</a>: Parse and validate an XML file to a tree and free the result</li></ul></li><li><p><a href="#Tree">Tree</a> :</p><ul><li><a href="#tree1.c">tree1.c</a>: Navigates a tree to print element names</li><li><a href="#tree2.c">tree2.c</a>: Creates a tree</li></ul></li></ul><h2><a name="Parsing" id="Parsing"></a>Parsing Examples</h2><h3><a name="parse1.c" href="parse1.c" id="parse1.c">parse1.c</a>: Parse an XML file to a tree and free it</h3><p>Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 24: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 26: Function <a href="../html/libxml-parser.html#xmlReadFile">xmlReadFile</a> from parser.h</li><li> line 31: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 45: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 50: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>parse1 test1.xml</p><p>Author: Daniel Veillard</p><h3><a name="parse2.c" href="parse2.c" id="parse2.c">parse2.c</a>: Parse and validate an XML file to a tree and free the result</h3><p>Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 25: Type <a href="../html/libxml-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> from tree.h</li><li> line 26: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 29: Function <a href="../html/libxml-parser.html#xmlNewParserCtxt">xmlNewParserCtxt</a> from parser.h</li><li> line 35: Function <a href="../html/libxml-parser.html#xmlCtxtReadFile">xmlCtxtReadFile</a> from parser.h</li><li> line 44: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 47: Function <a href="../html/libxml-parser.html#xmlFreeParserCtxt">xmlFreeParserCtxt</a> from parser.h</li><li> line 61: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 66: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>parse2 test2.xml</p><p>Author: Daniel Veillard</p><h2><a name="Tree" id="Tree"></a>Tree Examples</h2><h3><a name="tree1.c" href="tree1.c" id="tree1.c">tree1.c</a>: Navigates a tree to print element names</h3><p>Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 65: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 65: Function <a href="../html/libxml-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li><li> line 72: Function <a href="../html/libxml-tree.html#xmlDocGetRootElement">xmlDocGetRootElement</a> from tree.h</li><li> line 77: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 83: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>tree1 filename_or_URL</p><p>Author: Dodji Seketeli</p><h3><a name="tree2.c" href="tree2.c" id="tree2.c">tree2.c</a>: Creates a tree</h3><p>Shows how to create document, nodes and dump it to stdout or file.</p><p>Includes:</p><ul><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li></ul><p>Uses:</p><ul><li> line 32: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 37: Function <a href="../html/libxml-tree.html#xmlNewDoc">xmlNewDoc</a> from tree.h</li><li> line 39: Function <a href="../html/libxml-tree.html#xmlDocSetRootElement">xmlDocSetRootElement</a> from tree.h</li><li> line 44: Function <a href="../html/libxml-tree.html#xmlCreateIntSubset">xmlCreateIntSubset</a> from tree.h</li><li> line 72: Function <a href="../html/libxml-tree.html#xmlNewNode">xmlNewNode</a> from tree.h</li><li> line 73: Function <a href="../html/libxml-tree.html#xmlNewText">xmlNewText</a> from tree.h</li><li> line 76: Function <a href="../html/libxml-tree.html#xmlAddChild">xmlAddChild</a> from tree.h</li><li> line 86: Function <a href="../html/libxml-tree.html#xmlNewChild">xmlNewChild</a> from tree.h</li><li> line 87: Function <a href="../html/libxml-tree.html#xmlNewProp">xmlNewProp</a> from tree.h</li><li> line 94: Function <a href="../html/libxml-tree.html#xmlSaveFormatFileEnc">xmlSaveFormatFileEnc</a> from tree.h</li><li> line 97: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 103: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li></ul><p>Usage:</p><p>tree2 <filename> -Default output: stdout</p><p>Author: Lucas Brasilino <brasilino@recife.pe.gov.br></p><h2><a name="XPath" id="XPath"></a>XPath Examples</h2><h3><a name="xpath1.c" href="xpath1.c" id="xpath1.c">xpath1.c</a>: Evaluate XPath expression and prints result node set.</h3><p>Shows how to evaluate XPath expression and register known namespaces in XPath context.</p><p>Includes:</p><ul><li><a href="../html/libxml-xpath.html"><libxml/xpath.h></a></li><li><a href="../html/libxml-parser.html"><libxml/parser.h></a></li><li><a href="../html/libxml-xpathInternals.html"><libxml/xpathInternals.h></a></li><li><a href="../html/libxml-tree.html"><libxml/tree.h></a></li></ul><p>Uses:</p><ul><li> line 35: Function <a href="../html/libxml-parser.html#xmlInitParser">xmlInitParser</a> from parser.h</li><li> line 39: Macro <a href="../html/libxml-xmlversion.html#LIBXML_TEST_VERSION">LIBXML_TEST_VERSION</a> from xmlversion.h</li><li> line 45: Function <a href="../html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a> from parser.h</li><li> line 78: Type <a href="../html/libxml-tree.html#xmlDocPtr">xmlDocPtr</a> from tree.h</li><li> line 79: Type <a href="../html/libxml-xpath.html#xmlXPathContextPtr">xmlXPathContextPtr</a> from xpath.h</li><li> line 80: Type <a href="../html/libxml-xpath.html#xmlXPathObjectPtr">xmlXPathObjectPtr</a> from xpath.h</li><li> line 86: Function <a href="../html/libxml-parser.html#xmlParseFile">xmlParseFile</a> from parser.h</li><li> line 93: Function <a href="../html/libxml-xpath.html#xmlXPathNewContext">xmlXPathNewContext</a> from xpath.h</li><li> line 109: Function <a href="../html/libxml-xpath.html#xmlXPathEvalExpression">xmlXPathEvalExpression</a> from xpath.h</li><li> line 121: Function <a href="../html/libxml-xpath.html#xmlXPathFreeObject">xmlXPathFreeObject</a> from xpath.h</li><li> line 122: Function <a href="../html/libxml-xpath.html#xmlXPathFreeContext">xmlXPathFreeContext</a> from xpath.h</li><li> line 123: Function <a href="../html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a> from tree.h</li><li> line 148: Function <a href="../html/libxml-parser.html#xmlStrdup">xmlStrdup</a> from parser.h</li><li> line 172: Function <a href="../html/libxml-parser.html#xmlStrchr">xmlStrchr</a> from parser.h</li><li> line 178: Function <a href="../html/libxml-xpathInternals.html#xmlXPathRegisterNs">xmlXPathRegisterNs</a> from xpathInternals.h</li><li> line 198: Type <a href="../html/libxml-tree.html#xmlNodePtr">xmlNodePtr</a> from tree.h</li><li> line 210: Type <a href="../html/libxml-tree.html#xmlNsPtr">xmlNsPtr</a> from tree.h</li></ul><p>Usage:</p><p>xpath1 <xml-file> <xpath-expr> [<known-ns-list>]</p><p>Author: Aleksey Sanin</p><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/examples/tree1.out b/doc/examples/tree1.out
index 9940bca..7b14ad0 100644
--- a/doc/examples/tree1.out
+++ b/doc/examples/tree1.out
Binary files differ
diff --git a/doc/examples/tree2.c b/doc/examples/tree2.c
new file mode 100644
index 0000000..125606e
--- /dev/null
+++ b/doc/examples/tree2.c
@@ -0,0 +1,106 @@
+/*
+ * section: Tree
+ * synopsis: Creates a tree
+ * purpose: Shows how to create document, nodes and dump it to stdout or file.
+ * usage: tree2 <filename> -Default output: stdout
+ * test: tree2 > tree2.tmp ; diff tree2.tmp tree2.out ; rm tree2.tmp
+ * author: Lucas Brasilino <brasilino@recife.pe.gov.br>
+ * copy: see Copyright for the status of this software
+ */
+
+#include <stdio.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+/*
+ *To compile this file using gcc you can type
+ *gcc `xml2-config --cflags --libs` -o tree2 tree2.c
+ */
+
+/* A simple example how to create DOM. Libxml2 automagically
+ * allocates the necessary amount of memory to it.
+*/
+int
+main(int argc, char **argv)
+{
+ xmlDocPtr doc = NULL; /* document pointer */
+ xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */
+ xmlDtdPtr dtd = NULL; /* DTD pointer */
+ char buff[256];
+ int i, j;
+
+ LIBXML_TEST_VERSION;
+
+ /*
+ * Creates a new document, a node and set it as a root node
+ */
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+
+ /*
+ * Creates a DTD declaration. Isn't mandatory.
+ */
+ dtd = xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd");
+
+ /*
+ * xmlNewChild() creates a new node, which is "attached" as child node
+ * of root_node node.
+ */
+ xmlNewChild(root_node, NULL, BAD_CAST "node1",
+ BAD_CAST "content of node 1");
+ /*
+ * The same as above, but the new child node doesn't have a content
+ */
+ xmlNewChild(root_node, NULL, BAD_CAST "node2", NULL);
+
+ /*
+ * xmlNewProp() creates attributes, which is "attached" to an node.
+ * It returns xmlAttrPtr, which isn't used here.
+ */
+ node =
+ xmlNewChild(root_node, NULL, BAD_CAST "node3",
+ BAD_CAST "this node has attributes");
+ xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes");
+ xmlNewProp(node, BAD_CAST "foo", BAD_CAST "bar");
+
+ /*
+ * Here goes another way to create nodes. xmlNewNode() and xmlNewText
+ * creates a node and a text node separately. They are "attached"
+ * by xmlAddChild()
+ */
+ node = xmlNewNode(NULL, BAD_CAST "node4");
+ node1 = xmlNewText(BAD_CAST
+ "other way to create content (which is also a node)");
+ xmlAddChild(node, node1);
+ xmlAddChild(root_node, node);
+
+ /*
+ * A simple loop that "automates" nodes creation
+ */
+ for (i = 5; i < 7; i++) {
+ sprintf(buff, "node%d", i);
+ node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL);
+ for (j = 1; j < 4; j++) {
+ sprintf(buff, "node%d%d", i, j);
+ node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL);
+ xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes"));
+ }
+ }
+
+ /*
+ * Dumping document to stdio or file
+ */
+ xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1);
+
+ /*free the document */
+ xmlFreeDoc(doc);
+
+ /*
+ *Free the global variables that may
+ *have been allocated by the parser.
+ */
+ xmlCleanupParser();
+
+ return(0);
+}
diff --git a/doc/examples/tree2.out b/doc/examples/tree2.out
new file mode 100644
index 0000000..ed00195
--- /dev/null
+++ b/doc/examples/tree2.out
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE root SYSTEM "tree2.dtd">
+<root>
+ <node1>content of node 1</node1>
+ <node2/>
+ <node3 attribute="yes" foo="bar">this node has attributes</node3>
+ <node4>other way to create content (which is also a node)</node4>
+ <node5>
+ <node51 odd="no"/>
+ <node52 odd="yes"/>
+ <node53 odd="no"/>
+ </node5>
+ <node6>
+ <node61 odd="no"/>
+ <node62 odd="yes"/>
+ <node63 odd="no"/>
+ </node6>
+</root>
diff --git a/xinclude.c b/xinclude.c
index f4d6aee..2ceef0f 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1361,7 +1361,7 @@
if (xptrctxt == NULL) {
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_FAILED,
- "could create XPointer context\n", NULL);
+ "could not create XPointer context\n", NULL);
xmlFree(URL);
xmlFree(fragment);
return(-1);