doc/tutorial/xmltutorial.xml doc/tutorial/includekeyword.c


Sun Dec 15 21:27:30 MST 2002 John Fleck <jfleck@inkstain.net>

	* doc/tutorial/xmltutorial.xml
	* doc/tutorial/includekeyword.c
	* doc/tutorial/includegetattribute.c
	plus generated html and pdf
	Adding fix from Niraj Tolia to tutorial to properly free memory.
diff --git a/ChangeLog b/ChangeLog
index 68e583d..bfba42c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Dec 15 21:27:30 MST 2002 John Fleck <jfleck@inkstain.net>
+
+	* doc/tutorial/xmltutorial.xml
+	* doc/tutorial/includekeyword.c
+	* doc/tutorial/includegetattribute.c
+	plus generated html and pdf
+	Adding fix from Niraj Tolia to tutorial to properly free memory.
+	
+
 Mon Dec 16 00:34:25 CET 2002 Daniel Veillard <daniel@veillard.com>
 
 	* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added
diff --git a/doc/tutorial/apb.html b/doc/tutorial/apb.html
index a9ace0b..19b4ceb 100644
--- a/doc/tutorial/apb.html
+++ b/doc/tutorial/apb.html
@@ -10,11 +10,14 @@
 void
 parseStory (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *key;
 	cur = cur-&gt;xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;keyword&quot;))) {
-		    printf(&quot;keyword: %s\n&quot;, xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1));
-	    }
+		    key = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
+		    printf(&quot;keyword: %s\n&quot;, key);
+		    xmlFree(key);
+ 	    }
 	cur = cur-&gt;next;
 	}
     return;
@@ -30,7 +33,6 @@
 	
 	if (doc == NULL ) {
 		fprintf(stderr,&quot;Document not parsed successfully. \n&quot;);
-		xmlFreeDoc(doc);
 		return;
 	}
 	
diff --git a/doc/tutorial/ape.html b/doc/tutorial/ape.html
index f473044..9dc363c 100644
--- a/doc/tutorial/ape.html
+++ b/doc/tutorial/ape.html
@@ -10,14 +10,17 @@
 void
 getReference (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *uri;
 	cur = cur-&gt;xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) {
-		    printf(&quot;uri: %s\n&quot;, xmlGetProp(cur, &quot;uri&quot;));
-		    }
+		    uri = xmlGetProp(cur, &quot;uri&quot;);
+		    printf(&quot;uri: %s\n&quot;, uri);
+		    xmlFree(uri);
+	    }
 	    cur = cur-&gt;next;
 	}
-    return;
+	return;
 }
 
 
diff --git a/doc/tutorial/apg.html b/doc/tutorial/apg.html
index bdef971..3bd6e7a 100644
--- a/doc/tutorial/apg.html
+++ b/doc/tutorial/apg.html
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>G. Acknowledgements</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="up" href="index.html" title="Libxml Tutorial"><link rel="previous" href="apf.html" title="F. Code for Encoding Conversion Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">G. Acknowledgements</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apf.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2802385"></a>G. Acknowledgements</h2></div></div><p>A number of people have generously offered feedback, code and
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>G. Acknowledgements</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="up" href="index.html" title="Libxml Tutorial"><link rel="previous" href="apf.html" title="F. Code for Encoding Conversion Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">G. Acknowledgements</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apf.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2871832"></a>G. Acknowledgements</h2></div></div><p>A number of people have generously offered feedback, code and
     suggested improvements to this tutorial. In no particular order:
-      </p><table class="simplelist" border="0" summary="Simple list"><tr><td>Daniel Veillard</td></tr><tr><td>Marcus Labib Iskander</td></tr><tr><td>Christopher R. Harris</td></tr><tr><td>Igor Zlatkovic</td></tr></table><p>
+      </p><table class="simplelist" border="0" summary="Simple list"><tr><td>Daniel Veillard</td></tr><tr><td>Marcus Labib Iskander</td></tr><tr><td>Christopher R. Harris</td></tr><tr><td>Igor Zlatkovic</td></tr><tr><td>Niraj Tolia</td></tr></table><p>
     </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apf.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top">F. Code for Encoding Conversion Example </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
