summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-09-02 06:07:36 +0000
committerFred Drake <fdrake@acm.org>2001-09-02 06:07:36 +0000
commitb86677079d95a8296dbc0b5a21311cb68a3c7f40 (patch)
tree8112cb62d2337832723ae886265c717009ebab36
parentcb6d0da04e18c16c8498d35a9c053bbc477c004a (diff)
downloadcpython-git-b86677079d95a8296dbc0b5a21311cb68a3c7f40.tar.gz
Move the long minidom example to a separate file; \verbatiminput does the
right thing with page breaks in long examples, while the verbatim environment does not. This causes the example to wrap to the next page instead of overwriting the page footer and bottom margin.
-rw-r--r--Doc/lib/minidom-example.py65
-rw-r--r--Doc/lib/xmldomminidom.tex68
2 files changed, 66 insertions, 67 deletions
diff --git a/Doc/lib/minidom-example.py b/Doc/lib/minidom-example.py
new file mode 100644
index 0000000000..3745ca1a33
--- /dev/null
+++ b/Doc/lib/minidom-example.py
@@ -0,0 +1,65 @@
+import xml.dom.minidom
+
+document = """\
+<slideshow>
+<title>Demo slideshow</title>
+<slide><title>Slide title</title>
+<point>This is a demo</point>
+<point>Of a program for processing slides</point>
+</slide>
+
+<slide><title>Another demo slide</title>
+<point>It is important</point>
+<point>To have more than</point>
+<point>one slide</point>
+</slide>
+</slideshow>
+"""
+
+dom = xml.dom.minidom.parseString(document)
+
+space = " "
+def getText(nodelist):
+ rc = ""
+ for node in nodelist:
+ if node.nodeType == node.TEXT_NODE:
+ rc = rc + node.data
+ return rc
+
+def handleSlideshow(slideshow):
+ print "<html>"
+ handleSlideshowTitle(slideshow.getElementsByTagName("title")[0])
+ slides = slideshow.getElementsByTagName("slide")
+ handleToc(slides)
+ handleSlides(slides)
+ print "</html>"
+
+def handleSlides(slides):
+ for slide in slides:
+ handleSlide(slide)
+
+def handleSlide(slide):
+ handleSlideTitle(slide.getElementsByTagName("title")[0])
+ handlePoints(slide.getElementsByTagName("point"))
+
+def handleSlideshowTitle(title):
+ print "<title>%s</title>" % getText(title.childNodes)
+
+def handleSlideTitle(title):
+ print "<h2>%s</h2>" % getText(title.childNodes)
+
+def handlePoints(points):
+ print "<ul>"
+ for point in points:
+ handlePoint(point)
+ print "</ul>"
+
+def handlePoint(point):
+ print "<li>%s</li>" % getText(point.childNodes)
+
+def handleToc(slides):
+ for slide in slides:
+ title = slide.getElementsByTagName("title")[0]
+ print "<p>%s</p>" % getText(title.childNodes)
+
+handleSlideshow(dom)
diff --git a/Doc/lib/xmldomminidom.tex b/Doc/lib/xmldomminidom.tex
index 9d4f3b6fff..884e0c5b0f 100644
--- a/Doc/lib/xmldomminidom.tex
+++ b/Doc/lib/xmldomminidom.tex
@@ -143,73 +143,7 @@ This example program is a fairly realistic example of a simple
program. In this particular case, we do not take much advantage
of the flexibility of the DOM.
-\begin{verbatim}
-import xml.dom.minidom
-
-document = """\
-<slideshow>
-<title>Demo slideshow</title>
-<slide><title>Slide title</title>
-<point>This is a demo</point>
-<point>Of a program for processing slides</point>
-</slide>
-
-<slide><title>Another demo slide</title>
-<point>It is important</point>
-<point>To have more than</point>
-<point>one slide</point>
-</slide>
-</slideshow>
-"""
-
-dom = xml.dom.minidom.parseString(document)
-
-space = " "
-def getText(nodelist):
- rc = ""
- for node in nodelist:
- if node.nodeType == node.TEXT_NODE:
- rc = rc + node.data
- return rc
-
-def handleSlideshow(slideshow):
- print "<html>"
- handleSlideshowTitle(slideshow.getElementsByTagName("title")[0])
- slides = slideshow.getElementsByTagName("slide")
- handleToc(slides)
- handleSlides(slides)
- print "</html>"
-
-def handleSlides(slides):
- for slide in slides:
- handleSlide(slide)
-
-def handleSlide(slide):
- handleSlideTitle(slide.getElementsByTagName("title")[0])
- handlePoints(slide.getElementsByTagName("point"))
-
-def handleSlideshowTitle(title):
- print "<title>%s</title>" % getText(title.childNodes)
-
-def handleSlideTitle(title):
- print "<h2>%s</h2>" % getText(title.childNodes)
-
-def handlePoints(points):
- print "<ul>"
- for point in points:
- handlePoint(point)
- print "</ul>"
-
-def handlePoint(point):
- print "<li>%s</li>" % getText(point.childNodes)
-
-def handleToc(slides):
- for slide in slides:
- title = slide.getElementsByTagName("title")[0]
- print "<p>%s</p>" % getText(title.childNodes)
-
-handleSlideshow(dom)
-\end{verbatim}
+\verbatiminput{minidom-example.py}
\subsection{minidom and the DOM standard \label{minidom-and-dom}}