<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 04/30/15 03:11, Patricio Stegmann
      wrote:<br>
    </div>
    <blockquote cite="mid:55417321.3070508@gmail.com" type="cite">
      <meta content="text/html; charset=windows-1252"
        http-equiv="Content-Type">
      Burak,<br>
      There is the message, but inside is the result which has its own
      name. It is automatically generated with Result suffix, but my ws
      consumer didnt want that. He wanted the name of it's spec on it. I
      added that keyword and slightly changed some spyne lines.<br>
      I had lot of issues using multiple namespaces, in the lxml output
      generation, which I managed to solve using git version, and now it
      seems to work ok.<br>
    </blockquote>
    <br>
    I'm always interested in ways people patch Spyne. If you think it's
    worthy, please let me know.<br>
    <br>
    <blockquote cite="mid:55417321.3070508@gmail.com" type="cite"> I
      have just a simple question. I need to be able to generate
      something like this:<br>
      <br>
      <MyResponse><br>
        <Items><br>
          <ItemList ofType="b"> <br>
            <Item>blabla</Item><br>
            <Item>bleble</Item><br>
            <Item>blibli</Item><br>
          </ItemList><br>
          <ItemList ofType="c"> <br>
            <Item>clacla</Item><br>
            <Item>clecle</Item><br>
            <Item>clicli</Item><br>
          </ItemList><br>
        </Items><br>
      </MyResponse><br>
    </blockquote>
    <br>
    from spyne import *<br>
    from spyne.util.xml import *<br>
    from lxml import etree<br>
    <br>
    <meta http-equiv="content-type" content="text/html;
      charset=windows-1252">
    class ItemList(ComplexModel):<br>
        of_type = XmlAttribute(Unicode(sub_name='ofType'))<br>
        items = Unicode(max_occurs='unbounded', sub_name='Item')<br>
        # 2.12 will support this, which is imo nicer to look at:<br>
        items = Array(Unicode, wrapped=False, sub_name='Item')<br>
    <br>
    class MyResponse(ComplexModel):<br>
        items = Array(ItemList, sub_name="Items")<br>
    <br>
    print etree.tostring(get_object_as_xml(MyResponse(<br>
        items=[<br>
            ItemList(of_type="b", items=[<br>
                "blabla", "bleble", 'blibli',<br>
            ]),<br>
            ItemList(of_type="c", items=[<br>
                "clacla", "clecle", 'clicli',<br>
            ]),<br>
        ]<br>
    )), pretty_print=True)<br>
    <br>
    <br>
    The sub_name additions here are to prevent you from breaking the
    PEP8 rules.<br>
    <br>
    hth,<br>
    <br>
    burak<br>
    <br>
    <br>
  </body>
</html>