# Path: pyxform/errors.py
# class PyXFormError(Exception):
#     """Common base class for pyxform exceptions."""
# 
#     pass
# 
# Path: pyxform/external_instance.py
# class ExternalInstance(SurveyElement):
#     def xml_control(self):
#         """
#         No-op since there is no associated form control to place under <body/>.
# 
#         Exists here because there's a soft abstractmethod in SurveyElement.
#         """
#         pass
# 
# Path: pyxform/question.py
# class Question(SurveyElement):
# class InputQuestion(Question):
# class TriggerQuestion(Question):
# class UploadQuestion(Question):
# class Option(SurveyElement):
# class MultipleChoiceQuestion(Question):
# class SelectOneQuestion(MultipleChoiceQuestion):
# class Tag(SurveyElement):
# class OsmUploadQuestion(UploadQuestion):
# class RangeQuestion(Question):
#     def validate(self):
#     def xml_instance(self, **kwargs):
#     def xml_control(self):
#     def nest_setvalues(self, xml_node):
#     def build_xml(self):
#     def build_xml(self):
#     def build_xml(self):
#     def _get_media_type(self):
#     def build_xml(self):
#     def xml_value(self):
#     def xml(self):
#     def validate(self):
#     def __init__(self, **kwargs):
#     def add_choice(self, **kwargs):
#     def validate(self):
#     def build_xml(self):
#     def __init__(self, **kwargs):
#     def __init__(self, **kwargs):
#     def xml(self):
#     def validate(self):
#     def __init__(self, **kwargs):
#     def add_tag(self, **kwargs):
#     def build_xml(self):
#     def build_xml(self):
# 
# Path: pyxform/utils.py
# def node(*args, **kwargs):
#     """
#     args[0] -- a XML tag
#     args[1:] -- an array of children to append to the newly created node
#             or if a unicode arg is supplied it will be used to make a text node
#     kwargs -- attributes
#     returns a xml.dom.minidom.Element
#     """
#     blocked_attributes = ["tag"]
#     tag = args[0] if len(args) > 0 else kwargs["tag"]
#     args = args[1:]
#     result = DetachableElement(tag)
#     unicode_args = [u for u in args if type(u) == str]
#     assert len(unicode_args) <= 1
#     parsed_string = False
# 
#     # Convert the kwargs xml attribute dictionary to a xml.dom.minidom.Element. Sort the
#     # attributes to guarantee a consistent order across Python versions.
#     # See pyxform_test_case.reorder_attributes for details.
#     for k, v in iter(sorted(kwargs.items())):
#         if k in blocked_attributes:
#             continue
#         if k == "toParseString":
#             if v is True and len(unicode_args) == 1:
#                 parsed_string = True
#                 # Add this header string so parseString can be used?
#                 s = (
#                     '<?xml version="1.0" ?><'
#                     + tag
#                     + ">"
#                     + unicode_args[0]
#                     + "</"
#                     + tag
#                     + ">"
#                 )
#                 parsed_node = parseString(s.encode("utf-8")).documentElement
#                 # Move node's children to the result Element
#                 # discarding node's root
#                 for child in parsed_node.childNodes:
#                     # No tests seem to involve moving elements with children.
#                     # Deep clone used anyway in case of unknown edge cases.
#                     result.appendChild(child.cloneNode(deep=True))
#         else:
#             result.setAttribute(k, v)
# 
#     if len(unicode_args) == 1 and not parsed_string:
#         text_node = PatchedText()
#         text_node.data = unicode_args[0]
#         result.appendChild(text_node)
#     for n in args:
#         if type(n) == int or type(n) == float or type(n) == bytes:
#             text_node = PatchedText()
#             text_node.data = str(n)
#             result.appendChild(text_node)
#         elif type(n) is not str:
#             result.appendChild(n)
#     return result


from pyxform.errors import PyXFormError
from pyxform.external_instance import ExternalInstance
from pyxform.question import SurveyElement
from pyxform.utils import node
        """
        <group>
        <label>Fav Color</label>
        <repeat nodeset="fav-color">
          <select1 ref=".">
            <label ref="jr:itext('fav')" />
            <item><label ref="jr:itext('red')" /><value>red</value></item>
            <item><label ref="jr:itext('green')" /><value>green</value></item>
            <item><label ref="jr:itext('blue')" /><value>blue</value></item>
          </select1>
        </repeat>
        </group>
        """
        control_dict = self.control.copy()
        survey = self.get_root()
        # Resolve field references in attributes
        for key, value in control_dict.items():
            control_dict[key] = survey.insert_xpaths(value, self)
        repeat_node = node("repeat", nodeset=self.get_xpath(), **control_dict)

        for n in Section.xml_control(self):
            repeat_node.appendChild(n)

        setvalue_nodes = self._get_setvalue_nodes_for_dynamic_defaults()

        for setvalue_node in setvalue_nodes:
            repeat_node.appendChild(setvalue_node)

        label = self.xml_label()
        if label:

