PSML

A complete reference of PageSeeder's markup language PSML

<media-fragment>

Summary

The <media-fragment> element is used to include non-PSML content such as MathML, SVG or plain text.

Other fragment elements are:

Usage context

Element categorystructure
PSML levelportable
Permitted contentany
Permitted parent<section>
HTML equivalentno equivalent but similar to CDATA sections
OpenXML equivalent
PSStandard equivalent <customBody>

Attributes

This element includes the following attributes

NameTypeRequiredDescription
idfragment-idyesThe fragment ID.
mediatypexs:stringnoA MIME type.
typefragment-typenoA template type.
labelslabel-listnoA list of fragment labels

@id

A fragment identifier that is unique within the document.

@mediatype

The media type (MIME) of the content within the media fragment. 

It should not include character encoding (charset) as the encoding is defined at the PSML document level.

Media types referring to binary documents are acceptable provided that they use an encoding that is compatible with the character encoding used at the PSML document level. In general, it is best to use base64.

@type

If this fragment has a type or was created using a document-template.

Examples

Example #1: Plain text fragment

<media-fragment id="1" mediatype="text/plain">
  Here is some plain text content
</media-fragment>

Example #2: MathML fragment

Media fragments can be used to include MathML  in PSML document.

<media-fragment id="1" mediatype="application/mathml+xml">
<mrow>
  <mfrac>
    <mrow>
      <mi>x</mi>
      <mo>+</mo>
      <msup>
        <mi>y</mi>
        <mn>2</mn>
      </msup>
    </mrow>
    <mrow>
      <mi>k</mi>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</mrow>
</media-fragment>

Note

PSML does not recognise MathML named entities  such as for example &InvisibleTimes;, the corresponding numeric character entity must be used instead. Beware also that some mathematical symbols do not belong to Basic Multilingual Plane (BMP). Ensure that PageSeeder is suitably configured to support Unicode characters outside the BMP. 

Example #3: SVG

Media fragments can also be used to include SVG  inside PSML.

<media-fragment id="1" mediatype="image/svg+xml">
   <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
      <rect x="50" y="50" width="200" height="200" fill="lime" />
      <circle cx="125" cy="125" r="75" fill="orange" /> 
     <line x1="50" y1="50" x2="200" y2="200" stroke="blue" stroke-width="4"/>
   </svg>
</media-fragment>

 

Schema

XML Schema

<xs:element name="media-fragment">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="id" type="fragment-id" use="required"/>
      <xs:attribute name="type" type="fragment-type"/>
      <xs:attribute name="mediatype" type="xs:string"/>
      <xs:attribute name="labels" type="label-list"/>
   </xs:complexType>
</xs:element>

Relax Schema

element media-fragment {
  attribute id { fragment-id } ,
  attribute type { fragment-type }?,
  attribute mediatype { text }?,
  attribute labels { label-list }?, 
  any
}

Compatibility

This element was introduced in PSML Beta 4 as a replacement for the now defunct <ext-fragment> element.

It is supported from PageSeeder 5.3.

Warning!

Although it is possible to define media fragments with any media type, beware that using undocumented media type may cause your document to display incorrectly or to be handled incorrectly during publishing.

Media type which are known to work:

  • text/plain
  • application/mathml+xml
  • image/svg+xml
  • application/xml

PS Standard XML

In the Standard Format, fragments that didn't contain PS Standard XML content are expressed using the <customBody> element and a different algorithm is used to compute their fragment identifier.

The PSML <media-fragment> element also supports a @mediatype attribute so that the type of content can be clearly identified in a more standard manner.

See also

Created on , last edited on