public static function WriteTypedXmlValue(
      \XMLWriter $w, $value, string $name, bool $short = true, bool $separateElements = false)
   {

      if ( ! ( $value instanceof Type ) )
      {
         $value = new Type( $value );
      }

      $v = null;
      $t = null;

      switch ( $value->getType() )
      {

         case Type::PHP_ARRAY:
            $v = \serialize( $value->getValue() );
            $t = Type::PHP_ARRAY;
            break;

         case Type::PHP_BOOLEAN:
            $v = $value->getValue() ? 'true' : 'false';
            $t = Type::PHP_BOOLEAN;
            break;

         case Type::PHP_DOUBLE:
         case Type::PHP_FLOAT:
         case Type::PHP_INTEGER:
            $v = $value->getValue();
            $t = $value->getType();
            break;

         case Type::PHP_NULL:
            $v = '';
            $t = Type::PHP_NULL;
            break;

         case Type::PHP_RESOURCE:
             # Ignore some resources
            break;

         case Type::PHP_STRING:
            $v = $value->getValue();
            $t = Type::PHP_STRING;
            break;

         case Type::PHP_UNKNOWN:
            $v = $value->getStringValue();
            $t = Type::PHP_STRING;
            break;

         default:
            $v = \serialize( $value->getValue() );
            $t = $value->getType();
            break;

      }

      if ( ! \is_null( $t ) && ! \is_null( $v ) )
      {

         $w->startElement( $name );

         if ( $short )
         {
            $w->writeAttribute( 'type', $t );
            $w->writeAttribute( 'value', $v );
         }
         else
         {
            if ( $separateElements )
            {
               $w->writeElement( 'type',  $t );
               $w->writeElement( 'value', $v );
            }
            else
            {
               $w->writeAttribute( 'type', $t );
               $w->text( $v );
            }
         }

         $w->endElement();

      }

   }
public static function WriteTypedXmlValue(
      \XMLWriter $w, $value, string $name, bool $short = true, bool $separateElements = false)
   {

      if ( ! ( $value instanceof Type ) )
      {
         $value = new Type( $value );
      }

      $v = null;
      $t = null;

      switch ( $value->getType() )
      {

         case Type::PHP_ARRAY:
            $v = \serialize( $value->getValue() );
            $t = Type::PHP_ARRAY;
            break;

         case Type::PHP_BOOLEAN:
            $v = $value->getValue() ? 'true' : 'false';
            $t = Type::PHP_BOOLEAN;
            break;

         case Type::PHP_DOUBLE:
         case Type::PHP_FLOAT:
         case Type::PHP_INTEGER:
            $v = $value->getValue();
            $t = $value->getType();
            break;

         case Type::PHP_NULL:
            $v = '';
            $t = Type::PHP_NULL;
            break;

         case Type::PHP_RESOURCE:
             # Ignore some resources
            break;

         case Type::PHP_STRING:
            $v = $value->getValue();
            $t = Type::PHP_STRING;
            break;

         case Type::PHP_UNKNOWN:
            $v = $value->getStringValue();
            $t = Type::PHP_STRING;
            break;

         default:
            $v = \serialize( $value->getValue() );
            $t = $value->getType();
            break;

      }

      if ( ! \is_null( $t ) && ! \is_null( $v ) )
      {

         $w->startElement( $name );

         if ( $short )
         {
            $w->writeAttribute( 'type', $t );
            $w->writeAttribute( 'value', $v );
         }
         else
         {
            if ( $separateElements )
            {
               $w->writeElement( 'type',  $t );
               $w->writeElement( 'value', $v );
            }
            else
            {
               $w->writeAttribute( 'type', $t );
               $w->text( $v );
            }
         }

         $w->endElement();

      }

   }
public static function WriteTypedXmlValue ( \ XMLWriter $ w , $ value , string $ name , bool $ short = true , bool $ separateElements = false ) { if ( ! ( $ value instanceof Type ) ) { $ value = new Type ( $ value ) ; } $ v = null ; $ t = null ; switch ( $ value -> getType ( ) ) { case Type :: PHP_ARRAY : $ v = \ serialize ( $ value -> getValue ( ) ) ; $ t = Type :: PHP_ARRAY ; break ; case Type :: PHP_BOOLEAN : $ v = $ value -> getValue ( ) ? 'true' : 'false' ; $ t = Type :: PHP_BOOLEAN ; break ; case Type :: PHP_DOUBLE : case Type :: PHP_FLOAT : case Type :: PHP_INTEGER : $ v = $ value -> getValue ( ) ; $ t = $ value -> getType ( ) ; break ; case Type :: PHP_NULL : $ v = '' ; $ t = Type :: PHP_NULL ; break ; case Type :: PHP_RESOURCE : # Ignore some resources break ; case Type :: PHP_STRING : $ v = $ value -> getValue ( ) ; $ t = Type :: PHP_STRING ; break ; case Type :: PHP_UNKNOWN : $ v = $ value -> getStringValue ( ) ; $ t = Type :: PHP_STRING ; break ; default : $ v = \ serialize ( $ value -> getValue ( ) ) ; $ t = $ value -> getType ( ) ; break ; } if ( ! \ is_null ( $ t ) && ! \ is_null ( $ v ) ) { $ w -> startElement ( $ name ) ; if ( $ short ) { $ w -> writeAttribute ( 'type' , $ t ) ; $ w -> writeAttribute ( 'value' , $ v ) ; } else { if ( $ separateElements ) { $ w -> writeElement ( 'type' , $ t ) ; $ w -> writeElement ( 'value' , $ v ) ; } else { $ w -> writeAttribute ( 'type' , $ t ) ; $ w -> text ( $ v ) ; } } $ w -> endElement ( ) ; } }
Writes all data of the defined Value to the XmlWriter.

You can write it in 3 different ways:

- &lt;$name type="..." value="..." /&gt;
Is created if $short is boolean TRUE.

If $short is FALSE you can write in the following 2 ways:

- &lt;$name type="..."&gt;$value&lt;/$name&gt;
Is created if $separateElements is boolean FALSE.
- &lt;$name&gt;&lt;Type&gt;...&lt;/Type&gt;&lt;Value&gt;$value&lt;/Value&gt;&lt;/$name&gt;
Is created if $separateElements is boolean TRUE.

@param \XMLWriter $w                The XmlWriter to use.
@param mixed      $value            The value to write.
@param string     $name             The name of the element to write
@param boolean    $short            Use the short notation? (type and value as attributes)
@param boolean    $separateElements Write type and value in separate elements, if $short is FALSE
Writes all data of the defined Value to the XmlWriter .