diff --git a/doc/tutorial/ar01s03.html b/doc/tutorial/ar01s03.html
index eead7a8..a90e317 100644
--- a/doc/tutorial/ar01s03.html
+++ b/doc/tutorial/ar01s03.html
@@ -32,14 +32,14 @@
 	  interact with individual nodes).</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkparseerror"><img src="images/callouts/4.png" alt="4" border="0"></a> </td><td valign="top" align="left"><p>Check to see that the document was successfully parsed. If it
 	    was not, libxml will at this point
 	    register an error and stop. 
-	    </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th>Note</th></tr><tr><td colspan="2" align="left" valign="top"><p>One common example of an error at this point is improper
+	    </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>One common example of an error at this point is improper
 	    handling of encoding. The XML standard requires
 	    documents stored with an encoding other than UTF-8 or UTF-16 to
 	    contain an explicit declaration of their encoding. If the
 	    declaration is there, libxml will
 	    automatically perform the necessary conversion to UTF-8 for
 		you. More information on XML's encoding
-		requirements is contained in the <a href="http://www.w3.org/TR/REC-xml#charencoding" target="_top">standard</a>.</p></td></tr></table></div><p>
+		requirements is contained in the <a href="http://www.w3.org/TR/REC-xml#charencoding" target="_top">standard</a>.</p></div><p>
 	  </p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#getrootelement"><img src="images/callouts/5.png" alt="5" border="0"></a> </td><td valign="top" align="left"><p>Retrieve the document's root element.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkemptyerror"><img src="images/callouts/6.png" alt="6" border="0"></a> </td><td valign="top" align="left"><p>Check to make sure the document actually contains something.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkroottype"><img src="images/callouts/7.png" alt="7" border="0"></a> </td><td valign="top" align="left"><p>In our case, we need to make sure the document is the right
 	  type. &quot;story&quot; is the root type of the documents used in this
 	  tutorial.</p></td></tr></table></div><p>
diff --git a/doc/tutorial/ar01s07.html b/doc/tutorial/ar01s07.html
index 9335237..fe0bd7c 100644
--- a/doc/tutorial/ar01s07.html
+++ b/doc/tutorial/ar01s07.html
@@ -11,14 +11,17 @@
 void
 getReference (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *uri;
 	cur = cur-&gt;xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) {
-	<a name="getattributevalue"></a><img src="images/callouts/1.png" alt="1" border="0"> printf(&quot;uri: %s\n&quot;, xmlGetProp(cur, &quot;uri&quot;));
-		    }
+		   <a name="getattributevalue"></a><img src="images/callouts/1.png" alt="1" border="0"> uri = xmlGetProp(cur, &quot;uri&quot;);
+		    printf(&quot;uri: %s\n&quot;, uri);
+		    xmlFree(uri);
+	    }
 	    cur = cur-&gt;next;
 	}
-    return;
+	return;
 }
       </pre><p>
     
@@ -26,10 +29,10 @@
 	    The key function is <tt><a href="http://xmlsoft.org/html/libxml-tree.html#XMLGETPROP" target="_top">xmlGetProp</a></tt>, which returns an
       <tt>xmlChar</tt> containing the attribute's value. In this case,
 					   we just print it out.
-      </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th>Note</th></tr><tr><td colspan="2" align="left" valign="top"><p>
+      </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 	  If you are using a DTD that declares a fixed or
 	  default value for the attribute, this function will retrieve it.
-	</p></td></tr></table></div><p>
+	</p></div><p>
 	  </p></td></tr></table></div><p>
      
     </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ar01s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Writing Attribute </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Encoding Conversion</td></tr></table></div></body></html>
diff --git a/doc/tutorial/ar01s08.html b/doc/tutorial/ar01s08.html
index 509c8d5..70bb165 100644
--- a/doc/tutorial/ar01s08.html
+++ b/doc/tutorial/ar01s08.html
@@ -18,14 +18,14 @@
     different character formats with ability to convert from any to any. While
     the actual number of supported formats varies between implementations, every
     iconv implementation is almost guaranteed to
-    support every format anyone has ever heard of.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th>Warning</th></tr><tr><td colspan="2" align="left" valign="top"><p>A common mistake is to use different formats for the internal data
+    support every format anyone has ever heard of.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>A common mistake is to use different formats for the internal data
 	in different parts of one's code. The most common case is an application
 	that assumes ISO-8859-1 to be the internal data format, combined with
 	libxml, which assumes UTF-8 to be the
 	internal data format. The result is an application that treats internal
 	data differently, depending on which code section is executing. The one or
 	the other part of code will then, naturally, misinterpret the data.
