Serna plugin development


I spent a couple of days figuring out some weird behaviour of Serna. When trying to develop my own plugin, it always rendered my content in editable text fields, rather than word-processor-like inline editable text. Looking at the FO-tree dump, it appeared to be rendered using the serna-extensions.


I decided to strip-down the resume project, up to the level at which my own plugin was built up, to see where the text fields would show up.

The trigger for getting the editable text fields, is removing this line from the source resume xml:

<!DOCTYPE resume PUBLIC "-//Sean Kelly//DTD Resume  1.5.1//EN" "" []>

A clue on the web?:

It’s not a bug  per se.  That final decision rests with the folks at Syntext.  Serna has the capability to support entities (which XML Schema does not have).  In order to do get that capability, Serna uses in-line DOCTYPE.

That said, to process those documents in the Toolkit one needs to do one of the following:

a) remove the DOCTYPE from the XML docs; you get XSD validation

b) remove xmlxs:xsi namespace and xsi:noNamespaceSchemaLocation attribute from the XML docs;  you get DTD validation

c) modify the DTDs in the Toolkit  to include xmlxs:xsi namespace and xsi:noNamespaceSchemaLocation attribute;  you get DTD validation

Changing the XML parser parameters will not do anything useful since it is dependent on what appears in the XML docs.  The easiest one to do ay this point would be to modify the DTDs in the Toolkit.  That would allow you to process the documents without having to modify each one them.

Further stripping down of the resume example shows how the DTD declares a FIXED xmlns-attribute to the top-level element. Setting or unsetting this attribute would cause Serna to behave differently regarding presentation of the element text in wysiwyg-view. After removing the DTD alltogether, the xmlns-attribute doesn’t seem to be needed at all.

Bare-bone Serna plug-in

This is the complete specification of a bare-bone Serna plug-in that can be used for displaying, editing and saving xml-files using a custom stylesheet.

Serna Document Template (sdt)

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE  t:document-template PUBLIC "-//Syntext//DTD Syntext Document Template  V2.0//EN" "doctemplate2.dtd">
<t:document-template  xmlns:t="">
 <t:category>XML  Resume</t:category>

XML Schema (resumex.xsd)

<?xml  version="1.0"?>
<xs:schema  xmlns:xs="">
 <xs:element  name="misc">
    <xs:element ref="para"   maxOccurs="unbounded"/>
 <xs:element  name="para">
  <xs:complexType mixed="true" />
 <xs:element  name="resume">
    <xs:element ref="misc"   maxOccurs="unbounded"/>

Stylesheet (resume.xsl)

<xsl:stylesheet  version="1.0"

<xsl:include  href=""/>

<xsl:strip-space  elements="*"/>

<xsl:template name="heading">
  <xsl:value-of  select="local-name(.)"/>

<xsl:template  match="para">
  <xsl:call-template name = "bold.inline"/>

<xsl:template  match="misc">
 <xsl:call-template name="heading"/>

<xsl:template  match="resume">
 <xsl:call-template name="div"/>


Example XML

<?xml version='1.0'  encoding='UTF-8'?>
  <para>User  Documentation developer</para>


I seem to have solved my problem, but I still don’t understand why Serna behaves the way it does. Anyway, lesson learned (once again): if a stylesheet is behaving strange, 9 to 10 a namespace is in your way!

[Update!] Conclusion 2

I must have been completely deceived…. now it seems more like that the element definition in the xsd controls the behaviour of Serna:
This definition renders text fields:

<xs:element name="hyperlink"  type="xs:string" minOccurs="0" maxOccurs="1"/>

And omitting the ‘type=”xs:string”’ renders wordprocessor-style inline text:

<xs:element  name="title" minOccurs="0" maxOccurs="1"/>

2 thoughts on “Serna plugin development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s