Override IodefElement::xmlSerialize with some exceptions
for this Element and then call the parent serialize after.
@param  SabreWriter $writer
@return void
424690
public function xmlSerialize(\Sabre\Xml\Writer $writer) {

        if ($this->attributes['rating'] != 'numeric') {
            $this->value = '';
        }

        parent::xmlSerialize($writer);
    }
888504
protected function xmlSerializeValue(Xml\Writer $writer)
    {
        $writer->startElement(strtolower($this->getValueType()));
        $value = $this->getJsonValue();
        $writer->writeElement('start', $value[0][0]);

        if ('P' === $value[0][1][0]) {
            $writer->writeElement('duration', $value[0][1]);
        } else {
            $writer->writeElement('end', $value[0][1]);
        }

        $writer->endElement();
    }
861478
protected function xmlSerializeValue(Xml\Writer $writer)
    {
        // Special-casing the GEO property.
        //
        // See:
        // http://tools.ietf.org/html/rfc6321#section-3.4.1.2
        if ('GEO' === $this->name) {
            $value = array_map('floatval', $this->getParts());

            $writer->writeElement('latitude', $value[0]);
            $writer->writeElement('longitude', $value[1]);
        } else {
            parent::xmlSerializeValue($writer);
        }
    }
464919
public final void xmlRequestWriteOn(FormattedWriter writer) throws IOException, NotInMessageStore
    {
        Membership membership = _getMembership();
        if (null == membership)
        {
            throw new NotInMessageStore();
        }
        if (null != membership)
        {
            membership.requestXmlWriteOn(writer);
            writer.flush();
        }
    }
91506
public function writeInnerXml(\XMLWriter $xmlWriter)
    {
        Validate::notNull($xmlWriter, 'xmlWriter');
        $this->writeOptionalAttribute(
            $xmlWriter,
            'term',
            $this->term
        );

        $this->writeOptionalAttribute(
            $xmlWriter,
            'scheme',
            $this->scheme
        );

        $this->writeOptionalAttribute(
            $xmlWriter,
            'label',
            $this->label
        );

        if (!empty($this->undefinedContent)) {
            $xmlWriter->writeRaw($this->undefinedContent);
        }
    }
880025
public function writeXml(\XMLWriter $xmlWriter)
    {
        Validate::notNull($xmlWriter, 'xmlWriter');
        $xmlWriter->startElementNS(
            'atom',
            Resources::ENTRY,
            Resources::ATOM_NAMESPACE
        );
        $this->writeInnerXml($xmlWriter);
        $xmlWriter->endElement();
    }
879582
@SuppressWarnings("unchecked")
	public void addWriter(RecordWriter<SerializationDelegate<T>> writer)
	{
		// avoid using the array-list here to reduce one level of object indirection
		if (this.writers == null) {
			this.writers = new RecordWriter[] {writer};
		}
		else {
			RecordWriter<SerializationDelegate<T>>[] ws = new RecordWriter[this.writers.length + 1];
			System.arraycopy(this.writers, 0, ws, 0, this.writers.length);
			ws[this.writers.length] = writer;
			this.writers = ws;
		}
	}
114436
public function xmlSerialize(Xml\Writer $writer)
    {
        $propertiesByGroup = [];

        foreach ($this->children() as $property) {
            $group = $property->group;

            if (!isset($propertiesByGroup[$group])) {
                $propertiesByGroup[$group] = [];
            }

            $propertiesByGroup[$group][] = $property;
        }

        $writer->startElement(strtolower($this->name));

        foreach ($propertiesByGroup as $group => $properties) {
            if (!empty($group)) {
                $writer->startElement('group');
                $writer->writeAttribute('name', strtolower($group));
            }

            foreach ($properties as $property) {
                switch ($property->name) {
                    case 'VERSION':
                        break;

                    case 'XML':
                        $value = $property->getParts();
                        $fragment = new Xml\Element\XmlFragment($value[0]);
                        $writer->write($fragment);
                        break;

                    default:
                        $property->xmlSerialize($writer);
                        break;
                }
            }

            if (!empty($group)) {
                $writer->endElement();
            }
        }

        $writer->endElement();
    }
