- if ( $content instanceof TextContent ) {
- // HACK: For text based models, bypass the serialization step.
- // This allows extensions (like Flow)that use incompatible combinations
- // of serialization format and content model.
- $text = $content->getNativeData();
- } else {
- $text = $content->serialize( $content_format );
- }
- $text = $content_handler->exportTransform( $text, $content_format );
- $out .= " " . Xml::elementClean( 'text',
- [ 'xml:space' => 'preserve', 'bytes' => intval( $slot->getSize() ) ],
- strval( $text ) ) . "\n";
+ if ( $isV11 ) {
+ $out .= $indent . Xml::element( 'origin', null, strval( $slot->getOrigin() ) ) . "\n";
+ }
+
+ $contentModel = $slot->getModel();
+ $contentHandler = ContentHandler::getForModelID( $contentModel );
+ $contentFormat = $contentHandler->getDefaultFormat();
+
+ // XXX: The content format is only relevant when actually outputting serialized content.
+ // It should probably be an attribute on the text tag.
+ $out .= $indent . Xml::element( 'model', null, strval( $contentModel ) ) . "\n";
+ $out .= $indent . Xml::element( 'format', null, strval( $contentFormat ) ) . "\n";
+
+ $textAttributes = [
+ 'xml:space' => 'preserve',
+ 'bytes' => $slot->getSize(),
+ ];
+
+ if ( $isV11 ) {
+ $textAttributes['sha1'] = $slot->getSha1();
+ }
+
+ if ( $contentMode === self::WRITE_CONTENT ) {
+ try {
+ // write <text> tag
+ $out .= $this->writeText( $slot->getContent(), $textAttributes, $indent );
+ } catch ( SuppressedDataException $ex ) {
+ // NOTE: this shouldn't happen, since the caller is supposed to have checked
+ // for suppressed content!
+ // write <text> placeholder tag
+ $textAttributes['deleted'] = 'deleted';
+ $out .= $indent . Xml::element( 'text', $textAttributes ) . "\n";