# Path: pyxform/errors.py
# class PyXFormError(Exception):
#     """Common base class for pyxform exceptions."""
# 
#     pass
# 
# Path: pyxform/external_instance.py
# class ExternalInstance(SurveyElement):
#     def xml_control(self):
#         """
#         No-op since there is no associated form control to place under <body/>.
# 
#         Exists here because there's a soft abstractmethod in SurveyElement.
#         """
#         pass
# 
# Path: pyxform/question.py
# class Question(SurveyElement):
# class InputQuestion(Question):
# class TriggerQuestion(Question):
# class UploadQuestion(Question):
# class Option(SurveyElement):
# class MultipleChoiceQuestion(Question):
# class SelectOneQuestion(MultipleChoiceQuestion):
# class Tag(SurveyElement):
# class OsmUploadQuestion(UploadQuestion):
# class RangeQuestion(Question):
#     def validate(self):
#     def xml_instance(self, **kwargs):
#     def xml_control(self):
#     def nest_setvalues(self, xml_node):
#     def build_xml(self):
#     def build_xml(self):
#     def build_xml(self):
#     def _get_media_type(self):
#     def build_xml(self):
#     def xml_value(self):
#     def xml(self):
#     def validate(self):
#     def __init__(self, **kwargs):
#     def add_choice(self, **kwargs):
#     def validate(self):
#     def build_xml(self):
#     def __init__(self, **kwargs):
#     def __init__(self, **kwargs):
#     def xml(self):
#     def validate(self):
#     def __init__(self, **kwargs):
#     def add_tag(self, **kwargs):
#     def build_xml(self):
#     def build_xml(self):
# 
# Path: pyxform/utils.py
# def node(*args, **kwargs):
#     """
#     args[0] -- a XML tag
#     args[1:] -- an array of children to append to the newly created node
#             or if a unicode arg is supplied it will be used to make a text node
#     kwargs -- attributes
#     returns a xml.dom.minidom.Element
#     """
#     blocked_attributes = ["tag"]
#     tag = args[0] if len(args) > 0 else kwargs["tag"]
#     args = args[1:]
#     result = DetachableElement(tag)
#     unicode_args = [u for u in args if type(u) == str]
#     assert len(unicode_args) <= 1
#     parsed_string = False
# 
#     # Convert the kwargs xml attribute dictionary to a xml.dom.minidom.Element. Sort the
#     # attributes to guarantee a consistent order across Python versions.
#     # See pyxform_test_case.reorder_attributes for details.
#     for k, v in iter(sorted(kwargs.items())):
#         if k in blocked_attributes:
#             continue
#         if k == "toParseString":
#             if v is True and len(unicode_args) == 1:
#                 parsed_string = True
#                 # Add this header string so parseString can be used?
#                 s = (
#                     '<?xml version="1.0" ?><'
#                     + tag
#                     + ">"
#                     + unicode_args[0]
#                     + "</"
#                     + tag
#                     + ">"
#                 )
#                 parsed_node = parseString(s.encode("utf-8")).documentElement
#                 # Move node's children to the result Element
#                 # discarding node's root
#                 for child in parsed_node.childNodes:
#                     # No tests seem to involve moving elements with children.
#                     # Deep clone used anyway in case of unknown edge cases.
#                     result.appendChild(child.cloneNode(deep=True))
#         else:
#             result.setAttribute(k, v)
# 
#     if len(unicode_args) == 1 and not parsed_string:
#         text_node = PatchedText()
#         text_node.data = unicode_args[0]
#         result.appendChild(text_node)
#     for n in args:
#         if type(n) == int or type(n) == float or type(n) == bytes:
#             text_node = PatchedText()
#             text_node.data = str(n)
#             result.appendChild(text_node)
#         elif type(n) is not str:
#             result.appendChild(n)
#     return result


# Path: pyxform/section.py
from pyxform.errors import PyXFormError
from pyxform.external_instance import ExternalInstance
from pyxform.question import SurveyElement
from pyxform.utils import node

        """
        <group>
        <label>Fav Color</label>
        <repeat nodeset="fav-color">
          <select1 ref=".">
            <label ref="jr:itext('fav')" />
            <item><label ref="jr:itext('red')" /><value>red</value></item>
            <item><label ref="jr:itext('green')" /><value>green</value></item>
            <item><label ref="jr:itext('blue')" /><value>blue</value></item>
          </select1>
        </repeat>
        </group>
        """
        control_dict = self.control.copy()
        survey = self.get_root()
        # Resolve field references in attributes
        for key, value in control_dict.items():
            control_dict[key] = survey.insert_xpaths(value, self)
        repeat_node = node("repeat", nodeset=self.get_xpath(), **control_dict)

        for n in Section.xml_control(self):
            repeat_node.appendChild(n)

        setvalue_nodes = self._get_setvalue_nodes_for_dynamic_defaults()

        for setvalue_node in setvalue_nodes:
            repeat_node.appendChild(setvalue_node)

        label = self.xml_label()
        if label:

            return node("group", self.xml_label(), repeat_node, ref=self.get_xpath())