128549
def Serialize(self, writer):
        
        super(StorageItem, self).Serialize(writer)
        writer.WriteVarBytes(self.Value)
837927
public function writeXml($xmlWriter)
    {
        $xmlWriter->startElementNS(
            'atom',
            Resources::CATEGORY,
            Resources::ATOM_NAMESPACE
        );

        $this->writeOptionalAttribute(
            $xmlWriter,
            'uri',
            $this->uri
        );

        $this->writeOptionalAttribute(
            $xmlWriter,
            'version',
            $this->version
        );

        $xmlWriter->writeRaw($this->text);
        $xmlWriter->endElement();
    }
1264327
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    if(durablePseudoDestID != null)
    {
      writer.newLine();
      writer.taggedValue("durablePseudoDestID", durablePseudoDestID);
    }
    if(durableSubName != null)
    {
      writer.newLine();
      writer.taggedValue("durableSubName", durableSubName);
    }
  }
753530
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("referencedMsg", msgId);
    writer.newLine();
    writer.taggedValue("AOTicks", tick+","+prevTick);
    writer.newLine();
    writer.taggedValue("gatheredMEUuid", sourceMEUuid);
  }
341951
def Serialize(self, writer):
        
        self.SerializeUnsigned(writer)
        writer.WriteSerializableArray(self.scripts)
1209829
public void write(XMLStreamWriter writer, String xmlElementName) throws XMLStreamException {
      if (isModified()) {
         writer.writeStartElement(xmlElementName);
         write(writer);
         writer.writeEndElement();
      }
   }
361925
public function writeXml(\XMLWriter $xmlWriter)
    {
        $content = null;
        if (!is_null($this->_subscriptionDescription)) {
            $content = new Content();
            $content->setText(
                XmlSerializer::objectSerialize(
                    $this->_subscriptionDescription,
                    'SubscriptionDescription'
                )
            );
        }
        $this->_entry->setContent($content);
        $this->_entry->writeXml($xmlWriter);
    }