-      </p></td></tr></table></div><p>This example constructs a simple document, then adds content provided
+      </p></div><p>This example constructs a simple document, then adds content provided
     at the command line to the document's root element and outputs the results
     to <tt>stdout</tt> in the proper encoding. For this example, we
     use ISO-8859-1 encoding. The encoding of the string input at the command
diff --git a/doc/tutorial/includegetattribute.c b/doc/tutorial/includegetattribute.c
index 17f5a2f..b2b7471 100644
--- a/doc/tutorial/includegetattribute.c
+++ b/doc/tutorial/includegetattribute.c
@@ -8,14 +8,17 @@
 void
 getReference (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *uri;
 	cur = cur->xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
-		    printf("uri: %s\n", xmlGetProp(cur, "uri"));
-		    }
+		    uri = xmlGetProp(cur, "uri");
+		    printf("uri: %s\n", uri);
+		    xmlFree(uri);
+	    }
 	    cur = cur->next;
 	}
-    return;
+	return;
 }
 
 
diff --git a/doc/tutorial/includekeyword.c b/doc/tutorial/includekeyword.c
index d62d0a5..e9bb467 100644
--- a/doc/tutorial/includekeyword.c
+++ b/doc/tutorial/includekeyword.c
@@ -8,11 +8,14 @@
 void
 parseStory (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *key;
 	cur = cur->xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
-		    printf("keyword: %s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
-	    }
+		    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+		    printf("keyword: %s\n", key);
+		    xmlFree(key);
+ 	    }
 	cur = cur->next;
 	}
     return;
@@ -28,7 +31,6 @@
 	
 	if (doc == NULL ) {
 		fprintf(stderr,"Document not parsed successfully. \n");
-		xmlFreeDoc(doc);
 		return;
 	}
 	
