Get a serialized XML representation of a particular table.
490224
public VoltXMLElement getXMLForTable(String tableName) throws HSQLParseException {
        VoltXMLElement xml = emptySchema.duplicate();

        // search all the tables XXX probably could do this non-linearly,
        //  but i don't know about case-insensitivity yet
        HashMappedList hsqlTables = getHSQLTables();
        for (int i = 0; i < hsqlTables.size(); i++) {
            Table table = (Table) hsqlTables.get(i);
            String candidateTableName = table.getName().name;

            // found the table of interest
            if (candidateTableName.equalsIgnoreCase(tableName)) {
                VoltXMLElement vxmle = table.voltGetTableXML(sessionProxy);
                assert(vxmle != null);
                xml.children.add(vxmle);
                return xml;
            }
        }
        return null;
    }
220267
def _serialized(self):
        """"""
        return {'title': self.title,
                'summary': self.summary,
                'areadesc': self.areadesc,
                'event': self.event,
                'samecodes': self.samecodes,
                'zonecodes': self.zonecodes,
                'expiration': self.expiration,
                'updated': self.updated,
                'effective': self.effective,
                'published': self.published,
                'severity': self.severity,
                'category': self.category,
                'urgency': self.urgency,
                'msgtype': self.msgtype,
                'link': self.link,
                }
249202
def xml(self, indent = ""):
        """"""
        xml = indent + "<" + self.__class__.__name__
        xml += ' id="'+self.id + '"'
        xml += ' name="'+xmlescape(self.name) + '"'
        xml += ' description="'+xmlescape(self.description) + '"'
        if self.paramflag:
            xml += ' flag="'+self.paramflag + '"'
        if self.multi:
            xml += ' multi="true"'
        for key, value in self.kwargs.items():
            if key != 'choices' and key != 'default' and key != 'flag' and key != 'paramflag':
                if isinstance(value, bool):
                    xml += ' ' + key + '="' + str(int(value))+ '"'
                elif isinstance(value, list):
                    xml += ' ' + key + '="'+",".join(value)+ '"'
                else:
                    xml += ' ' + key + '="'+xmlescape(value)+ '"'
        if self.error:
            xml += ' error="'+self.error + '"'
        xml += ">"
        for key, value in self.choices:
            if self.value == key or (isinstance(self.value ,list) and key in self.value):
                xml += " <choice id=\""+key+"\" selected=\"1\">" + xmlescape(value) + "</choice>"
            else:
                xml += " <choice id=\""+key+"\">" + xmlescape(value) + "</choice>"
        xml += "</" + self.__class__.__name__ + ">"
        return xml
568149
def serialize(self):
        """"""
        res = '<?xml version="1.0" encoding="UTF-8"?>'
        for ns in self.namespaces:
            self.top_grammar.attr["xmlns:" + self.namespaces[ns]] = ns
        res += self.top_grammar.start_tag()
        for ch in self.top_grammar.children:
            res += ch.serialize()
        res += self.tree.serialize()
        for d in self.global_defs:
            res += self.global_defs[d].serialize()
        for i in self.identities:
            res += self.identities[i].serialize()
        return res + self.top_grammar.end_tag()
1297983
def get_xml_type(val):
    """"""
    if type(val).__name__ in ('str', 'unicode'):
        return 'str'
    if type(val).__name__ in ('int', 'long'):
        return 'int'
    if type(val).__name__ == 'float':
        return 'float'
    if type(val).__name__ == 'bool':
        return 'bool'
    if isinstance(val, numbers.Number):
        return 'number'
    if type(val).__name__ == 'NoneType':
        return 'null'
    if isinstance(val, dict):
        return 'dict'
    if isinstance(val, collections.Iterable):
        return 'list'
    return type(val).__name__
815980
def to_element(self, root_name=None):
        """"""
        if not root_name:
            root_name = self.nodename
        elem = ElementTreeBuilder.Element(root_name)
        for attrname in self.serializable_attributes():
            # Only use values that have been loaded into the internal
            # __dict__. For retrieved objects we look into the XML response at
            # access time, so the internal __dict__ contains only the elements
            # that have been set on the client side.
            try:
                value = self.__dict__[attrname]
            except KeyError:
                continue

            if attrname in self.xml_attribute_attributes:
                elem.attrib[attrname] = six.text_type(value)
            else:
                sub_elem = self.element_for_value(attrname, value)
                elem.append(sub_elem)

        return elem
621464
def to_xml_string(r_index, str = '')
      serialized_tag('row', str, :r => r_index + 1) do
        tmp = '' # time / memory tradeoff, lots of calls to rubyzip costs more
                 # time..
        each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, tmp) }
        str << tmp
      end
    end
