fix NPE error on builder, as well as add DOM synchronization tests
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/VEXDocument.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/VEXDocument.java
index a9023cc..f7cf199 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/VEXDocument.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/VEXDocument.java
@@ -341,5 +341,9 @@
 	 * @generated
 	 */
 	void insertText(int offset, String text) throws DocumentValidationException;
+	
+	void setDOMDocument(org.w3c.dom.Document domDocument);
+	
+	org.w3c.dom.Document getDOMDocument();
 
 } // VEXDocument
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
index 7a8653c..b19c79d 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
@@ -692,4 +692,15 @@
 		return result.toString();
 	}
 
+	public Document getDOMDocument() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public void setDOMDocument(Document domDocument) {
+		
+	}
+	
+	
+
 } //VEXDocumentImpl
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
index 95228bd..d982cc4 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
@@ -341,9 +341,11 @@
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
-	 * @generated
+	 * @generated not
 	 */
 	public void setText(String newText) {
+		
+	
 		String oldText = text;
 		text = newText;
 		if (eNotificationRequired())
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Document.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Document.java
index d78e82f..23ecf22 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Document.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Document.java
@@ -29,6 +29,9 @@
 import org.eclipse.wst.xml.vex.core.internal.undo.CannotRedoException;
 import org.eclipse.wst.xml.vex.core.internal.undo.CannotUndoException;
 import org.eclipse.wst.xml.vex.core.internal.undo.IUndoableEdit;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
 
 /**
  * Represents an XML document.
@@ -44,6 +47,9 @@
 
 	//private String publicID;
 	protected String systemID;
+	
+	protected org.w3c.dom.Document domDocument;
+	
 	//private String encoding;
 	//private Validator validator;
 
@@ -57,12 +63,21 @@
 	 */
 	public Document(VEXElement rootElement) {
 		content = new GapContent(100);
+		content.insertString(0, "\0\0");
+
 		this.rootElement = rootElement;
 		rootElement.setDocument(this);
-		content.insertString(0, "\0\0");
 		rootElement.setContent(content, 0, 1);
 		
 	}
+	
+	public Document(org.w3c.dom.Document domDocument) {
+		content = new GapContent(100);
+		content.insertString(0, "\0\0");
+		
+		setDOMDocument(domDocument);
+		rootElement.setDocument(this);
+	}
 
 	/**
 	 * Class constructor. This constructor is used by the document builder and
@@ -955,5 +970,67 @@
 	private void fireContentInserted(DocumentEvent e) {
 		this.listeners.fireEvent("contentInserted", e);
 	}
+	
+	@Override
+	public void setDOMDocument(org.w3c.dom.Document domDocument) {
+		this.domDocument = domDocument;
+		synchronizeDocuments();
+	}
+	
+	@Override
+	public org.w3c.dom.Document getDOMDocument() {
+		return domDocument;
+	}
+	
+	private void synchronizeDocuments() {
+		synchronizeRootElement();
+	}
+	
+	private void synchronizeRootElement() {
+		rootElement = null;
+		org.w3c.dom.Element domRootElement = domDocument.getDocumentElement(); 
+		String rootElementName = domRootElement.getNodeName();
+		rootElement = new RootElement(rootElementName);
+		rootElement.setElement(domRootElement);
+		rootElement.setContent(content, 0, 1);
+		synchronizeAttributeNodes(rootElement, domRootElement);
+		synchronizeChildNodes(rootElement, domRootElement);
+	}
+	
+	private void synchronizeAttributeNodes(VEXElement vexElement, org.w3c.dom.Element domElement) {
+		NamedNodeMap domAttrNodes = domElement.getAttributes();
+		if (domAttrNodes == null || domAttrNodes.getLength() == 0) {
+			return;
+		}
+		for (int nodeCount = 0; nodeCount < domAttrNodes.getLength(); nodeCount++ ) {
+			Attr attrNode = (Attr)domAttrNodes.item(nodeCount);
+			String attrName = attrNode.getName();
+			String attrValue = attrNode.getValue();
+			vexElement.setAttribute(attrName, attrValue);
+		}
+	}
+	
+	private void synchronizeChildNodes(VEXElement vexElement, org.w3c.dom.Element domElement) {
+		NodeList domNodes = domElement.getChildNodes();
+		if (domNodes.getLength() > 0) {
+			for (int nodeCount = 0; nodeCount < domNodes.getLength(); nodeCount++) {
+				org.w3c.dom.Node domNode = domNodes.item(nodeCount);
+				if (domNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
+					VEXElement element = new Element(domNode.getNodeName());
+					synchronizeChildNodes(element, (org.w3c.dom.Element) domNode);
+					synchronizeAttributeNodes(element, (org.w3c.dom.Element) domNode);
+					element.setElement((org.w3c.dom.Element) domNode);
+					vexElement.addChild(element);
+				}
+				if (domNode.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
+					int offset = content.getLength();
+					String text = domNode.getNodeValue();
+					content.insertString(this.content.getLength(), domNode.getNodeValue());
+					content.insertString(content.getLength(), "\0");
+					vexElement.setContent(content, offset, content.getLength() - 1);
+				}
+			}
+		}
+	}
 
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
index 5e5b4ea..9e5b351 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
@@ -18,6 +18,7 @@
 import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
 import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
 import org.eclipse.wst.xml.core.internal.modelhandler.XMLModelLoader;
+import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
@@ -135,6 +136,10 @@
 		this.content.insertString(content.getLength(), "\0");
 		entry.element.setContent(this.content, entry.offset, content
 				.getLength() - 1);
+//		int length = entry.element.getEndOffset() - entry.element.getStartOffset();
+//		String text = content.getString(entry.element.getStartOffset(), length);
+//		org.w3c.dom.Text textNode = entry.element.getElement().getOwnerDocument().createTextNode(text);
+//		entry.element.getElement().appendChild(textNode);
 
 		if (this.isBlock(entry.element)) {
 			this.trimLeading = true;
@@ -164,6 +169,9 @@
 	private void initDOM() {
 		IDOMModel model = null;
 		model = new DOMModelImpl();
+		IModelManager modelManager = StructuredModelManager.getModelManager();
+		IStructuredDocument structuredDocument = modelManager.createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML);
+		model.setStructuredDocument(structuredDocument);
 		domDocument =  model.getDocument();
 	}
 
@@ -201,6 +209,8 @@
 				element.setAttribute(attrs.getQName(i), attrs.getValue(i));
 			}
 
+//			org.w3c.dom.Text textNode = domDocument.createTextNode(cleanUpText(this.isBlock(element)).toString());
+//			element.getElement().appendChild(textNode);
 			this.appendChars(this.isBlock(element));
 
 			stack.add(new StackEntry(element, content.getLength(), this
@@ -215,6 +225,15 @@
 		}
 
 	}
+	
+	private StringBuffer cleanUpText(boolean trim) {
+		StringBuffer sb;
+
+		sb = cleanUpTextContent(trim);
+		
+		return sb;
+		
+	}
 
 	public void startPrefixMapping(String prefix, String uri) {
 	}
@@ -252,6 +271,16 @@
 
 		StringBuffer sb;
 
+		sb = cleanUpTextContent(trimTrailing);
+
+		this.content.insertString(this.content.getLength(), sb.toString());
+
+		this.pendingChars.setLength(0);
+		this.trimLeading = false;
+	}
+
+	private StringBuffer cleanUpTextContent(boolean trimTrailing) {
+		StringBuffer sb;
 		StackEntry entry = this.stack.size() > 0 ? (StackEntry) this.stack
 				.getLast() : null;
 
@@ -290,11 +319,7 @@
 		}
 
 		this.normalizeNewlines(sb);
-
-		this.content.insertString(this.content.getLength(), sb.toString());
-
-		this.pendingChars.setLength(0);
-		this.trimLeading = false;
+		return sb;
 	}
 
 	private boolean isBlock(VEXElement element) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
index ada6d7a..3ab2994 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
@@ -23,7 +23,10 @@
 import org.eclipse.emf.common.util.BasicEList;
 import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.Content;
 import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
 import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXElement;
 import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXNode;
@@ -72,7 +75,7 @@
 	public void addChild(VEXElement child) {
 		childNodes.add(child);
 		child.setParent(this);
-		getElement().appendChild(child.getElement());
+		//getElement().appendChild(child.getElement());
 	}
 
 	/*
@@ -407,5 +410,19 @@
 	public String getNodeType() {
 		return "Element";
 	}
+	
+	/**
+	 * Sets the content of the node
+	 * 
+	 * @param content
+	 *            Content object holding the node's content
+	 * @param startOffset
+	 *            offset at which the node's content starts
+	 * @param endOffset
+	 *            offset at which the node's content ends
+	 */
+	public void setContent(Content content, int startOffset, int endOffset) {
+		super.setContent(content, startOffset, endOffset);
+	}	
 
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.properties b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.properties
index 014a843..be27ce7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.properties
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.properties
@@ -20,6 +20,7 @@
 StylePropertyPage.name=Vex Style
 VexCommandCategory.name=Vex XML Editor
 VexEditor.name=Vex XML Editor
+VexEditor.multipage.name=VEX Multipage XML Editor
 VexEditorContext.name=Editing XML Documents
 VexViewCategory.name=Vex
 
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.xml b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.xml
index 9d16685..cd3a3ec 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.xml
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/plugin.xml
@@ -134,24 +134,23 @@
             id="org.eclipse.wst.xml.vex.ui.VexEditor">
       </editor>
    </extension>
-<!--
+
    	<extension point="org.eclipse.ui.editors">
 		<editor
-			name="%VexEditor.name"
+			name="%VexEditor.multipage.name"
 			icon="$nl$/vex16.gif"
 			contributorClass="org.eclipse.wst.xml.vex.ui.internal.editor.VexActionBarContributor"
 			class="org.eclipse.wst.xml.vex.ui.internal.editor.VEXMultiPageEditorPart"
 			symbolicFontName="org.eclipse.wst.sse.ui.textfont"
-			id="org.eclipse.wst.xml.vex.ui.VexEditor">
+			id="org.eclipse.wst.xml.vex.ui.VexEditorMultiPage">
 			<contentTypeBinding
 				contentTypeId="org.eclipse.core.runtime.xml" />
-			<contentTypeBinding
+<!--			<contentTypeBinding
 				contentTypeId="org.eclipse.wst.xml.core.xmlsource" />
-
+-->				
 		</editor>
 	</extension>
- -->  
-   
+    
    <extension
          point="org.eclipse.ui.newWizards">
       <category
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/BuildProblemDecorator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/BuildProblemDecorator.java
index 2fcffe1..70db10a 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/BuildProblemDecorator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/BuildProblemDecorator.java
@@ -7,6 +7,7 @@
  * 
  * Contributors:
  *     John Krasnay - initial API and implementation
+ *     Torsten Stolpmann - bug 250837 - fixed id used for builder.
  *******************************************************************************/
 package org.eclipse.wst.xml.vex.ui.internal.config;
 
@@ -30,7 +31,7 @@
 public class BuildProblemDecorator extends LabelProvider implements
 		ILightweightLabelDecorator {
 
-	public static final String ID = "org.eclipse.wst.xml.vex.ui.internal.config.buildProblemDecorator"; //$NON-NLS-1$
+	public static final String ID = "org.eclipse.wst.xml.vex.ui.config.buildProblemDecorator"; //$NON-NLS-1$
 
 	public void decorate(Object element, IDecoration decoration) {
 
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VEXMultiPageEditorPart.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VEXMultiPageEditorPart.java
index 3c39868..8d0af6b 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VEXMultiPageEditorPart.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VEXMultiPageEditorPart.java
@@ -12,6 +12,7 @@
 import org.eclipse.wst.xml.ui.internal.Logger;
 import org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorMessages;
 import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer;
+import org.eclipse.wst.xml.vex.ui.internal.swt.VexWidget;
 
 public class VEXMultiPageEditorPart extends MultiPageEditorPart {
 
@@ -25,9 +26,13 @@
 		try {
 			createSourcePage();
 			createVisualEditorPage();
-			addSourcePage();
 			addVisualEditorPage();
-			setActivePage(sourcePageIndex);
+			addSourcePage();
+			
+			VexWidget vexWidget = vexEditor.getVexWidget();
+			modelDocument = (IDOMDocument) vexWidget.getDocument().getDOMDocument();
+			textEditor.getTextViewer().setDocument(modelDocument.getStructuredDocument());
+			setActivePage(visualPageIndex);
 
 		} catch (PartInitException e) {
 			Logger.logException(e);
@@ -61,20 +66,20 @@
 	
 	private void addVisualEditorPage() throws PartInitException {
 		visualPageIndex = addPage(vexEditor, getEditorInput());
-		setPageText(visualPageIndex, "VEX");
+		setPageText(visualPageIndex, "Author");
 		firePropertyChange(PROP_TITLE);
 	}
 
 	public void doSave(IProgressMonitor monitor) {
-	   textEditor.doSave(monitor);
+	  vexEditor.doSave(monitor);
 	}
 
 	public void doSaveAs() {
-		textEditor.doSaveAs();
+		vexEditor.doSaveAs();
 	}
 
 	public boolean isSaveAsAllowed() {
-		return textEditor.isSaveAsAllowed();
+		return vexEditor.isSaveAsAllowed();
 	}
 
 	private IDocument getDocument() {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
index 035f6f2..fa5e541 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
@@ -62,6 +62,12 @@
 import org.eclipse.ui.views.properties.IPropertySource;
 import org.eclipse.ui.views.properties.IPropertySourceProvider;
 import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
 import org.eclipse.wst.xml.vex.core.internal.core.ListenerList;
 import org.eclipse.wst.xml.vex.core.internal.dom.DOMDocumentReader;
 import org.eclipse.wst.xml.vex.core.internal.dom.Document;
@@ -341,6 +347,11 @@
 
 			IPath inputPath = null;
 
+			IModelManager modelManager = StructuredModelManager
+					.getModelManager();
+			IStructuredDocument structuredDocument = null;
+			IStructuredModel model = null;
+
 			if (input instanceof IFileEditorInput) {
 				inputPath = ((IFileEditorInput) input).getFile()
 						.getRawLocation();
@@ -371,11 +382,28 @@
 						.println("Parsed document in " + (end - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
 			}
 
+			if (input instanceof IFileEditorInput) {
+				IFile file = ((IFileEditorInput) input).getFile();
+
+				model = modelManager.getModelForEdit(file);
+				structuredDocument = model.getStructuredDocument();
+			}
+			
+			IDOMDocument domDocument = ((IDOMModel) model).getDocument();
+			doc = new Document(domDocument);
+			doc.setPublicID(domDocument.getDoctype().getPublicId());
+			doc.setSystemID(domDocument.getDoctype().getSystemId());
+			doc.setEncoding(structuredDocument.getEncodingMemento()
+					.getJavaCharsetName());
+			doctype = DocumentType.getDocumentType(doc.getPublicID());
+			wsFactory.getPolicy(doc.getPublicID());
+
 			// this.doctype is set either by wsPolicyFactory or entityResolver
 			// this.style is set by wsPolicyFactory
 			// Otherwise, a PartInitException would have been thrown by now
 
-			Validator validator = WTPVEXValidator.create(doctype.getResourceUrl());
+			Validator validator = WTPVEXValidator.create(doctype
+					.getResourceUrl());
 			if (validator != null) {
 				this.doc.setValidator(validator);
 				if (this.debugging) {
@@ -392,7 +420,7 @@
 
 			if (this.updateDoctypeDecl) {
 				this.doc.setPublicID(this.doctype.getPublicId());
-				((Document)this.doc).setSystemID(this.doctype.getSystemId());
+				((Document) this.doc).setSystemID(this.doctype.getSystemId());
 				this.doSave(null);
 			}
 
@@ -508,7 +536,7 @@
 		super.setInput(input);
 		this.setPartName(input.getName());
 		this.setContentDescription(input.getName());
-		//this.setTitleToolTip(input.getToolTipText());
+		// this.setTitleToolTip(input.getToolTipText());
 	}
 
 	public void setStatus(String text) {
@@ -639,12 +667,12 @@
 		gd.verticalAlignment = GridData.FILL;
 		this.vexWidget.setLayoutData(gd);
 
-//		VexActionBarContributor contributor = (VexActionBarContributor) this
-//				.getEditorSite().getActionBarContributor();
-//
-//		MenuManager menuMgr = contributor.getContextMenuManager();
-//		this.getSite().registerContextMenu(menuMgr, this.vexWidget);
-//		this.vexWidget.setMenu(menuMgr.createContextMenu(this.vexWidget));
+		// VexActionBarContributor contributor = (VexActionBarContributor) this
+		// .getEditorSite().getActionBarContributor();
+		//
+		// MenuManager menuMgr = contributor.getContextMenuManager();
+		// this.getSite().registerContextMenu(menuMgr, this.vexWidget);
+		// this.vexWidget.setMenu(menuMgr.createContextMenu(this.vexWidget));
 
 		this.savedUndoDepth = this.vexWidget.getUndoDepth();
 
@@ -837,7 +865,8 @@
 				}
 			}
 
-			style = VexEditorMultiPage.findStyleForDoctype(doctype.getPublicId());
+			style = VexEditorMultiPage.findStyleForDoctype(doctype
+					.getPublicId());
 			if (style == null) {
 				throw new NoStyleForDoctypeException(doctype);
 			}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/projectFiles/SecuringYourApacheServer.xml b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/projectFiles/SecuringYourApacheServer.xml
new file mode 100644
index 0000000..29bafc5
--- /dev/null
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/projectFiles/SecuringYourApacheServer.xml
@@ -0,0 +1,253 @@
+<?xml version='1.0'?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd">
+<chapter id="SecuringYourApacheServer">
+  <title>Securing Your Apache Server with SSL</title>
+  <para>Test insert of some code.</para>
+  <section>
+    <title>Getting Started with SSL on Apache</title>
+    <para>There are a few key ingredients you will need to use with 
+    Apache to secure your Web server: OpenSSL, mod_ssl, and root access 
+    to the server.</para>
+    <para>OpenSSL is a command line toolkit for using secure sockets 
+    layer encryption on a server and can be acquired from 
+    <ulink url="http://www.openssl.org">http://www.openssl.org</ulink> 
+    . This tool works with Apache module mod_ssl in carrying out 
+    SSL-related tasks. Any modern Linux/Unix installation will come 
+    with OpenSSL, you will be required to install OpenSSL if your 
+    hosting you Apache sever on Windows. You will need root/admin 
+    privileges to install OpenSSL.</para>
+    <para>You must also ensure that mod_ssl is available on your 
+    server. To see which modules are active in Apache, issue the 
+    following command in a Terminal as root user on your server.</para>
+    <screen>
+# httpd –l
+        </screen>
+    <para>If you have a recent Linux distribution installed, it is 
+    likely Apache’s modules are compiled as dynamic loadable modules, 
+    in which case you’ll need to edit your httpd.conf file and check 
+    that the following line is uncommented.</para>
+    <screen>
+LoadModule ssl_module modules/libmodssl.so
+        </screen>
+    <para>Restarting Apache will load the module into action.</para>
+    <screen>
+# service httpd restart
+        </screen>
+    <note>
+      <para>Note that in recent Apache distributions, the httpd.conf 
+      file contains an <emphasis>&quot;IfDefine 
+      HAVE_SSL&quot;</emphasis> section that is intended to contain the 
+      <emphasis>&quot;VirtualHost&quot;</emphasis> definitions for all 
+      your SSL Websites. By placing these definitions within the 
+      <emphasis>&quot;IfDefine&quot;</emphasis> section, you can ensure 
+      that the sites will not be made available unless SSL support is 
+      successfully loaded on the server. This prevents any problems 
+      arising in which lack of SSL could expose your secure site</para>
+    </note>
+  </section>
+  <section>
+    <title>Create a Local Key Pair</title>
+    <para>If you have not already done so, your first step should be to 
+    create a local private/public key from which you can generate 
+    certificate requests. These can then be used for self-signed 
+    certificates, or when purchasing a certificate from a CA.</para>
+    <para>OpenSSL allows us to use the command line to generate keys. 
+    You have the option of using strong encryption and a passphrase to 
+    secure your private key, as shown below.</para>
+    <screen>
+# cd /etc/ssl/apache/
+# openssl genrsa -des3 -out domainname.com.key 2048
+        </screen>
+    <para>Typing the above on the command line will create a private 
+    key using TripleDES encryption, 1024 being the number of bits 
+    generated in the key. There are options for lower encryption 
+    levels, however, these are not recommended for those with servers 
+    that are accessible via the Internet.</para>
+    <para>The key will be created in the directory you’re in.</para>
+    <para>Finally, you should modify the permissions to restrict access 
+    to the new key.</para>
+    <screen>
+# cd /etc/ssl/apache/
+# chmod 400 domainname.com.key
+# chown root.root domainname.com.key
+        </screen>
+    <para>This ensures that only the root user has access to this file, 
+    and still requires the passphrase you may have used to create the 
+    key in order to open.</para>
+  </section>
+  <section>
+    <title>Generating a Certificate Signing Request</title>
+    <para>To purchase an SSL certificate from a CA, you need first to 
+    generate what is called a Certificate Signing Request (CSR). This 
+    is submitted to the CA of your choice, and is used to create the 
+    official and singed SSL certificate that will be returned to you, 
+    and with which you may secure your Web server.</para>
+    <screen>
+# cd /etc/ssl/apache/
+# openssl req -new -key domainname.com.key -out domainname.com.csr
+        
+        </screen>
+    <para>This command creates the .csr file that is sent or uploaded 
+    to a CA during the process of ordering an SSL certificate.</para>
+  </section>
+  <section>
+    <title>Receiving and Installing Your SSL Certificate</title>
+    <para>Generally, CAs provide detailed instructions for the 
+    installation of their SSL certificates; however, I’ll cover some 
+    broad points here.</para>
+    <para>The CA from which you order a certificate will email you 
+    either the certificate, or a link at which you can download it. 
+    Follow the instructions provided precisely—especially with regards 
+    to opening a certificate in a text editor. Do not use a word 
+    processor or rich text editor, as the certificate code can become 
+    corrupted. You should also take care to ensure that no leading or 
+    trailing spaces follow the beginning and end of the certificate 
+    code in <xref linkend="examp_Emailed_Certificate"/> .</para>
+    <example id="examp_Emailed_Certificate">
+      <title>Sample Emailed Certificate</title>
+      <programlisting>
+-----BEGIN CERTIFICATE-----
+MIICzjCCAjegAwIBAgIBAjANBgkqhkiG9w0BAQQFADCBrDELMAkGA1UEBhMCVVMx
+ETAPBgNVBAgTCFZpcmdpbmlhMRQwEgYDVQQHEwtTcHJpbmdmaWVsZDEYMBYGA1UE
+ChMPSlJJIFdvcmxkLCBJbmMuMRAwDgYDVQQLEwdPbnRhcmlvMR0wGwYDVQQDExRv
+bnRhcmlvLmpyaXdvcmxkLmNvbTEpMCcGCSqGSIb3DQEJARYaYmlsbGZAb250YXJp
+by5qcml3b3JsZC5jb20wHhcNMDUwNDA3MjI0MTU3WhcNMDYwNDA3MjI0MTU3WjCB
+rDELMAkGA1UEBhMCVVMxETAPBgNVBAgTCFZpcmdpbmlhMRQwEgYDVQQHEwtTcHJp
+bmdmaWxlZDEYMBYGA1UEChMPSlJJIFdvcmxkLCBJbmMuMRAwDgYDVQQLEwdPbnRh
+cmlvMR0wGwYDVQQDExRPbnRhcmlvLmpyaXdvcmxkLmNvbTEpMCcGCSqGSIb3DQEJ
+ARYaYmlsbGZAb250YXJpby5qcml3b3JsZC5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD
+gY0AMIGJAoGBAM81vIgjw0DWAfReVKthdvwe4YP4Z29UU2QZKx/cTt7pJYnW2vnD
+pieGoIyiWr5qW+rmtEFRe1yqarZxU0oGyz2w/1ZlOrhU6vBvsa4JOY6DndSixiRq
+jVpzspNk9iJUA5AcjKQVC7SCgDHeySLyHm/zzNKOlATRge3HMgge/qzbAgMBAAEw
+DQYJKoZIhvcNAQEEBQADgYEAS6MTN6SWlXu24JhNBPjYpwNs/h0HJ+s4uZnQAq49
+pPoRm8omMFx4ilEwuihIUnH0Q9rG6hViiThq6pxRj3gkY8UJ5UaKuXr9yLcfNGf5
+r6iaPTHeiauHVqXeBfY+ZWTWlIl9FNePo8Sc9eYI8s/KuR+dn97iYmTAHC8kOzlY
+gGg=
+-----END CERTIFICATE-----
+            </programlisting>
+    </example>
+    <para>The signed certificate returned by the CA should be written 
+    to domainname.com.crt in the /etc/ssl/apache directory.</para>
+    <para>Configuring Apache to enable SSL for the domain(s) you’re 
+    securing occurs in the httpd.conf on in modern system it may have 
+    been relocated to the modules.d/40_mod_ssl.conf file. To begin, 
+    make a backup of the file. Then, open it in your favorite text 
+    editor.</para>
+    <para>You can add the virtual host domain you’re securing into the 
+    <emphasis>&quot;IfDefine HAVE_SSL&quot;</emphasis> section noted 
+    above. A minimal example entry straight from a default httpd.conf 
+    file is listed below for your reference. You should modify items 
+    such as paths and IP addresses to fit your own environment. The SSL 
+    port is 443 unless you’re specifically adjusting the port to 
+    another port number. This is depicted in 
+    <xref linkend="examp_SSL_Config"/> .</para>
+    <example id="examp_SSL_Config">
+      <title>Sample SSL Config</title>
+      <programlisting>
+
+./modules.d/40_mod_ssl.conf contains:
+
+&lt;IfDefine HAVE_SSL&gt;
+    &lt;IfModule !mod_ssl.c&gt;
+        LoadModule ssl_module   modules/mod_ssl.so
+    &lt;/IfModule&gt;
+&lt;/IfDefine&gt;
+
+&lt;IfModule mod_ssl.c&gt;
+   Listen 0.0.0.0:443
+&lt;IfModule mod_mime.c&gt;
+
+AddType application/x-x509-ca-cert .crt
+AddType application/x-pkcs7-crl    .crl
+
+&lt;/IfModule&gt;
+   SSLPassPhraseDialog  builtin
+   SSLSessionCache         shmcb:/var/cache/httpd/mod_ssl/ssl_scache(512000)
+   SSLSessionCacheTimeout  300
+   SSLMutex default
+   SSLRandomSeed startup /dev/urandom  256
+   SSLRandomSeed connect builtin
+   SSLCryptoDevice builtin
+&lt;/IfModule&gt;
+
+./conf/vhosts.d/99_domainname_com_ssl.conf:
+
+&lt;IfModule mod_ssl.c&gt;
+   &lt;VirtualHost default:443&gt;
+      ServerName www.domainname.com
+      ServerAlias domainname.com
+      ServerAdmin admin@domainname.com
+      ErrorLog logs/ssl_error_domainname_com_log
+      
+      &lt;IfModule mod_log_config.c&gt;
+         TransferLog logs/ssl_access_domainname_com_log
+      &lt;/IfModule&gt;
+
+      SSLEngine on
+      SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
+      SSLProtocol all -SSLv2
+      SSLCertificateFile /etc/ssl/apache/domainname.com.crt
+      SSLCertificateKeyFile /etc/ssl/apache/domainname.com.key
+
+      &lt;FilesMatch “\.(cgi|shtml|phtml|php)$”&gt;
+         SSLOptions +StdEnvVars
+      &lt;/FilesMatch&gt;
+
+      DocumentRoot “/var/www/domainname_com/html”
+      
+      &lt;Directory “/var/www/domainname_com/html”&gt;
+         Options Indexes FollowSymLinks MultiViews
+         AllowOverride None
+         Order allow,deny
+         Allow from all
+      &lt;/Directory&gt;
+
+      ScriptAlias /cgi-bin/ “/var/www/domainname_com/cgi-bin/”
+
+      &lt;Directory “/var/www/domainname_com/cgi-bin”&gt;
+         SSLOptions +StdEnvVars
+         AllowOverride None
+         Options None
+         Order allow,deny
+         Allow from all
+      &lt;/Directory&gt;
+
+      &lt;IfModule mod_setenvif.c&gt;
+         BrowserMatch “.*MSIE.*” nokeepalive ssl-unclean-shutdown \
+                  downgrade-1.0 force-response-1.0
+      &lt;/IfModule&gt;
+      
+      &lt;IfModule mod_log_config.c&gt;
+         CustomLog logs/ssl_request_log \
+             “%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \”%r\” %b”
+      &lt;/IfModule&gt;
+
+      &lt;IfModule mod_rewrite.c&gt;
+         RewriteEngine On
+         RewriteOptions inherit
+      &lt;/IfModule&gt;
+
+   &lt;/VirtualHost&gt;
+
+&lt;/IfModule&gt;
+
+
+            </programlisting>
+    </example>
+    <important>
+      <title>Restart</title>
+      <para>To have these changes take effect, Restart Apache!</para>
+    </important>
+    <para>Now, you must restart Apache to ensure that all your 
+    modifications are enabled. In Redhat based systems type the 
+    following:</para>
+    <screen>
+# service httpd restart
+        </screen>
+    <para>In other system you could use the Apache control command by 
+    typing the following:</para>
+    <screen>
+# /usr/sbin/apachectl -k restart
+        </screen>
+  </section>
+</chapter>
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DOMSynchronizationTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DOMSynchronizationTest.java
new file mode 100644
index 0000000..a7c272b
--- /dev/null
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DOMSynchronizationTest.java
@@ -0,0 +1,118 @@
+package org.eclipse.wst.xml.vex.core.internal.dom;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
+import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXElement;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXNode;
+import org.eclipse.wst.xml.vex.core.internal.dom.Document;
+import org.eclipse.wst.xml.vex.core.tests.VEXCoreTestPlugin;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.w3c.dom.Attr;
+
+import junit.framework.TestCase;
+
+public class DOMSynchronizationTest extends TestCase {
+	private IStructuredDocument loadTestFile()
+			throws UnsupportedEncodingException, IOException {
+		IModelManager modelManager = StructuredModelManager.getModelManager();
+		URL url = VEXCoreTestPlugin.getDefault().getBundle().getEntry(
+				"/projectFiles/SecuringYourApacheServer.xml");
+		IStructuredDocument structuredDocument = null;
+		IStructuredModel model = null;
+		try {
+		model = modelManager.getModelForRead(
+				"SecuringYourApacheServer.xml", url.openStream(), null);
+		structuredDocument = model.getStructuredDocument();
+		} finally {
+			model.releaseFromRead();
+		}
+		return structuredDocument;
+	}
+
+	private IDOMDocument getDOM() throws Exception {
+		IStructuredDocument document = loadTestFile();
+		IDOMModel model = new DOMModelImpl();
+		model.setStructuredDocument(document);
+		IDOMDocument domDocument = model.getDocument();
+		return domDocument;
+	}
+	
+	public void testLoadXML() throws Exception {
+		IStructuredDocument structuredDocument = loadTestFile();
+		assertNotNull("Structured Document was null", structuredDocument);
+	}
+	
+	public void testGetDOMForStructuredDocument() throws Exception {
+		IDOMDocument domDocument = getDOM();
+		assertNotNull("DOM Model not loaded.", domDocument);
+	}
+	
+	public void testDOMtoVEXDocument() throws Exception {
+		org.w3c.dom.Document domDocument = getDOM();
+		VEXDocument vexDocument = new Document(domDocument);
+		assertEquals("DOM's not equal.", domDocument, vexDocument.getDOMDocument());
+	}
+	
+	public void testRootElement() throws Exception {
+		org.w3c.dom.Document domDocument = getDOM();
+		VEXDocument vexDocument = new Document(domDocument);
+		VEXElement rootElement = vexDocument.getRootElement();
+		assertEquals("Root element is incorrect.", "chapter", rootElement.getName());
+		assertEquals("Synchronization in elements incorrect.", rootElement.getName(), domDocument.getDocumentElement().getNodeName());
+		assertEquals("Root element's dom incorrect.", rootElement.getElement(), domDocument.getDocumentElement());
+	}
+	
+	public void testChapterElementAttributes() throws Exception {
+		org.w3c.dom.Document domDocument = getDOM();
+		VEXDocument vexDocument = new Document(domDocument);
+		VEXElement rootElement = vexDocument.getRootElement();
+		
+		EList<String> attributeNameList = rootElement.getAttributeNames();
+		assertEquals("Wrong number of attributes", 1, attributeNameList.size());
+		
+		org.w3c.dom.Element domElement = domDocument.getDocumentElement();
+		for (int cnt = 0; cnt < attributeNameList.size(); cnt++) {
+			String attrName = attributeNameList.get(cnt);
+			Attr domAttr = domElement.getAttributeNode(attrName);
+			assertNotNull("Missing DOM Attribute.", domAttr);
+			assertEquals("Incorrect Attribute Name", attrName, domAttr.getName());
+		}
+	}
+	
+//	public void testChildrenElements() throws Exception {
+//		org.w3c.dom.Document domDocument = getDOM();
+//		VEXDocument vexDocument = new Document(domDocument);
+//		VEXElement rootElement = vexDocument.getRootElement();
+//		assertEquals("Wrong number of children.", 2, rootElement.getChildElements().size());
+//		EList nodeList = rootElement.getChildNodes();
+//		VEXElement chapterElement = (VEXElement) rootElement.getChildNodes().get(0);
+//		assertTrue("No children found.", chapterElement.getChildNodes().size() > 0);
+//	}
+	
+//	public void testTitleElementContent() throws Exception {
+//		org.w3c.dom.Document domDocument = getDOM();
+//		VEXDocument vexDocument = new Document(domDocument);
+//		VEXElement rootElement = vexDocument.getRootElement();
+//		VEXElement chapterElement = rootElement.getChildElements().get(0);
+//		VEXElement titleElement = chapterElement.getChildElements().get(0);
+//		
+//		assertNotNull("Title Element missing.", titleElement);
+//		assertEquals("Wrong element", "title", titleElement.getName());
+//		
+//		int startOffset = titleElement.getStartOffset();
+//		int length = titleElement.getEndOffset() - titleElement.getEndOffset();
+//		assertEquals("Wrong Content", "Securing Your Apache Server with SSL", titleElement.getContent().getString(startOffset, length));
+//	}
+}