Ephox EditLive! for XML provides a number of extensions to XSLT to provide extra functionality and control of EditLive! for XML. These extensions are provided in a separate namespace so that they are ignored by standard XSLT processors. This means that an XSLT can be used outside of EditLive! for XML even if it contains Ephox extensions and the extensions will simply be ignored.
All Ephox extensions use the http://www.ephox.com/product/editliveforxml/1.0/ namespace. Before you can use the extensions you must first declare this namespace in your XSLT. For example, to bind the Ephox extension namespace to the ephox prefix use the declaration below:
xmlns:ephox="http://www.ephox.com/product/editliveforxml/1.0"
The normal namespace inheritance rules for XML apply. It is generally easiest to add this attribute to the stylesheet element of the XSLT so it is available everywhere in the document. A typical stylesheet element might look like:
<xs:stylesheet version="1.0" xmlns:xs="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://www.ephox.com/product/editliveforxml/document/Untitled" xmlns:ephox="http://www.ephox.com/product/editliveforxml/1.0" xmlns="http://www.w3.org/1999/xhtml">
The extensions supported by EditLive! for XML are:
A button inside the document layout that allows the user to initiate actions like a toolbar button.
Controls whether or not insert and remove buttons are automatically added to the document for repeating and optional elements.
Specifies the type of control to use for editable values.
Specifies a more user friendly set of items to display to the user in combo boxes and lists. The actual values inserted into the XML are still what is specified in the schema or in ephox:items but the user sees these values.
Specifies the items to provide in combo boxes and lists.
Specifies that a value should not be editable by the user.
Defines if a section of the form is displayed based on a condition
EditLive! for XML will automatically insert action buttons for some elements from XML. Whether action buttons are inserted for a particular element or not is dependant on both the XSD and the XSLT for the XML file being edited in EditLive! for XML. The XSD specifies whether a particular element or attribute is optional or if an element can be repeated. Action buttons will only be automatically added for optional elements or attributes or repeating elements. The insertion of action buttons is also dependant on the structure of the XSLT in use. Action buttons will only ever be inserted when the apply-templates, template, or for-each XSL element is used within the XSLT. The following list describes the situations in which action buttons will automatically be inserted within EditLive! for XML.
EditLive! for XML will automatically insert action buttons for the following XSL elements in the following situations:
EditLive! for XML will automatically insert an action button to insert the element if it doesn't already exist.
EditLive! for XML will automatically insert an action button to remove the element and an action button to insert another element.
EditLive! for XML will automatically insert a remove action button for the element or attribute.
EditLive! for XML will automatically insert an action button to insert new elements and remove existing elements. If no elements are present an action button will be added to allow the user to add one. This is a combination of the two behaviours above.
The current element for Ephox buttons is always the context node from where it appeared in the XSLT. Most operations will apply on this element so it is important to be aware of the context element, especially when using Ephox buttons (see the ephox:button element). In most cases, the most intuitive place to put the ephox:button in the XSLT is correct, however there are times when this may not be the case. As an example, to provide an action button that removes an optional element when it is present the XSLT should look like:
<?xml version="1.0" encoding="US-ASCII"?>
<xs:stylesheet version="1.0"
xmlns:xs="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://www.ephox.com/product/editliveforxml/document/Untitled"
xmlns:ephox="http://www.ephox.com/product/editliveforxml/1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xs:template match="/">
<html>
<head></head>
<body>
<xs:apply-templates select="my:document/my:optionalElement" />
</body>
</html>
</xs:template>
<!--The context node for this template is "my:optionalElement"-->
<xs:template match="my:optionalElement" ephox:autoaddbuttons="false">
<p>Optional value: <xs:value-of select="." />
<ephox:button action="xmlRemove" text="Remove Optional Element" />
</p>
</xs:template>
</xs:stylesheet>Note that a separate template is used for the my:optionalElement so that the context node changes to the my:optionalElement instead of /. Also note the use of ephox:autoaddbuttons to disable the automatically inserted remove button. The XSLT below would be incorrect and not work as intended:
<?xml version="1.0" encoding="US-ASCII"?>
<xs:stylesheet version="1.0"
xmlns:xs="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://www.ephox.com/product/editliveforxml/document/Untitled"
xmlns:ephox="http://www.ephox.com/product/editliveforxml/1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xs:template match="/">
<html>
<head></head>
<body>
<p>Optional value:
<!--The context node here is still "/" -->
<xs:value-of select="my:document/my:optionalElement" />
<ephox:button action="xmlRemove" text="Remove Optional Element" />
</p>
</body>
</html>
</xs:template>
</xs:stylesheet>In the second example, the context node is not changed and so the remove action button will attempt to remove the root node, resulting in an error. This XSLT will also incorrectly show the Optional value: label and a text box for the value of my:optionalElement even when it doesn't exist in the XML document. See Manually Creating XSLTs For EditLive! for XML for more information on managing the context node.
Copyright 2001-2005 Ephox Corporation. All Rights Reserved.