4379
def get_xml(self, pretty=True):
        
        return etree.tostring(self.root, encoding="utf-8", pretty_print=pretty)
480395
def dumps(self):
        """"""
        return {table_name: getattr(self, table_name).dumps() for table_name in self.TABLES}
811179
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<table xmlns="' << XML_NS << '" id="' << (index+1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/,'_') << '" ')
      str << ('ref="' << @ref << '" totalsRowShown="0">')
      str << ('<autoFilter ref="' << @ref << '"/>')
      str << ('<tableColumns count="' << header_cells.length.to_s << '">')
      header_cells.each_with_index do |cell,index|
        str << ('<tableColumn id ="' << (index+1).to_s << '" name="' << cell.value << '"/>')
      end
      str << '</tableColumns>'
      table_style_info.to_xml_string(str)
      str << '</table>'
    end
1346287
public String toXML()
    {
        RepositoryTags tags = RepositoryTags.getInstance();
        String eol = SystemUtils.LINE_SEPARATOR;

        //opening tag + attributes
        StringBuffer result = new StringBuffer( 1024 );
        result.append( "      " );
        result.append( tags.getOpeningTagNonClosingById( FIELD_DESCRIPTOR ) );
        result.append( " " );
        result.append( eol );

        //        // id
        //        String id = new Integer(getColNo()).toString();
        //        result += /*"        " +*/ tags.getAttribute(ID, id) + eol;

        // name
        result.append( "        " );
        result.append( tags.getAttribute( FIELD_NAME, this.getAttributeName() ) );
        result.append( eol );

        // table not yet implemented

        // column
        result.append( "        " );
        result.append( tags.getAttribute( COLUMN_NAME, this.getColumnName() ) );
        result.append( eol );

        // jdbc-type
        result.append( "        " );
        result.append( tags.getAttribute( JDBC_TYPE, this.getColumnType() ) );
        result.append( eol );

        // primarykey
        if( this.isPrimaryKey() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( PRIMARY_KEY, "true" ) );
            result.append( eol );
        }

        // nullable
        if( this.isRequired() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( NULLABLE, "false" ) );
            result.append( eol );
        }

        // indexed not yet implemented

        // autoincrement
        if( this.isAutoIncrement() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( AUTO_INCREMENT, "true" ) );
            result.append( eol );
        }

        // locking
        if( this.isLocking() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( LOCKING, "true" ) );
            result.append( eol );
        }

        // updateLock
        // default is true so only write if false
        if( !this.isUpdateLock() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( UPDATE_LOCK, "false" ) );
            result.append( eol );
        }

        // default-fetch not yet implemented

        // conversion
        if( this.getFieldConversion().getClass() != FieldConversionDefaultImpl.class )
        {
            result.append( "        " );
            result.append( tags.getAttribute( FIELD_CONVERSION, getFieldConversion().getClass().getName() ) );
            result.append( eol );
        }

        // length
        if( this.isLengthSpecified() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( LENGTH, "" + getLength() ) );
            result.append( eol );
        }

        // precision
        if( this.isPrecisionSpecified() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( PRECISION, "" + getPrecision() ) );
            result.append( eol );
        }

        // scale
        if( this.isScaleSpecified() )
        {
            result.append( "        " );
            result.append( tags.getAttribute( SCALE, "" + getScale() ) );
            result.append( eol );
        }

        // access
        result.append( "        " );
        result.append( tags.getAttribute( ACCESS, this.getAccess() ) );
        result.append( eol );

        result.append( "      />" );
        result.append( eol );
        return result.toString();
    }
505534
def to_xml(self):
        """"""
        element = etree.Element(self._tag_name)
        struct_to_xml(element, [
            {"text": self.raw_content},
            {"guid": self.guid},
            {"author": self.handle},
            {"public": "true" if self.public else "false"},
            {"created_at": format_dt(self.created_at)},
            {"provider_display_name": self.provider_display_name},
        ])
        return element
881234
def serialize(self):
        """"""
        data = {
            'type': self.__class__.__name__,
            'caption': self.caption.serialize(),
            'headings': [[cell.serialize() for cell in hrow] for hrow in self.headings],
            'rows': [[cell.serialize() for cell in row] for row in self.rows],
        }
        return data
849140
def serialize_for_reading(element):
    
    xml = etree.tostring(element, encoding='unicode', pretty_print=True)
    return XmlString(xml)
