2006-08-07
| Revision History | ||
|---|---|---|
| Revision 1.0 | 2006-08-07 | AW |
| First initial draft. | ||
Abstract
The Yulup code design for milestone 1.
Table of Contents
Figure 6. Interface IBackend
#ifndef IBACKEND_IDL
#define IBACKEND_IDL
// interface
interface IBackend {
// Associations
// Attributes
// Operations
abstract IDocument createNewDocumentInstanceFromEmpty ( ) = 0;
abstract IDocument createNewDocumentInstanceFromExisting ( ) = 0;
abstract IDocument createNewDocumentInstanceFromTemplate ( ) = 0;
abstract void serializeDocumentInstanceToFile ( in IDocument document, in String name, in URI path ) = 0;
abstract void serializeDocumentInstanceToCMS ( in IDocument document, in String name, in URI path ) = 0;
abstract boolean hasCapability ( in String capability ) = 0;
abstract void tearDown ( ) = 0;
abstract private DocumentRawDataContainer openFromFile ( ) = 0;
abstract private DocumentRawDataContainer openFromCMS ( ) = 0;
abstract private DocumentRawDataContainer openFromHttp ( ) = 0;
abstract private DocumentRawDataContainer saveToFile ( ) = 0;
abstract private DocumentRawDataContainer saveToCMS ( ) = 0;
};
#endif
Figure 7. Class Backend
#ifndef BACKEND_IDL
#define BACKEND_IDL
#include "ibackend.idl"
interface Backend: IBackend {
// Associations
// Attributes
// Operations
IDocument createNewDocumentInstanceFromEmpty ( );
IDocument createNewDocumentInstanceFromExisting ( );
IDocument createNewDocumentInstanceFromTemplate ( );
void serializeDocumentInstanceToFile ( in IDocument document, in String name, in URI path );
void serializeDocumentInstanceToCMS ( in IDocument document, in String name, in URI path );
boolean hasCapability ( in String capability );
void tearDown ( );
private DocumentRawDataContainer openFromFile ( );
private DocumentRawDataContainer openFromCMS ( );
private DocumentRawDataContainer openFromHttp ( );
private DocumentRawDataContainer saveToFile ( );
private DocumentRawDataContainer saveToCMS ( );
};
#endif
Figure 9. Interface IDocument
#ifndef IDOCUMENT_IDL
#define IDOCUMENT_IDL
// interface
interface IDocument {
// Associations
// Attributes
// Operations
abstract Controller getController ( ) = 0;
abstract Model getModel ( ) = 0;
abstract String serialize ( ) = 0;
abstract void close ( ) = 0;
};
#endif
Figure 10. Interface IValidatable
#ifndef IVALIDATABLE_IDL
#define IVALIDATABLE_IDL
// interface
interface IValidatable {
// Associations
// Attributes
// Operations
abstract ValidationErrors validate ( ) = 0;
};
#endif
Figure 11. Class XMLDocument
#ifndef XMLDOCUMENT_IDL
#define XMLDOCUMENT_IDL
#include "idocument.idl"
#include "ivalidatable.idl"
interface XMLDocument: IValidatable: IDocument {
// Associations
// Attributes
private attribute Controller controller;
private attribute Model model;
// Operations
ValidationErrors validate ( );
Controller getController ( );
Model getModel ( );
String serialize ( );
void close ( );
};
#endif
Figure 12. Class PlainDocument
#ifndef PLAINDOCUMENT_IDL
#define PLAINDOCUMENT_IDL
#include "idocument.idl"
interface PlainDocument: IDocument {
// Associations
// Attributes
private attribute Controller controller;
private attribute Model model;
// Operations
Controller getController ( );
Model getModel ( );
String serialize ( );
void close ( );
};
#endif
Figure 20. Interface ICMS
#ifndef ICMS_IDL
#define ICMS_IDL
// interface
interface ICMS {
// Associations
// Attributes
// Operations
abstract ??? new ( ) = 0;
abstract ??? open ( ) = 0;
abstract ??? save ( ) = 0;
abstract ??? saveAs ( ) = 0;
abstract ??? exit ( ) = 0;
abstract ??? queryDirectory ( ) = 0;
abstract ??? queryAssetType ( ) = 0;
};
#endif
All elements in the source document are tagged with a unique ID by applying the sourcetagger.xsl stlyesheet.
For example, a source document
<foo>
Some text.
<bar>
Hello.
</bar>
Some more text.
</foo>
would get transformed to
<foo _yulup-id="951">
Some text.
<bar _yulup-id="362">
Hello.
</bar>
Some more text.
</foo>
Note that the IDs are semi-random and do not neither imply order nor nesting levels.
All elements are added into a map, consisting of ID/DOM node pairs.
For example:
951: ref to foo
362: ref to bar
The source document is transformed into its XHTML version by applying its associated stylesheet, which was first appended to the idcopier.xsl stylesheet which contains a rule to copy the source element's unique ID everytime text is extracted from this element's content and inserted into the XHTML document.
The result is an XHTML document consisting of nodes with no IDs and nodes with possibly not unique IDs (e.g. if the text of one source element was used twice). For exmaple:
<html>
<head>
<title>A Static Title</title>
</head>
<body>
<div>
<span _yulup-id="951">Some text.</span>
<emphasis><span _yulup-id="362">Hello.</span></emphasis>
<span _yulup-id="951">Some more text.</span>
</div>
</body>
</html>
In order to propagate possible changes back to the source document, we first create a second map, mapping unique IDs to nodes using that ID. Since multiple nodes may be using the same ID in the XHTML form, this is a map consisting of ID/(list of DOM nodes) pairs.
For example:
951: [ref to "Some text." span] [ref to "Some more text." span]
362: [ref to "Hello." span]
For all unique IDs in the XHTML node map, the children of the corresponding node in the source document are removed, and all nodes in the XHTML form bearing that ID added to that node in the source document.
After an assumed user modification like
<html>
<head>
<title>A Static Title</title>
</head>
<body>
<div>
<span _yulup-id="951">I've modified some text.</span>
<emphasis><span _yulup-id="362">Hola.</span></emphasis>
<span _yulup-id="951">I've modified some more text.</span>
</div>
</body>
</html>
this would result in the following source document:
<foo _yulup-id="951">
I've modified some text.
I've modified some more text.
</foo>
Unfortunately, this means that the complete <bar/> element is gone.