[XML-SIG] DTD parser question

Andreas Jung Andreas Jung <lists@andreas-jung.com>
Fri, 31 Jan 2003 19:00:14 +0100

I am currently building an XML editor using Zope. Users will see an
XML document as tree and klick on a node. Based on the node they will
see a toolbox with elements they can insert either as sibling or as child.

I need to decide based on the DTD what elements are allowed to be inserted
/deleted. I checked out the DTD parser of xmlproc and it looks very
promising to work with however I have some problems with the
ElementType interface:

def get_start_state(self):
    Returns the start state of the content model of the element. (No 
guarantees is made as to the type of this value; just think of it as a 
magic cookie instead.)
def final_state(self,state):
    Returns true if the given state (as returned by get_start_state or 
next_state) is a final state, ie: one in which the element is allowed to 
def next_state(self,state,elem_name):
    Returns the next state of the element (again in an unspecified type) 
when the an element with the given name is encountered in the given state. 
Character data is represented as the element name '#PCDATA'. If the element 
is not allowed in this state the value 0 will be returned.

What are these states used for (assuming the DTD is build on a final state
machine)? How can I use them for my projects?

Thanks for any hint,

   -    Andreas Jung                     http://www.andreas-jung.com   -
  -   EMail: andreas at andreas-jung.com                              -
   -            "Life is too short to (re)write parsers"               -