add a relation mapping an element to its direct parent (occurence)

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset22e82a22addf
branchdefault
phasepublic
hiddenno
parent revision#bcbaa0def9f2 Add a pretty print visitor.
child revision#5962c4836b80 NotImplemented is not an exception
files modified by this revision
pyxst/xml_struct/graph_nodes.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1461943630 -7200
# Fri Apr 29 17:27:10 2016 +0200
# Node ID 22e82a22addf6869e31975466f19c48ff322e5d9
# Parent bcbaa0def9f2c1b7f9954c6224c86354ca0ebc2d
add a relation mapping an element to its direct parent (occurence)

diff --git a/pyxst/xml_struct/graph_nodes.py b/pyxst/xml_struct/graph_nodes.py
@@ -127,10 +127,12 @@
1 
2         Type: :class:`set` of :class:`unicode`
3 
4      .. automethod:: __init__
5      """
6 +    parent = None
7 +
8      def __init__(self, qname):
9          """
10          Initializes a new XML node.
11 
12          :param qname:
@@ -211,10 +213,11 @@
13         Type: :class:`int` or
14         :data:`~pyxst.xml_struct.utils.INFINITY`
15 
16      .. automethod:: __init__
17      """
18 +
19      def __init__(self, target, min_occur, max_occur):
20          """
21          Initializes a new occurence.
22 
23          :param target:
@@ -231,10 +234,11 @@
24          :type max_occur:
25              :class:`int` or
26              :data:`~pyxst.xml_struct.utils.INFINITY`
27          """
28          self.target = target
29 +        target.parent = self
30          self.minimum = min_occur
31          self.maximum = max_occur
32 
33      @property
34      def qname(self):