1244898
private function doMarshal($mappedObject, WriterHelper $writer)
    {
        $className = get_class($mappedObject);
        $classMetadata = $this->classMetadataFactory->getMetadataFor($className);

        if (!$this->classMetadataFactory->hasMetadataFor($className)) {
            throw MarshallerException::mappingNotFoundForClass($className);
        }

        // PreMarshall Hook
        if ($classMetadata->hasLifecycleCallbacks(Events::preMarshal)) {
            $classMetadata->invokeLifecycleCallbacks(Events::preMarshal, $mappedObject);
        }

        if (isset($this->visited[spl_object_hash($mappedObject)])) {
            return;
        }

        $this->visited[spl_object_hash($mappedObject)] = true;

        $writer->startElement($classMetadata->getXmlName());

        $namespaces = $classMetadata->getXmlNamespaces();
        if (!empty($namespaces)) {
            foreach ($namespaces as $namespace) {
                $writer->writeNamespace($namespace['url'], $namespace['prefix']);
            }
        }

        // build ordered field mappings for this class
        $fieldMappings = $classMetadata->getFieldMappings();
        $orderedMap = array();
        if (!empty($fieldMappings)) {
            foreach ($fieldMappings as $fieldMapping) {
                $orderedMap[$fieldMapping['node']][] = $fieldMapping;
            }
        }

        // do attributes
        if (array_key_exists(ClassMetadata::XML_ATTRIBUTE, $orderedMap)) {
            foreach ($orderedMap[ClassMetadata::XML_ATTRIBUTE] as $fieldMapping) {

                $fieldName = $fieldMapping['fieldName'];
                $fieldValue = $classMetadata->getFieldValue($mappedObject, $fieldName);

                if ($classMetadata->isRequired($fieldName) && $fieldValue === null) {
                    throw MarshallerException::fieldRequired($className, $fieldName);
                }

                if ($fieldValue !== null || $classMetadata->isNullable($fieldName)) {
                    $this->writeAttribute($writer, $classMetadata, $fieldName, $fieldValue);
                }
            }
        }

        // do text
        if (array_key_exists(ClassMetadata::XML_TEXT, $orderedMap)) {
            foreach ($orderedMap[ClassMetadata::XML_TEXT] as $fieldMapping) {

                $fieldName = $fieldMapping['fieldName'];
                $fieldValue = $classMetadata->getFieldValue($mappedObject, $fieldName);

                if ($classMetadata->isRequired($fieldName) && $fieldValue === null) {
                    throw MarshallerException::fieldRequired($className, $fieldName);
                }

                if ($fieldValue !== null || $classMetadata->isNullable($fieldName)) {
                    $this->writeText($writer, $classMetadata, $fieldName, $fieldValue);
                }
            }
        }

        // do elements
        if (array_key_exists(ClassMetadata::XML_ELEMENT, $orderedMap)) {
            foreach ($orderedMap[ClassMetadata::XML_ELEMENT] as $fieldMapping) {

                $fieldName = $fieldMapping['fieldName'];
                $fieldValue = $classMetadata->getFieldValue($mappedObject, $fieldName);

                if ($classMetadata->isRequired($fieldName) && $fieldValue === null) {
                    throw MarshallerException::fieldRequired($className, $fieldName);
                }

                if ($fieldValue !== null || $classMetadata->isNullable($fieldName)) {
                    $this->writeElement($writer, $classMetadata, $fieldName,  $fieldValue);   
                }
            }
        }

        // do value
        if (array_key_exists(ClassMetadata::XML_VALUE, $orderedMap)) {
            foreach ($orderedMap[ClassMetadata::XML_VALUE] as $fieldMapping) {

                $fieldName = $fieldMapping['fieldName'];
                $fieldValue = $classMetadata->getFieldValue($mappedObject, $fieldName);

                if ($classMetadata->isRequired($fieldName) && $fieldValue === null) {
                    throw MarshallerException::fieldRequired($className, $fieldName);
                }

                if ($fieldValue !== null || $classMetadata->isNullable($fieldName)) {
                    $type = $classMetadata->getTypeOfField($fieldName);
                    $writer->writeValue(Type::getType($type)->convertToXmlValue($fieldValue));
                }
            }
        }


        // PostMarshal hook
        if ($classMetadata->hasLifecycleCallbacks(Events::postMarshal)) {
            $classMetadata->invokeLifecycleCallbacks(Events::postMarshal, $mappedObject);
        }

        $writer->endElement();
    }
596324
protected function xmlSerializeValue(Xml\Writer $writer)
    {
        $values = $this->getParts();

        $map = function ($items) use ($values, $writer) {
            foreach ($items as $i => $item) {
                $writer->writeElement(
                    $item,
                    !empty($values[$i]) ? $values[$i] : null
                );
            }
        };

        switch ($this->name) {
            // Special-casing the REQUEST-STATUS property.
            //
            // See:
            // http://tools.ietf.org/html/rfc6321#section-3.4.1.3
            case 'REQUEST-STATUS':
                $writer->writeElement('code', $values[0]);
                $writer->writeElement('description', $values[1]);

                if (isset($values[2])) {
                    $writer->writeElement('data', $values[2]);
                }
                break;

            case 'N':
                $map([
                    'surname',
                    'given',
                    'additional',
                    'prefix',
                    'suffix',
                ]);
                break;

            case 'GENDER':
                $map([
                    'sex',
                    'text',
                ]);
                break;

            case 'ADR':
                $map([
                    'pobox',
                    'ext',
                    'street',
                    'locality',
                    'region',
                    'code',
                    'country',
                ]);
                break;

            case 'CLIENTPIDMAP':
                $map([
                    'sourceid',
                    'uri',
                ]);
                break;

            default:
                parent::xmlSerializeValue($writer);
        }
    }