|
DITA Storm
browser-based DITA XML Editor
by Inmedius Inc.
|
||
|
Editor Integration
Description: Provides instructions how to integrate DITA Storm editor into generic web application.
Integrating DITA Storm into HTML PageIntegrating DITA Storm into web application or content management system is a relatively simple procedure. You can either attach editor to the text field of your HTML form or load DITA document directly via HTTP request. Here are basic required steps:
Example: Attaching to HTML Form FieldLets take a simple example of HTML form with text field and modify it utilize DITA Storm. Here is the original HTML form: <HTML>
<HEAD>
<SCRIPT>
function verifyAndSubmit() {
...
}
</SCRIPT>
</HEAD>
<BODY onLoad='init()'>
<FORM name='myForm' onSubmit='verifyAndSubmit()'>
<INPUT name='ditaField'
type='text'
value='<topic><title>Lorem Ipsum</title><body>
<p>Morbi et lacus nec.</p></body></topic>'>
...
</FORM>
</BODY>
</HTML>
This HTML can be easily modified to enable DITA editing with DITA Storm: <HTML>
<HEAD>
<LINK href="DITAStorm/styles.css" rel="stylesheet" type="text/css"/>
<SCRIPT src="DITAStorm/DITAStorm.js" type="text/javascript"></SCRIPT>
<SCRIPT>
function verifyAndSubmit()
{
// store XML back to the field and proceed with regular form submission
ditaStorm.updateField();
...
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name='myForm' onSubmit='verifyAndSubmit()'>
<INPUT name='ditaField' type='hidden'
value='<topic><title>Lorem</title><body><p>...</p></body></topic>'>
<SCRIPT>
// Render Editor and get value from the field
ditaStorm.render('DITAStorm','100%','300','simple.css','simple.xsl.js');
ditaStorm.attachField('myForm','ditaField');
</SCRIPT>
</FORM>
</BODY>
</HTML>
Example: Loading DITA Document via HTTP DITA Storm can load XML content directly from server via HTTP request. JavaScript function loadXmlFile() retrieves XML over HTTP and loads it into the editor. Here is the sample code:
<HTML>
<HEAD>
<LINK href="/cm/lib/DITAStorm/styles.css" rel="stylesheet" type="text/css"/>
<SCRIPT src="/cm/lib/DITAStorm/DITAStorm.js" type="text/javascript"></SCRIPT></HEAD>
<BODY>
<SCRIPT>
ditaStorm.render(
'/cm/lib/DITAStorm','100%','300','simple.css','simple.xsl.js');
ditaStorm.loadXmlFile('/cm/content/product.xml');
</SCRIPT>
</BODY>
</HTML>
loadXmlFile function can also be called at any time during the lifetime of DITA Storm control on the web page. Example: Retrieving Modified XML via JavaScript You can always retrieve currently edited DITA XML as text via JavaScript call using getXml() function. For example:
<SCRIPT>
var xmlString = ditaStorm.getXml();
alert('Content: '+xmlString);
</SCRIPT>
|
|
|
Copyright © 2007
Inmedius Inc. |
||