Sample Code

Some code samples

PSML sample code

Following are some PSML code samples that can be used as templates.

Basic PSML document

<document>

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

Simple table

<table>

A basic table structure with header row.

<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.

<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"
             count="n">
        <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"
             count="n"
          datatype="xref"
             title="Related">
      <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. Users will find this interface very productive for creating, editing and ordering links. 

<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 will allow users to add a specific fragment type using the standard editing environment.

<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 will automatically expand a minimally-expressed links. This allows developers to only code for the key location and title data:

<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>
<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 Group Manage page under the Admin menu and select the option to Resolve References. PageSeeder will then resolve the link elements, add the implied attributes and values and create a <reversexref> element at the link destination.

Created on , last edited on