---
title: "PSML"
source: https://dev.pageseeder.com/reference/sample_code/psml.html
description: "This document provides PSML code templates and samples, including basic document structure, tables, properties fragments, cross-references, and fragment templates for PageSeeder document creation and editing."
last_updated: 2026-09-14T15:58:53+10:00
tokens: ~1114
---

# PSML sample code

Following are some [PSML](/reference/glossary/psml.md) code samples that can be used as templates.

## Basic PSML document

### `<document>`

A basic document with placeholders for content:

```xml

<?xml version="1.0" encoding="UTF-8"?>
<document level="portable" [type="[your document type]"]>
  <section id="title">
    <fragment id="1">
      <heading level="1">[your document title]</heading>
    </fragment>
  </section>
  <section id="content">
    <fragment id="2">
      <para>[your first paragraph]</para>
      <!-- more PSML content here... -->
    </fragment>
  </section>
</document>
```

## Basic table

### `<table>`

A basic table structure with header row.

```xml

<table>
  <caption>Books</caption>
  <col width="200px"/>
  <col width="100px"/>
  <row part="header">
    <cell>Title</cell>
    <cell>Author</cell>
  </row>
  <row>
    <cell>Alice's Adventures in Wonderland</cell>
    <cell>Lewis Carol</cell>
  </row>
  <row>
    <cell>Gulliver's Travels</cell>
    <cell>Jonathan Swift</cell>
  </row>
</table>
```

## Properties fragment

### `<properties-fragment>`

A specialized structure, the `<properties-fragment>` is suited to the capture, editing and validation of *name/value* pairs.

```xml

<section id="metadata">
  <properties-fragment id="4" >
    <property name="title" title="Book Title"
              value="Alice's Adventures in Wonderland"/>
    <property name="isbn" title="ISBN"
              value="0000000000001"/>
    <property name="author" title="Author"
              value="Lewis Caroll"/>
    <property name="language" title="Language" multiple="true">
      <value>English</value>
      <value>Spanish</value>
    </property>
    <property name="country" title="Country"
              value="Australia"/>
    <property name="available-date" datatype="date"
              title="Available date"
              value="2012-01-01"/>
    <property name="related" datatype="xref" title="Related"
              multiple="true">
      <xref href="book4.psml" frag="default"/>
      <xref href="book7.psml" frag="default"/>
    </property>
  </properties-fragment>
</section>
```

## Cross-reference fragment

### `<xref-fragment>`

An editing interface specialized for [cross-references](/reference/glossary/cross_reference.md). Users find this [interface](/guide/configuration/psml/psml_xrefs_editor.md) very productive for creating, editing and ordering links. 

```xml
<section id="links">
  <xref-fragment id="5">
    <blockxref href="chapter1.psml"
               frag="default">Chapter 1: Down the Rabbit-Hole</blockxref>
    <blockxref href="chapter2.psml"
               frag="default">Chapter 2: The Pool of Tears</blockxref>
  </xref-fragment>
</section>
```

## Fragment template

Adding this to the [document-template](/guide/configuration/psml/psml_document_template.md) allows users to add a specific fragment type using the standard editing environment.

```xml

<t:fragment type="parameter" title="Parameter">
  <fragment>
    <properties-fragment id="4">
      <property name="field"     title="Field"       value=""/>
      <property name="type"      title="Type"        value=""/>
      <property name="mandatory" title="Mandatory"   value=""/>
      <property name="desc"      title="Description" value=""/>
    </properties>
  </fragment>
</t:fragment>
```

## Cross-reference

### `<xref>`

When coding the creation of `<xref>` or `<blockxref>` elements, it is useful to remember that the server automatically expands minimally-expressed links. This allows developers to only code for the key location and title data:

```xml
<xref href="filename.psml"
      frag="default">the title to be displayed</xref>

<xref docid="server-wide_uniqueid" 
      frag="default">the title to be displayed</xref>
```

```xml
<xref uriid="9999"
      frag="5">the title to be displayed</xref>
```

Except for an `<xref>` or `<blockxref>` using the `uriid` attribute, which is generated by the system, xrefs can be created even if the other end of the link does not exist. Or the collection of linked documents is only partially complete.

To process the links, any user with the appropriate rights can go to the **Administration** menu, **Group maintenance** page, and select the option to **Resolve...**. PageSeeder then resolves the `<xref>`, `<link>`, and `<image>` elements, adds the implied attributes and values and creates a `<reversexref>` element in the destination document.