1113681
def parsetuple(self,xmltuple):
    
    # first extract all the table and columns from the tuple from the
    # children of the ligo lightweight parent tuple
    table = {}
    tupleidx = 0
    for tag in xmltuple[2]:
      if tag[0] == 'Table' or tag[0] == 'table':
        tab = tag[1]['Name'].encode('ascii').lower()
        try:
          tab = self.tabrx.match(tab).group(2)
        except AttributeError:
          raise LIGOLwParseError, 'unable to parse a valid table name '+tab
        # initalize the table dictionary for this table
        table[tab] = { 
          'pos' : tupleidx,
          'column' : {},
          'stream' : (), 
          'query' : ''
          }
        # parse for columns in the tables children
        # look for the column name and type in the attributes
        # store the index in which the columns were found as
        # we need this to decode the stream later
        for subtag in tag[2]:
          if subtag[0] == 'Column' or subtag[0] == 'column':
            col = subtag[1]['Name'].encode('ascii').lower()
            try:
              col = self.colrx.match(col).group(3)
            except AttributeError:
              raise LIGOLwParseError, 'unable to parse a valid column name '+col
            try:
              typ = subtag[1]['Type'].encode('ascii').lower()
            except KeyError:
              raise LIGOLwParseError, 'type is missing for column '+col
            table[tab]['column'][col] = typ
            table[tab].setdefault('orderedcol',[]).append(col)
      tupleidx += 1

    # now iterate the dictionary of tables we have created looking for streams
    for tab in table.keys():
      for tag in xmltuple[2][table[tab]['pos']][2]:
        if tag[0] == 'Stream' or tag[0] == 'stream':
          # store the stream delimiter and create the esacpe regex
          try:
            delim = tag[1]['Delimiter'].encode('ascii')
          except KeyError:
            raise LIGOLwParseError, 'stream is missing delimiter'
          if delim != ',':
            raise LIGOLwParseError, 'unable to handle stream delimiter: '+delim

          # If the result set is empty tag[2] is an empty array, which causes
          # the next step to fail.  Add an empty string in this case.
          if len(tag[2]) == 0:
            tag[2].append("")


          # strip newlines from the stream and parse it
          stream = csv.reader([re.sub(r'\n','',tag[2][0])],LIGOLWStream).next()

          # turn the csv stream into a list of lists
          slen = len(stream)
          ntyp = len(table[tab]['column'])
          mlen, lft = divmod(slen,ntyp)
          if lft != 0:
            raise LIGOLwParseError, 'invalid stream length for given columns'
          lst = [[None] * ntyp for i in range(mlen)]

          # translate the stream data to the correct data types
          for i in range(slen):
            j, k = divmod(i,ntyp)
            try:
              thiscol = table[tab]['orderedcol'][k]
              if len( stream[i] ) == 0:
                lst[j][k] = None
              else:
                lst[j][k] = self.types[table[tab]['column'][thiscol]](stream[i])
            except (KeyError, ValueError), errmsg:
              msg = "stream translation error (%s) " % str(errmsg)
              msg += "for column %s in table %s: %s -> %s" \
                % (tab,thiscol,stream[i],str(table[tab])) 
              raise LIGOLwParseError, msg
          table[tab]['stream'] = map(tuple,lst)

    # return the created table to the caller
    return table
1280592
def serialize_table(ctx, document, table, root):
    

    # What we should check really is why do we pass None as root element
    # There is a good chance some content is missing after the import

    if root is None:
        return root

    if ctx.ilvl != None:
        root = close_list(ctx, root)
        ctx.ilvl, ctx.numid = None, None

    _table = etree.SubElement(root, 'table')
    _table.set('border', '1')
    _table.set('width', '100%')

    style = get_style(document, table)

    if style:
        _table.set('class', get_css_classes(document, style))

    for rows in table.rows:
        _tr = etree.SubElement(_table, 'tr')

        for cell in rows:
            _td = etree.SubElement(_tr, 'td')

            if cell.grid_span != 1:
                _td.set('colspan', str(cell.grid_span))

            if cell.row_span != 1:
                _td.set('rowspan', str(cell.row_span))

            for elem in cell.elements:
                if isinstance(elem, doc.Paragraph):
                    _ser = ctx.get_serializer(elem)
                    _td = _ser(ctx, document, elem, _td, embed=False)

            if ctx.ilvl != None:
#                root = close_list(ctx, root)
                _td = close_list(ctx, _td)

                ctx.ilvl, ctx.numid = None, None

            fire_hooks(ctx, document, table, _td, ctx.get_hook('td'))
        fire_hooks(ctx, document, table, _td, ctx.get_hook('tr'))

    fire_hooks(ctx, document, table, _table, ctx.get_hook('table'))

    return root
813405
def _get_rows(self, table):
        """"""

        childnodes = table.childNodes
        qname_childnodes = [(s.qname[1], s) for s in childnodes]
        return [node for name, node in qname_childnodes
                if name == u'table-row']