Skip to content

Commit

Permalink
doc(test) fixes in new DTD API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed Apr 6, 2012
1 parent d36fe0f commit 00b9748
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions doc/validation.txt
Expand Up @@ -155,7 +155,7 @@ The DTD information is available as attributes on the DTD object. The method


>>> dtd = etree.DTD(StringIO('<!ELEMENT a EMPTY><!ELEMENT b EMPTY>')) >>> dtd = etree.DTD(StringIO('<!ELEMENT a EMPTY><!ELEMENT b EMPTY>'))
>>> for el in dtd.iterelements(): >>> for el in dtd.iterelements():
... print el.name ... print(el.name)
a a
b b


Expand All @@ -164,7 +164,7 @@ The method ``elements`` returns the element declarations as a list:
.. sourcecode:: pycon .. sourcecode:: pycon


>>> dtd = etree.DTD(StringIO('<!ELEMENT a EMPTY><!ELEMENT b EMPTY>')) >>> dtd = etree.DTD(StringIO('<!ELEMENT a EMPTY><!ELEMENT b EMPTY>'))
>>> print len(dtd.elements()) >>> len(dtd.elements())
2 2


An element declaration object provides the following attributes/methods: An element declaration object provides the following attributes/methods:
Expand Down Expand Up @@ -192,23 +192,25 @@ list of all attributes:
- ``occur``: How often this element (or this combination of elements) may occur: - ``occur``: How often this element (or this combination of elements) may occur:
one of "once", "opt", "mult" or "plus" one of "once", "opt", "mult" or "plus"


- ``left``: The left hand supexpression - ``left``: The left hand subexpression


- ``right``: The right hand supexpression - ``right``: The right hand subexpression


For example the element declaration ``<!ELEMENT a (a|b)+>`` results in the following For example, the element declaration ``<!ELEMENT a (a|b)+>`` results
element content declaration objects: in the following element content declaration objects:


.. sourcecode:: pycon .. sourcecode:: pycon


>>> dtd = etree.DTD(StringIO('<!ELEMENT a (a|b)+>')) >>> dtd = etree.DTD(StringIO('<!ELEMENT a (a|b)+>'))
>>> con = dtd.elements()[0].content >>> content = dtd.elements()[0].content
>>> print con.type, con.occur, con.name >>> content.type, content.occur, content.name
or plus None ('or', 'plus', None)
>>> print con.left.type, con.left.occur, con.left.name
element once a >>> left, right = content.left, content.right
>>> print con.right.type, con.right.occur, con.right.name >>> left.type, left.occur, left.name
element once b ('element', 'once', 'a')
>>> right.type, right.occur, right.name
('element', 'once', 'b')


Attributes declarations have the following attributes/methods: Attributes declarations have the following attributes/methods:


Expand All @@ -232,9 +234,9 @@ Attributes declarations have the following attributes/methods:
Entity declarations are available via the ``iterentities`` and ``entities`` methods: Entity declarations are available via the ``iterentities`` and ``entities`` methods:


>>> dtd = etree.DTD(StringIO('<!ENTITY hurz "&#x40;">')) >>> dtd = etree.DTD(StringIO('<!ENTITY hurz "&#x40;">'))
>>> ent = dtd.entities()[0] >>> entity = dtd.entities()[0]
>>> print ent.name, ent.orig, ent.content >>> entity.name, entity.orig, entity.content
hurz &#x40; @ ('hurz', '&#x40;', '@')




RelaxNG RelaxNG
Expand Down

0 comments on commit 00b9748

Please sign in to comment.