diff --git a/doc/tutorial/index.html b/doc/tutorial/index.html
index 4ce60be..03e8588 100644
--- a/doc/tutorial/index.html
+++ b/doc/tutorial/index.html
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Libxml Tutorial</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="next" href="ar01s02.html" title="Data Types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Libxml Tutorial</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s02.html">Next</a></td></tr></table><hr></div><div class="article" lang="en"><div class="titlepage"><div><h1 class="title"><a name="id2800880"></a>Libxml Tutorial</h1></div><div><div class="author"><h3 class="author">John Fleck</h3></div></div><div><p class="copyright">Copyright © 2002 John Fleck</p></div><div><div class="revhistory"><table border="1" width="100%" summary="Revision history"><tr><th align="left" valign="top" colspan="2"><b>Revision History</b></th></tr><tr><td align="left">Revision 1</td><td align="left">June 4,2002</td></tr><tr><td align="left">Revision 2</td><td align="left">June 12, 2002</td></tr><tr><td align="left">Revision 3</td><td align="left">Aug. 31, 2002</td></tr><tr><td align="left">Revision 4</td><td align="left">Nov. 10, 2002</td></tr></table></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="index.html#introduction">Introduction</a></dt><dt><a href="ar01s02.html">Data Types</a></dt><dt><a href="ar01s03.html">Parsing the file</a></dt><dt><a href="ar01s04.html">Retrieving Element Content</a></dt><dt><a href="ar01s05.html">Writing element content</a></dt><dt><a href="ar01s06.html">Writing Attribute</a></dt><dt><a href="ar01s07.html">Retrieving Attributes</a></dt><dt><a href="ar01s08.html">Encoding Conversion</a></dt><dt>A. <a href="apa.html">Sample Document</a></dt><dt>B. <a href="apb.html">Code for Keyword Example</a></dt><dt>C. <a href="apc.html">Code for Add Keyword Example</a></dt><dt>D. <a href="apd.html">Code for Add Attribute Example</a></dt><dt>E. <a href="ape.html">Code for Retrieving Attribute Value Example</a></dt><dt>F. <a href="apf.html">Code for Encoding Conversion Example</a></dt><dt>G. <a href="apg.html">Acknowledgements</a></dt></dl></div><div class="abstract"><p class="title"><b>Abstract</b></p><p>Libxml is a freely licensed C language library for handling
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Libxml Tutorial</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="next" href="ar01s02.html" title="Data Types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Libxml Tutorial</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s02.html">Next</a></td></tr></table><hr></div><div class="article" lang="en"><div class="titlepage"><div><h1 class="title"><a name="id2803514"></a>Libxml Tutorial</h1></div><div><div class="author"><h3 class="author">John Fleck</h3></div></div><div><p class="copyright">Copyright © 2002 John Fleck</p></div><div><div class="revhistory"><table border="1" width="100%" summary="Revision history"><tr><th align="left" valign="top" colspan="2"><b>Revision History</b></th></tr><tr><td align="left">Revision 1</td><td align="left">June 4, 2002</td></tr><tr><td align="left">Revision 2</td><td align="left">June 12, 2002</td></tr><tr><td align="left">Revision 3</td><td align="left">Aug. 31, 2002</td></tr><tr><td align="left">Revision 4</td><td align="left">Nov. 10, 2002</td></tr><tr><td align="left">Revision 5</td><td align="left">Dec. 15, 2002</td></tr></table></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="index.html#introduction">Introduction</a></dt><dt><a href="ar01s02.html">Data Types</a></dt><dt><a href="ar01s03.html">Parsing the file</a></dt><dt><a href="ar01s04.html">Retrieving Element Content</a></dt><dt><a href="ar01s05.html">Writing element content</a></dt><dt><a href="ar01s06.html">Writing Attribute</a></dt><dt><a href="ar01s07.html">Retrieving Attributes</a></dt><dt><a href="ar01s08.html">Encoding Conversion</a></dt><dt>A. <a href="apa.html">Sample Document</a></dt><dt>B. <a href="apb.html">Code for Keyword Example</a></dt><dt>C. <a href="apc.html">Code for Add Keyword Example</a></dt><dt>D. <a href="apd.html">Code for Add Attribute Example</a></dt><dt>E. <a href="ape.html">Code for Retrieving Attribute Value Example</a></dt><dt>F. <a href="apf.html">Code for Encoding Conversion Example</a></dt><dt>G. <a href="apg.html">Acknowledgements</a></dt></dl></div><div class="abstract"><p class="title"><b>Abstract</b></p><p>Libxml is a freely licensed C language library for handling
     XML, portable across a large number of platforms. This
     tutorial provides examples of its basic functions.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="introduction"></a>Introduction</h2></div></div><p>Libxml is a C language library implementing functions for reading,
       creating and manipulating XML data. This tutorial
diff --git a/doc/tutorial/xmltutorial.pdf b/doc/tutorial/xmltutorial.pdf
index 31c293a..5a1a0f7 100644
--- a/doc/tutorial/xmltutorial.pdf
+++ b/doc/tutorial/xmltutorial.pdf
Binary files differ
diff --git a/doc/tutorial/xmltutorial.xml b/doc/tutorial/xmltutorial.xml
index 7469ed5..14dc2ca 100644
--- a/doc/tutorial/xmltutorial.xml
+++ b/doc/tutorial/xmltutorial.xml
@@ -37,6 +37,10 @@
 	<revnumber>4</revnumber>
 	<date>Nov. 10, 2002</date>
       </revision>
+      <revision>
+	<revnumber>5</revnumber>
+	<date>Dec. 15, 2002</date>
+      </revision>
     </revhistory>
   </articleinfo>
   <abstract>
@@ -381,14 +385,17 @@
 void
 getReference (xmlDocPtr doc, xmlNodePtr cur) {
 
+	xmlChar *uri;
 	cur = cur->xmlChildrenNode;
 	while (cur != NULL) {
 	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
-	<co id="getattributevalue" /> printf("uri: %s\n", xmlGetProp(cur, "uri"));
-		    }
+		   <co id="getattributevalue" /> uri = xmlGetProp(cur, "uri");
+		    printf("uri: %s\n", uri);
+		    xmlFree(uri);
+	    }
 	    cur = cur->next;
 	}
-    return;
+	return;
 }
       </programlisting>
     
@@ -555,6 +562,7 @@
 	<member>Marcus Labib Iskander</member>
 	<member>Christopher R. Harris</member>
 	<member>Igor Zlatkovic</member>
+	<member>Niraj Tolia</member>
       </simplelist>
     </para>
   </appendix>