Sample Code

Some code samples

PSML example markup

Following are some PSML code samples that developers can use as templates.

Basic PSML document – <document>

A PSML document with placeholders for content:

<?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>
   <section id="content">
     <fragment id="2">
       <para>[your first paragraph]</para>
       <!-- more PSML content here... -->

Simple table – <table>

Below is a basic table model with header row.

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

Properties fragment – <properties-fragment>

This specialized fragment, known as a <properties-fragment>,  makes it possible to capture, edit and validate name / value pairs.

<section id="metadata">
  <properties-fragment id="4" >
    <property name="title" title="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">
    <property name="country" title="Country" value="Australia"/>
    <property name="available-date" datatype="date" title="Available date"
    <property name="related" count="n" datatype="xref" title="Related">
       <xref href="book4.psml" frag="default"/>
       <xref href="book7.psml" frag="default"/>

Cross reference fragment – <xref-fragment>

This is a specialized fragment that provides an optimized editor for users that need to create lists of cross references. Users will find that aggregating links, then editing and ordering them is faster with this interface. 

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

Cross reference – <xref>

For developers constructing <xref> or <blockxref> elements, it is useful to remember the server will automatically expand a minimally-expressed link. All that is required is the address of the document and fragment and some content to make the link visible. In other words a link can be as simple as the following:

<xref href="filename.psml" frag="default">link title</xref>
<xref docid="server-wide_uniqueid" frag="default">link title</xref>
<xref uriid="9999" frag="5">link title</xref>

Except for the URIID, which must be generated by the system, documents containing these minimal links can be uploaded before the other end of the link is available.

When both ends are available, any user with the appropriate rights can go to the Group Manage page under the Admin menu and select the option to Resolve References.

The PageSeeder server will then resolve the <xref> element, add the implied attributes and values and create a <reversexref> element at the link destination.

Created on , last edited on