bug 253753: namespace-aware Validator interface

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/core/QualifiedNameComparator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/core/QualifiedNameComparator.java
new file mode 100644
index 0000000..97360f7
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/core/QualifiedNameComparator.java
@@ -0,0 +1,25 @@
+/*******************************************************************************

+ * Copyright (c) 2010 Florian Thienel and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * Contributors:

+ * 		Florian Thienel - initial API and implementation

+ *******************************************************************************/

+package org.eclipse.wst.xml.vex.core.internal.core;

+

+import java.util.Comparator;

+

+import org.eclipse.core.runtime.QualifiedName;

+

+/**

+ * @author Florian Thienel

+ */

+public class QualifiedNameComparator implements Comparator<QualifiedName> {

+

+	public int compare(QualifiedName name1, QualifiedName name2) {

+		return name1.toString().compareTo(name2.toString());

+	}

+}

diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/BackgroundImageProperty.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/BackgroundImageProperty.java
index e5946c2..c79e12b 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/BackgroundImageProperty.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/BackgroundImageProperty.java
@@ -24,24 +24,28 @@
 public class BackgroundImageProperty extends AbstractProperty {

 

 	public static final String DEFAULT = null;

-	

+

 	public BackgroundImageProperty() {

 		super(CSS.BACKGROUND_IMAGE);

 	}

 

-	public Object calculate(final LexicalUnit lexicalUnit, final Styles parentStyles, final Styles styles, Element element) {

+	public Object calculate(final LexicalUnit lexicalUnit, final Styles parentStyles, final Styles styles, final Element element) {

 		if (lexicalUnit == null)

 			return DEFAULT;

 		switch (lexicalUnit.getLexicalUnitType()) {

 		case LexicalUnit.SAC_STRING_VALUE:

 			return lexicalUnit.getStringValue();

 		case LexicalUnit.SAC_ATTR:

-			final String attributeValue = element.getAttribute(lexicalUnit.getStringValue());

+			final String attributeValue = element.getAttributeValue(lexicalUnit.getStringValue());

 			if (attributeValue != null)

 				return attributeValue;

 			return DEFAULT;

 		default:

-			VEXCorePlugin.getInstance().getLog().log(new Status(IStatus.WARNING, VEXCorePlugin.ID, MessageFormat.format("Unsupported lexical unit type in ''background-image: {0}'' (type: {1})", lexicalUnit.toString(), lexicalUnit.getLexicalUnitType())));

+			VEXCorePlugin

+					.getInstance()

+					.getLog()

+					.log(new Status(IStatus.WARNING, VEXCorePlugin.ID, MessageFormat.format(

+							"Unsupported lexical unit type in ''background-image: {0}'' (type: {1})", lexicalUnit.toString(), lexicalUnit.getLexicalUnitType())));

 			return DEFAULT;

 		}

 	}

diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/LengthProperty.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/LengthProperty.java
index 5d752d6..bf76a38 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/LengthProperty.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/LengthProperty.java
@@ -51,23 +51,22 @@
 			return RelativeLength.createAbsolute(0);
 	}
 
-	
 	private static boolean isAttr(final LexicalUnit lexicalUnit) {
 		return lexicalUnit != null && lexicalUnit.getLexicalUnitType() == LexicalUnit.SAC_ATTR;
 	}
-	
-	private static LexicalUnit parseAttribute(final LexicalUnit lexicalUnit, Element element) {
+
+	private static LexicalUnit parseAttribute(final LexicalUnit lexicalUnit, final Element element) {
 		final String attributeName = lexicalUnit.getStringValue();
-		String attribute = element.getAttribute(attributeName);
-		if (attribute == null || "".equals(attribute.trim()))
+		final String attributeValue = element.getAttributeValue(attributeName);
+		if (attributeValue == null)
 			return null;
 		final Parser parser = StyleSheetReader.createParser();
 		try {
-			return parser.parsePropertyValue(new InputSource(new StringReader(attribute)));
-		} catch (CSSException e) {
+			return parser.parsePropertyValue(new InputSource(new StringReader(attributeValue)));
+		} catch (final CSSException e) {
 			VEXCorePlugin.getInstance().getLog().log(new Status(IStatus.ERROR, VEXCorePlugin.ID, e.getMessage(), e));
 			return null;
-		} catch (IOException e) {
+		} catch (final IOException e) {
 			VEXCorePlugin.getInstance().getLog().log(new Status(IStatus.ERROR, VEXCorePlugin.ID, e.getMessage(), e));
 			return null;
 		}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/Rule.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/Rule.java
index 30cc2fb..cfd81e0 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/Rule.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/Rule.java
@@ -55,7 +55,7 @@
 	 * @param selector
 	 *            Selector for the rule.
 	 */
-	public Rule(Selector selector) {
+	public Rule(final Selector selector) {
 		this.selector = selector;
 	}
 
@@ -65,7 +65,7 @@
 	 * @param decl
 	 *            new property declaration to add
 	 */
-	public void add(PropertyDecl decl) {
+	public void add(final PropertyDecl decl) {
 		propertyDecls.add(decl);
 	}
 
@@ -73,15 +73,14 @@
 	 * Returns the selector for the rule.
 	 */
 	public Selector getSelector() {
-		return this.selector;
+		return selector;
 	}
 
 	/**
 	 * Returns an array of the property declarations in this rule.
 	 */
 	public PropertyDecl[] getPropertyDecls() {
-		return this.propertyDecls
-				.toArray(new PropertyDecl[propertyDecls.size()]);
+		return propertyDecls.toArray(new PropertyDecl[propertyDecls.size()]);
 	}
 
 	/**
@@ -92,7 +91,7 @@
 	 * Composite selectors result in a recursive call.
 	 */
 	public int getSpecificity() {
-		return specificity(this.getSelector());
+		return specificity(getSelector());
 	}
 
 	/**
@@ -101,8 +100,8 @@
 	 * @param element
 	 *            Element to check.
 	 */
-	public boolean matches(Element element) {
-		return matches(this.selector, element);
+	public boolean matches(final Element element) {
+		return matches(selector, element);
 	}
 
 	// ==================================================== PRIVATE
@@ -110,17 +109,16 @@
 	/**
 	 * Returns true if the given element matches the given selector.
 	 */
-	private static boolean matches(Selector selector, Element element) {
+	private static boolean matches(final Selector selector, final Element element) {
 
-		if (element == null) {
+		if (element == null)
 			// This can happen when, e.g., with the rule "foo > *".
 			// Since the root element matches the "*", we check if
 			// its parent matches "foo", but of course its parent
 			// is null
 			return false;
-		}
 
-		int selectorType = selector.getSelectorType();
+		final int selectorType = selector.getSelectorType();
 
 		switch (selectorType) {
 
@@ -135,59 +133,46 @@
 			// spec an the Flute parser. CSS treats pseudo-elements as elements
 			// attached to their parents, while Flute treats them like
 			// attributes
-			ConditionalSelector cs = (ConditionalSelector) selector;
+			final ConditionalSelector cs = (ConditionalSelector) selector;
 			if (cs.getCondition().getConditionType() == Condition.SAC_PSEUDO_CLASS_CONDITION) {
 				if (element instanceof PseudoElement) {
-					AttributeCondition ac = (AttributeCondition) cs
-							.getCondition();
-					return ac.getValue().equals(element.getLocalName())
-							&& matches(cs.getSimpleSelector(), element
-									.getParent());
-				} else {
+					final AttributeCondition ac = (AttributeCondition) cs.getCondition();
+					return ac.getValue().equals(element.getLocalName()) && matches(cs.getSimpleSelector(), element.getParent());
+				} else
 					return false;
-				}
-			} else {
-				return matches(cs.getSimpleSelector(), element)
-						&& matchesCondition(cs.getCondition(), element);
-			}
+			} else
+				return matches(cs.getSimpleSelector(), element) && matchesCondition(cs.getCondition(), element);
 
 		case Selector.SAC_ELEMENT_NODE_SELECTOR:
-			String elementName = element.getLocalName();
-			String selectorName = ((ElementSelector) selector).getLocalName();
-			if (selectorName == null) {
+			final String elementName = element.getLocalName();
+			final String selectorName = ((ElementSelector) selector).getLocalName();
+			if (selectorName == null)
 				// We land here if we have a wildcard selector (*) or
 				// a pseudocondition w/o an element name (:before)
 				// Probably other situations too (conditional w/o element
 				// name? e.g. [attr=value])
 				return true;
-			}
-			if (selectorName.equals(elementName)) {
+			if (selectorName.equals(elementName))
 				return true;
-			}
 			break;
 
 		case Selector.SAC_DESCENDANT_SELECTOR:
-			DescendantSelector ds = (DescendantSelector) selector;
-			return matches(ds.getSimpleSelector(), element)
-					&& matchesAncestor(ds.getAncestorSelector(), element
-							.getParent());
+			final DescendantSelector ds = (DescendantSelector) selector;
+			return matches(ds.getSimpleSelector(), element) && matchesAncestor(ds.getAncestorSelector(), element.getParent());
 
 		case Selector.SAC_CHILD_SELECTOR:
-			DescendantSelector ds2 = (DescendantSelector) selector;
+			final DescendantSelector ds2 = (DescendantSelector) selector;
 			Element parent = element.getParent();
-			if (element instanceof PseudoElement) {
+			if (element instanceof PseudoElement)
 				parent = parent.getParent(); // sigh - this looks inelegant, but
 												// whatcha gonna do?
-			}
-			return matches(ds2.getSimpleSelector(), element)
-					&& matches(ds2.getAncestorSelector(), parent);
+			return matches(ds2.getSimpleSelector(), element) && matches(ds2.getAncestorSelector(), parent);
 
 		case Selector.SAC_DIRECT_ADJACENT_SELECTOR:
 
-			SiblingSelector ss = (SiblingSelector) selector;
+			final SiblingSelector ss = (SiblingSelector) selector;
 
-			if (element != null && element.getParent() != null
-					&& matches(ss.getSiblingSelector(), element)) {
+			if (element != null && element.getParent() != null && matches(ss.getSiblingSelector(), element)) {
 
 				// find next sibling
 				final Iterator<Element> i = element.getParent().getChildElements().iterator();
@@ -198,9 +183,8 @@
 					e = i.next();
 				}
 
-				if (e == element) {
+				if (e == element)
 					return matches(ss.getSelector(), f);
-				}
 			}
 			return false;
 
@@ -215,20 +199,19 @@
 	 * Returns true if some ancestor of the given element matches the given
 	 * selector.
 	 */
-	private static boolean matchesAncestor(Selector selector, Element element) {
+	private static boolean matchesAncestor(final Selector selector, final Element element) {
 		Element e = element;
 		while (e != null) {
-			if (matches(selector, e)) {
+			if (matches(selector, e))
 				return true;
-			}
 			e = e.getParent();
 		}
 		return false;
 	}
 
-	private static boolean matchesCondition(Condition condition, Element element) {
+	private static boolean matchesCondition(final Condition condition, final Element element) {
 
-		AttributeCondition acon;
+		AttributeCondition attributeCondition;
 		String attributeName;
 		String value;
 
@@ -237,46 +220,39 @@
 			return false;
 
 		case Condition.SAC_ATTRIBUTE_CONDITION:
-			acon = (AttributeCondition) condition;
-			value = element.getAttribute(acon.getLocalName());
-			if (acon.getValue() != null) {
-				return acon.getValue().equals(value);
-			} else {
+			attributeCondition = (AttributeCondition) condition;
+			value = element.getAttributeValue(attributeCondition.getLocalName());
+			if (attributeCondition.getValue() != null)
+				return attributeCondition.getValue().equals(value);
+			else
 				return value != null;
-			}
 
 		case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
 		case Condition.SAC_CLASS_CONDITION:
 
-			acon = (AttributeCondition) condition;
+			attributeCondition = (AttributeCondition) condition;
 
-			if (condition.getConditionType() == Condition.SAC_CLASS_CONDITION) {
+			if (condition.getConditionType() == Condition.SAC_CLASS_CONDITION)
 				attributeName = "class";
-			} else {
-				attributeName = acon.getLocalName();
-			}
+			else
+				attributeName = attributeCondition.getLocalName();
 
-			value = element.getAttribute(attributeName);
-			if (value == null) {
+			value = element.getAttributeValue(attributeName);
+			if (value == null)
 				return false;
-			}
-			StringTokenizer st = new StringTokenizer(value);
-			while (st.hasMoreTokens()) {
-				if (st.nextToken().equals(acon.getValue())) {
+			final StringTokenizer st = new StringTokenizer(value);
+			while (st.hasMoreTokens())
+				if (st.nextToken().equals(attributeCondition.getValue()))
 					return true;
-				}
-			}
 			return false;
 
 		case Condition.SAC_AND_CONDITION:
-			CombinatorCondition ccon = (CombinatorCondition) condition;
-			return matchesCondition(ccon.getFirstCondition(), element)
-					&& matchesCondition(ccon.getSecondCondition(), element);
+			final CombinatorCondition ccon = (CombinatorCondition) condition;
+			return matchesCondition(ccon.getFirstCondition(), element) && matchesCondition(ccon.getSecondCondition(), element);
 
 		default:
 			// TODO: warning: condition not supported
-			System.out.println("Unsupported condition type: "
-					+ condition.getConditionType());
+			System.out.println("Unsupported condition type: " + condition.getConditionType());
 		}
 		return false;
 	}
@@ -284,50 +260,42 @@
 	/**
 	 * Calculates the specificity for a selector.
 	 */
-	private static int specificity(Selector sel) {
+	private static int specificity(final Selector sel) {
 		if (sel instanceof ElementSelector) {
-			if (((ElementSelector) sel).getLocalName() == null) {
+			if (((ElementSelector) sel).getLocalName() == null)
 				// actually wildcard selector -- see comment in matches()
 				return 0;
-			} else {
+			else
 				return 1;
-			}
 		} else if (sel instanceof DescendantSelector) {
-			DescendantSelector ds = (DescendantSelector) sel;
-			return specificity(ds.getAncestorSelector())
-					+ specificity(ds.getSimpleSelector());
+			final DescendantSelector ds = (DescendantSelector) sel;
+			return specificity(ds.getAncestorSelector()) + specificity(ds.getSimpleSelector());
 		} else if (sel instanceof SiblingSelector) {
-			SiblingSelector ss = (SiblingSelector) sel;
-			return specificity(ss.getSelector())
-					+ specificity(ss.getSiblingSelector());
+			final SiblingSelector ss = (SiblingSelector) sel;
+			return specificity(ss.getSelector()) + specificity(ss.getSiblingSelector());
 		} else if (sel instanceof NegativeSelector) {
-			NegativeSelector ns = (NegativeSelector) sel;
+			final NegativeSelector ns = (NegativeSelector) sel;
 			return specificity(ns.getSimpleSelector());
 		} else if (sel instanceof ConditionalSelector) {
-			ConditionalSelector cs = (ConditionalSelector) sel;
-			return specificity(cs.getCondition())
-					+ specificity(cs.getSimpleSelector());
-		} else {
+			final ConditionalSelector cs = (ConditionalSelector) sel;
+			return specificity(cs.getCondition()) + specificity(cs.getSimpleSelector());
+		} else
 			return 0;
-		}
 	}
 
 	/**
 	 * Calculates the specificity for a condition.
 	 */
-	private static int specificity(Condition cond) {
+	private static int specificity(final Condition cond) {
 		if (cond instanceof CombinatorCondition) {
-			CombinatorCondition cc = (CombinatorCondition) cond;
-			return specificity(cc.getFirstCondition())
-					+ specificity(cc.getSecondCondition());
+			final CombinatorCondition cc = (CombinatorCondition) cond;
+			return specificity(cc.getFirstCondition()) + specificity(cc.getSecondCondition());
 		} else if (cond instanceof AttributeCondition) {
-			if (cond.getConditionType() == Condition.SAC_ID_CONDITION) {
+			if (cond.getConditionType() == Condition.SAC_ID_CONDITION)
 				return 1000000;
-			} else {
+			else
 				return 1000;
-			}
-		} else {
+		} else
 			return 0;
-		}
 	}
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
index 87fa002..071ab96 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
@@ -218,37 +218,37 @@
 
 		Map<String, LexicalUnit> decls = getApplicableDeclarations(element);
 
-		LexicalUnit lu;
+		LexicalUnit lexicalUnit;
 
 		// If we're finding a pseudo-element, look at the 'content' property
 		// first, since most of the time it'll be empty and we'll return null.
 		if (element instanceof PseudoElement) {
-			lu = decls.get(CSS.CONTENT);
-			if (lu == null)
+			lexicalUnit = decls.get(CSS.CONTENT);
+			if (lexicalUnit == null)
 				return null;
 
 			List<String> content = new ArrayList<String>();
-			while (lu != null) {
-				switch (lu.getLexicalUnitType()) {
+			while (lexicalUnit != null) {
+				switch (lexicalUnit.getLexicalUnitType()) {
 				case LexicalUnit.SAC_STRING_VALUE :
 					// content: "A String"
-					content.add(lu.getStringValue());
+					content.add(lexicalUnit.getStringValue());
 					break;
 				case LexicalUnit.SAC_ATTR :
 					// content: attr(attributeName)
-					final String attributeValue = element.getParent().getAttribute(lu.getStringValue());
+					final String attributeValue = element.getParent().getAttributeValue(lexicalUnit.getStringValue());
 					if (attributeValue != null)
 						content.add(attributeValue);
 					break;
 				}
-				lu = lu.getNextLexicalUnit();
+				lexicalUnit = lexicalUnit.getNextLexicalUnit();
 			}
 			styles.setContent(content);
 		}
 
 		for (final IProperty property : CSS_PROPERTIES) {
-			lu = decls.get(property.getName());
-			final Object value = property.calculate(lu, parentStyles, styles, element);
+			lexicalUnit = decls.get(property.getName());
+			final Object value = property.calculate(lexicalUnit, parentStyles, styles, element);
 			styles.put(property.getName(), value);
 		}
 
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Attribute.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Attribute.java
index 8702100..1def704 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Attribute.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Attribute.java
@@ -14,10 +14,11 @@
 

 /**

  * An immutable representation of an attribute within the start tag of an element.

+ * The attribute is Comparable by its qualified name.

  *  

  * @author Florian Thienel

  */

-public class Attribute {

+public class Attribute implements Comparable<Attribute> {

 	

 	private final Element parent;

 	

@@ -60,4 +61,14 @@
 	public String getPrefixedName() {

 		return getLocalName();

 	}

+

+	/**

+	 * Compares two attributes by their name.

+	 * 

+	 * @param otherAttribute the other attribute

+	 * @see Comparable

+	 */

+	public int compareTo(Attribute otherAttribute) {

+		return name.toString().compareTo(otherAttribute.name.toString());

+	}

 }

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 d460252..2d28242 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
@@ -12,9 +12,11 @@
 package org.eclipse.wst.xml.vex.core.internal.dom;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.core.ListenerList;
 import org.eclipse.wst.xml.vex.core.internal.undo.CannotRedoException;
 import org.eclipse.wst.xml.vex.core.internal.undo.CannotUndoException;
@@ -26,16 +28,15 @@
  */
 public class Document {
 
-	private Content content;
-	private RootElement rootElement;
-	private ListenerList<DocumentListener, DocumentEvent> listeners =
-		new ListenerList<DocumentListener, DocumentEvent>(DocumentListener.class);
+	private final Content content;
+	private final RootElement rootElement;
+	private final ListenerList<DocumentListener, DocumentEvent> listeners = new ListenerList<DocumentListener, DocumentEvent>(DocumentListener.class);
 	private boolean undoEnabled = true;
 
 	private String publicID;
 	protected String systemID;
 	private String documentURI;
-	
+
 	private String encoding;
 	private Validator validator;
 
@@ -47,7 +48,7 @@
 	 *            RootElement is set by this constructor.
 	 * 
 	 */
-	public Document(RootElement rootElement) {
+	public Document(final RootElement rootElement) {
 		content = new GapContent(100);
 		content.insertString(0, "\0\0");
 
@@ -55,7 +56,7 @@
 		rootElement.setDocument(this);
 		rootElement.setContent(content, 0, 1);
 	}
-	
+
 	/**
 	 * Class constructor. This constructor is used by the document builder and
 	 * assumes that the content and root element have bee properly set up.
@@ -66,283 +67,230 @@
 	 *            RootElement of the document.
 	 * 
 	 */
-	public Document(Content content, RootElement rootElement) {
+	public Document(final Content content, final RootElement rootElement) {
 		this.content = content;
 		this.rootElement = rootElement;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#addDocumentListener(org.eclipse.wst.xml.vex.core.internal.dom.DocumentListener)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#addDocumentListener
+	 * (org.eclipse.wst.xml.vex.core.internal.dom.DocumentListener)
 	 */
-	public void addDocumentListener(DocumentListener listener) {
-		this.listeners.add(listener);
+	public void addDocumentListener(final DocumentListener listener) {
+		listeners.add(listener);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#canInsertFragment(int, org.eclipse.wst.xml.vex.core.internal.dom.DocumentFragment)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#canInsertFragment
+	 * (int, org.eclipse.wst.xml.vex.core.internal.dom.DocumentFragment)
 	 */
-	public boolean canInsertFragment(int offset, DocumentFragment fragment) {
-		if (this.validator == null)
+	public boolean canInsertFragment(final int offset, final DocumentFragment fragment) {
+		if (validator == null)
 			return true;
 
-		Element element = getElementAt(offset);
-		List<String> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
-		List<String> seq2 = fragment.getNodeNames();
-		List<String> seq3 = getNodeNames(offset, element.getEndOffset());
-		
-		return this.validator.isValidSequence(element.getName(), seq1, seq2,
-				seq3, true);
+		final Element element = getElementAt(offset);
+		final List<QualifiedName> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
+		final List<QualifiedName> seq2 = fragment.getNodeNames();
+		final List<QualifiedName> seq3 = getNodeNames(offset, element.getEndOffset());
+
+		return validator.isValidSequence(element.getQualifiedName(), seq1, seq2, seq3, true);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#canInsertText(int)
-	 * 
-	 */
-	public boolean canInsertText(int offset) {
-		if (this.validator == null) 
+	public boolean canInsertText(final int offset) {
+		if (validator == null)
 			return true;
 
-		Element element = getElementAt(offset);
-		List<String> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
+		final Element element = getElementAt(offset);
+		final List<QualifiedName> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
+		final List<QualifiedName> seq2 = Collections.singletonList(Validator.PCDATA);
+		final List<QualifiedName> seq3 = getNodeNames(offset, element.getEndOffset());
 
-		List<String> seq2 = new ArrayList<String>();
-		seq2.add("#PCDATA");
-		
-		List<String> seq3 = getNodeNames(offset, element.getEndOffset());
-
-		return this.validator.isValidSequence(element.getName(), seq1, seq2,
-				seq3, true);
+		return validator.isValidSequence(element.getQualifiedName(), seq1, seq2, seq3, true);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#createPosition(int)
-	 * 
-	 */
-	public Position createPosition(int offset) {
-		return this.content.createPosition(offset);
+	public Position createPosition(final int offset) {
+		return content.createPosition(offset);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#delete(int, int)
-	 * 
-	 */
-	public void delete(int startOffset, int endOffset)
-			throws DocumentValidationException {
+	public void delete(final int startOffset, final int endOffset) throws DocumentValidationException {
 
-		Element e1 = this.getElementAt(startOffset);
-		Element e2 = this.getElementAt(endOffset);
-		if (e1 != e2) 
-			throw new IllegalArgumentException("Deletion from " + startOffset
-					+ " to " + endOffset + " is unbalanced");
-		
+		final Element e1 = getElementAt(startOffset);
+		final Element e2 = getElementAt(endOffset);
+		if (e1 != e2)
+			throw new IllegalArgumentException("Deletion from " + startOffset + " to " + endOffset + " is unbalanced");
 
-		Validator validator = this.getValidator();
+		final Validator validator = getValidator();
 		if (validator != null) {
-			List<String> seq1 = this.getNodeNames(e1.getStartOffset() + 1,
-					startOffset);
+			final List<QualifiedName> seq1 = getNodeNames(e1.getStartOffset() + 1, startOffset);
+			final List<QualifiedName> seq2 = getNodeNames(endOffset, e1.getEndOffset());
 
-			List<String> seq2 = this.getNodeNames(endOffset, e1.getEndOffset());
-
-			if (!validator
-					.isValidSequence(e1.getName(), seq1, seq2, null, true)) {
-				throw new DocumentValidationException("Unable to delete from "
-						+ startOffset + " to " + endOffset);
-			}
+			if (!validator.isValidSequence(e1.getQualifiedName(), seq1, seq2, null, true))
+				throw new DocumentValidationException("Unable to delete from " + startOffset + " to " + endOffset);
 		}
 
 		// Grab the fragment for the undoable edit while it's still here
-		DocumentFragment frag = getFragment(startOffset, endOffset);
+		final DocumentFragment frag = getFragment(startOffset, endOffset);
 
-		this.fireBeforeContentDeleted(new DocumentEvent(this, e1, startOffset,
-				endOffset - startOffset, null));
+		fireBeforeContentDeleted(new DocumentEvent(this, e1, startOffset, endOffset - startOffset, null));
 
 		Iterator<Node> iter = e1.getChildNodes().iterator();
-		if (e1 instanceof Element) {
-			iter = ((Element) e1).getChildIterator();
-		}
+		if (e1 instanceof Element)
+			iter = (e1).getChildIterator();
 		while (iter.hasNext()) {
-			Node child = (Node) iter.next();
-			if (startOffset <= child.getStartOffset()
-					&& child.getEndOffset() < endOffset) {
+			final Node child = iter.next();
+			if (startOffset <= child.getStartOffset() && child.getEndOffset() < endOffset)
 				iter.remove();
-			}
 		}
 
-		this.content.remove(startOffset, endOffset - startOffset);
+		content.remove(startOffset, endOffset - startOffset);
 
-		IUndoableEdit edit = this.undoEnabled ? new DeleteEdit(startOffset,
-				endOffset, frag) : null;
+		final IUndoableEdit edit = undoEnabled ? new DeleteEdit(startOffset, endOffset, frag) : null;
 
-		this.fireContentDeleted(new DocumentEvent(this, e1, startOffset,
-				endOffset - startOffset, edit));
+		fireContentDeleted(new DocumentEvent(this, e1, startOffset, endOffset - startOffset, edit));
 	}
 
-	public Element findCommonElement(int offset1, int offset2) {
-		Element element = this.rootElement;
+	public Element findCommonElement(final int offset1, final int offset2) {
+		Element element = rootElement;
 		for (;;) {
 			boolean tryAgain = false;
-			List<Element> children = element.getChildElements();
-			for (int i = 0; i < children.size(); i++) {
-				if (offset1 > children.get(i).getStartOffset()
-						&& offset2 > children.get(i).getStartOffset()
-						&& offset1 <= children.get(i).getEndOffset()
+			final List<Element> children = element.getChildElements();
+			for (int i = 0; i < children.size(); i++)
+				if (offset1 > children.get(i).getStartOffset() && offset2 > children.get(i).getStartOffset() && offset1 <= children.get(i).getEndOffset()
 						&& offset2 <= children.get(i).getEndOffset()) {
 
 					element = children.get(i);
 					tryAgain = true;
 					break;
 				}
-			}
-			if (!tryAgain) {
+			if (!tryAgain)
 				break;
-			}
 		}
 		return element;
 	}
 
-	public char getCharacterAt(int offset) {
-		return this.content.getString(offset, 1).charAt(0);
+	public char getCharacterAt(final int offset) {
+		return content.getString(offset, 1).charAt(0);
 	}
 
-	public Element getElementAt(int offset) {
-		if (offset < 1 || offset >= this.getLength()) {
-			throw new IllegalArgumentException("Illegal offset: " + offset
-					+ ". Must be between 1 and n-1");
-		}
-		Element element = this.rootElement;
+	public Element getElementAt(final int offset) {
+		if (offset < 1 || offset >= getLength())
+			throw new IllegalArgumentException("Illegal offset: " + offset + ". Must be between 1 and n-1");
+		Element element = rootElement;
 		for (;;) {
 			boolean tryAgain = false;
-			List<Element> children = element.getChildElements();
+			final List<Element> children = element.getChildElements();
 			for (int i = 0; i < children.size(); i++) {
-				Element child = children.get(i);
-				if (offset <= child.getStartOffset()) {
+				final Element child = children.get(i);
+				if (offset <= child.getStartOffset())
 					return element;
-				} else if (offset <= child.getEndOffset()) {
+				else if (offset <= child.getEndOffset()) {
 					element = child;
 					tryAgain = true;
 					break;
 				}
 			}
-			if (!tryAgain) {
+			if (!tryAgain)
 				break;
-			}
 		}
 		return element;
 	}
 
 	public String getEncoding() {
-		return this.encoding;
+		return encoding;
 	}
 
-	public void setEncoding(String encoding) {
+	public void setEncoding(final String encoding) {
 		this.encoding = encoding;
 	}
-	
-	public DocumentFragment getFragment(int startOffset, int endOffset) {
 
-		assertOffset(startOffset, 0, this.content.getLength());
-		assertOffset(endOffset, 0, this.content.getLength());
+	public DocumentFragment getFragment(final int startOffset, final int endOffset) {
 
-		if (endOffset <= startOffset) {
-			throw new IllegalArgumentException("Invalid range (" + startOffset
-					+ ", " + endOffset + ")");
-		}
+		assertOffset(startOffset, 0, content.getLength());
+		assertOffset(endOffset, 0, content.getLength());
 
-		Element e1 = this.getElementAt(startOffset);
-		Element e2 = this.getElementAt(endOffset);
-		if (e1 != e2) {
-			throw new IllegalArgumentException("Fragment from " + startOffset
-					+ " to " + endOffset + " is unbalanced");
-		}
+		if (endOffset <= startOffset)
+			throw new IllegalArgumentException("Invalid range (" + startOffset + ", " + endOffset + ")");
 
-		List<Element> children = e1.getChildElements();
+		final Element e1 = getElementAt(startOffset);
+		final Element e2 = getElementAt(endOffset);
+		if (e1 != e2)
+			throw new IllegalArgumentException("Fragment from " + startOffset + " to " + endOffset + " is unbalanced");
 
-		Content newContent = new GapContent(endOffset - startOffset);
-		String s = content.getString(startOffset, endOffset - startOffset);
+		final List<Element> children = e1.getChildElements();
+
+		final Content newContent = new GapContent(endOffset - startOffset);
+		final String s = content.getString(startOffset, endOffset - startOffset);
 		newContent.insertString(0, s);
-		List<Element> newChildren = new ArrayList<Element>();
+		final List<Element> newChildren = new ArrayList<Element>();
 		for (int i = 0; i < children.size(); i++) {
-			Element child = children.get(i);
-			if (child.getEndOffset() <= startOffset) {
+			final Element child = children.get(i);
+			if (child.getEndOffset() <= startOffset)
 				continue;
-			} else if (child.getStartOffset() >= endOffset) {
+			else if (child.getStartOffset() >= endOffset)
 				break;
-			} else {
-				newChildren.add(cloneElement(child, newContent,
-						-startOffset, null));
-			}
+			else
+				newChildren.add(cloneElement(child, newContent, -startOffset, null));
 		}
 
 		return new DocumentFragment(newContent, newChildren);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getLength()
-	 * 
-	 */
 	public int getLength() {
-		return this.content.getLength();
+		return content.getLength();
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getNodeNames(int, int)
-	 * 
-	 */
-	public List<String> getNodeNames(int startOffset, int endOffset) {
+	public List<QualifiedName> getNodeNames(final int startOffset, final int endOffset) {
 
-		List<Node> nodes = this.getNodes(startOffset, endOffset);
-		List<String> names = new ArrayList<String>(nodes.size());
+		final List<Node> nodes = getNodes(startOffset, endOffset);
+		final List<QualifiedName> names = new ArrayList<QualifiedName>(nodes.size());
 
 		for (int i = 0; i < nodes.size(); i++) {
-			Node node = nodes.get(i);
-			if (node instanceof Element) {
-				names.add(((Element) node).getName());
-			} else {
-				names.add("#PCDATA");
-			}
+			final Node node = nodes.get(i);
+			if (node instanceof Element)
+				names.add(((Element) node).getQualifiedName());
+			else
+				names.add(Validator.PCDATA);
 		}
 
 		return names;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getNodes(int, int)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getNodes(int,
+	 * int)
 	 */
-	public List<Node> getNodes(int startOffset, int endOffset) {
+	public List<Node> getNodes(final int startOffset, final int endOffset) {
 
-		Element element = this.getElementAt(startOffset);
-		if (element != this.getElementAt(endOffset)) {
-			throw new IllegalArgumentException("Offsets are unbalanced: "
-					+ startOffset + " is in " + element.getName() + ", "
-					+ endOffset + " is in "
-					+ this.getElementAt(endOffset).getName());
-		}
+		final Element element = getElementAt(startOffset);
+		if (element != getElementAt(endOffset))
+			throw new IllegalArgumentException("Offsets are unbalanced: " + startOffset + " is in " + element.getName() + ", " + endOffset + " is in "
+					+ getElementAt(endOffset).getName());
 
-		List<Node> list = new ArrayList<Node>();
-		List<Node> nodes = element.getChildNodes();
+		final List<Node> list = new ArrayList<Node>();
+		final List<Node> nodes = element.getChildNodes();
 		for (int i = 0; i < nodes.size(); i++) {
-			Node node = nodes.get(i);
-			if (node.getEndOffset() <= startOffset) {
+			final Node node = nodes.get(i);
+			if (node.getEndOffset() <= startOffset)
 				continue;
-			} else if (node.getStartOffset() >= endOffset) {
+			else if (node.getStartOffset() >= endOffset)
 				break;
-			} else {
-				if (node instanceof Element) {
-					list.add(node);
-				} else {
-					Text text = (Text) node;
-					if (text.getStartOffset() < startOffset) {
-						text.setContent(text.getContent(), startOffset, text
-								.getEndOffset());
-					} else if (text.getEndOffset() > endOffset) {
-						text.setContent(text.getContent(), text
-								.getStartOffset(), endOffset);
-					}
-					list.add(text);
-				}
+			else if (node instanceof Element)
+				list.add(node);
+			else {
+				final Text text = (Text) node;
+				if (text.getStartOffset() < startOffset)
+					text.setContent(text.getContent(), startOffset, text.getEndOffset());
+				else if (text.getEndOffset() > endOffset)
+					text.setContent(text.getContent(), text.getStartOffset(), endOffset);
+				list.add(text);
 			}
 		}
 
@@ -363,123 +311,93 @@
 	 * @param elements
 	 *            child elements that are within the run
 	 */
-	static List<Node> createNodeList(Content content, int startOffset,
-			int endOffset, List<Node> elements) {
+	static List<Node> createNodeList(final Content content, final int startOffset, final int endOffset, final List<Node> elements) {
 
-		List<Node> nodes = new ArrayList<Node>();
+		final List<Node> nodes = new ArrayList<Node>();
 		int offset = startOffset;
 		for (int i = 0; i < elements.size(); i++) {
-			int start = elements.get(i).getStartOffset();
-			if (offset < start) {
+			final int start = elements.get(i).getStartOffset();
+			if (offset < start)
 				nodes.add(new Text(content, offset, start));
-			}
 			nodes.add(elements.get(i));
 			offset = elements.get(i).getEndOffset() + 1;
 		}
 
-		if (offset < endOffset) {
+		if (offset < endOffset)
 			nodes.add(new Text(content, offset, endOffset));
-		}
 
 		return nodes;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getPublicID()
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getPublicID()
 	 */
 	public String getPublicID() {
-		return this.publicID;
+		return publicID;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getRawText(int, int)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getRawText(int,
+	 * int)
 	 */
-	public String getRawText(int startOffset, int endOffset) {
-		return this.content.getString(startOffset, endOffset - startOffset);
+	public String getRawText(final int startOffset, final int endOffset) {
+		return content.getString(startOffset, endOffset - startOffset);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getRootElement()
-	 * 
-	 */
 	public Element getRootElement() {
 		return rootElement;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getSystemID()
-	 * 
-	 */
 	public String getSystemID() {
 		return systemID;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getText(int, int)
-	 * 
-	 */
-	public String getText(int startOffset, int endOffset) {
-		String raw = this.content.getString(startOffset, endOffset
-				- startOffset);
-		StringBuffer sb = new StringBuffer(raw.length());
+	public String getText(final int startOffset, final int endOffset) {
+		final String raw = content.getString(startOffset, endOffset - startOffset);
+		final StringBuffer sb = new StringBuffer(raw.length());
 		for (int i = 0; i < raw.length(); i++) {
-			char c = raw.charAt(i);
-			if (c != '\0') {
+			final char c = raw.charAt(i);
+			if (c != '\0')
 				sb.append(c);
-			}
 		}
 		return sb.toString();
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#getValidator()
-	 * 
-	 */
 	public Validator getValidator() {
-		return this.validator;
+		return validator;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#insertElement(int, org.eclipse.wst.xml.vex.core.internal.dom.Element)
-	 * 
-	 */
-	public void insertElement(int offset, Element element)
-			throws DocumentValidationException {
+	public void insertElement(final int offset, final Element element) throws DocumentValidationException {
 
-		if (offset < 1 || offset >= this.getLength()) {
-			throw new IllegalArgumentException("Error inserting element <"
-					+ element.getName() + ">: offset is " + offset
-					+ ", but it must be between 1 and "
-					+ (this.getLength() - 1));
-		}
+		if (offset < 1 || offset >= getLength())
+			throw new IllegalArgumentException("Error inserting element <" + element.getName() + ">: offset is " + offset + ", but it must be between 1 and "
+					+ (getLength() - 1));
 
-		Validator validator = this.getValidator();
+		final Validator validator = getValidator();
 		if (validator != null) {
-			Element parent = this.getElementAt(offset);
-			List<String> seq1 = this.getNodeNames(parent.getStartOffset() + 1,
-					offset);
-			List<String> seq2 = new ArrayList<String>();
-			seq2.add(element.getName());
-			List<String> seq3 = this.getNodeNames(offset, parent.getEndOffset());
+			final Element parent = getElementAt(offset);
+			final List<QualifiedName> seq1 = getNodeNames(parent.getStartOffset() + 1, offset);
+			final List<QualifiedName> seq2 = Collections.singletonList(element.getQualifiedName());
+			final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
 
-			if (!validator.isValidSequence(parent.getName(), seq1, seq2, seq3,
-					true)) {
-				throw new DocumentValidationException("Cannot insert element "
-						+ element.getName() + " at offset " + offset);
-			}
+			if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true))
+				throw new DocumentValidationException("Cannot insert element " + element.getName() + " at offset " + offset);
 		}
 
 		// find the parent, and the index into its children at which
 		// this element should be inserted
-		Element parent = this.rootElement;
+		Element parent = rootElement;
 		int childIndex = -1;
 		while (childIndex == -1) {
 			boolean tryAgain = false;
-			List<Element> children = parent.getChildElements();
+			final List<Element> children = parent.getChildElements();
 			for (int i = 0; i < children.size(); i++) {
-				Element child = children.get(i);
+				final Element child = children.get(i);
 				if (offset <= child.getStartOffset()) {
 					childIndex = i;
 					break;
@@ -495,190 +413,164 @@
 			}
 		}
 
-		this.fireBeforeContentInserted(new DocumentEvent(this, parent, offset,
-				2, null));
+		fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
 
-		this.content.insertString(offset, "\0\0");
+		content.insertString(offset, "\0\0");
 
-		element.setContent(this.content, offset, offset + 1);
+		element.setContent(content, offset, offset + 1);
 		element.setParent(parent);
 		parent.insertChild(childIndex, element);
 
-		IUndoableEdit edit = this.undoEnabled ? new InsertElementEdit(offset,
-				element) : null;
+		final IUndoableEdit edit = undoEnabled ? new InsertElementEdit(offset, element) : null;
 
-		this.fireContentInserted(new DocumentEvent(this, parent, offset, 2,
-				edit));
+		fireContentInserted(new DocumentEvent(this, parent, offset, 2, edit));
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#insertFragment(int, org.eclipse.wst.xml.vex.core.internal.dom.DocumentFragment)
-	 * 
-	 */
-	public void insertFragment(int offset, DocumentFragment fragment)
-			throws DocumentValidationException {
+	public void insertFragment(final int offset, final DocumentFragment fragment) throws DocumentValidationException {
 
-		if (offset < 1 || offset >= this.getLength()) {
-			throw new IllegalArgumentException(
-					"Error inserting document fragment");
+		if (offset < 1 || offset >= getLength())
+			throw new IllegalArgumentException("Error inserting document fragment");
+
+		final Element parent = getElementAt(offset);
+
+		if (validator != null) {
+			final List<QualifiedName> seq1 = getNodeNames(parent.getStartOffset() + 1, offset);
+			final List<QualifiedName> seq2 = fragment.getNodeNames();
+			final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
+
+			if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true))
+				throw new DocumentValidationException("Cannot insert document fragment");
 		}
 
-		Element parent = this.getElementAt(offset);
+		fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
 
-		if (this.validator != null) {
-			List<String> seq1 = this.getNodeNames(parent.getStartOffset() + 1,
-					offset);
-			
-			List<String> seq2 = fragment.getNodeNames();
-			List<String> seq3 = this.getNodeNames(offset, parent.getEndOffset());
-			
-			if (!validator.isValidSequence(parent.getName(), seq1, seq2, seq3,
-					true)) {
+		final Content c = fragment.getContent();
+		final String s = c.getString(0, c.getLength());
+		content.insertString(offset, s);
 
-				throw new DocumentValidationException(
-						"Cannot insert document fragment");
-			}
-		}
-
-		this.fireBeforeContentInserted(new DocumentEvent(this, parent, offset,
-				2, null));
-
-		Content c = fragment.getContent();
-		String s = c.getString(0, c.getLength());
-		this.content.insertString(offset, s);
-
-		List<Element> children = parent.getChildElements();
+		final List<Element> children = parent.getChildElements();
 		int index = 0;
-		while (index < children.size()
-				&& children.get(index).getEndOffset() < offset) {
+		while (index < children.size() && children.get(index).getEndOffset() < offset)
 			index++;
-		}
 
-		List<Element> elements = fragment.getElements();
+		final List<Element> elements = fragment.getElements();
 		for (int i = 0; i < elements.size(); i++) {
-			Element newElement = this.cloneElement(elements.get(i), this.content,
-					offset, parent);
+			final Element newElement = cloneElement(elements.get(i), content, offset, parent);
 			parent.insertChild(index, newElement);
 			index++;
 		}
 
-		IUndoableEdit edit = this.undoEnabled ? new InsertFragmentEdit(offset,
-				fragment) : null;
+		final IUndoableEdit edit = undoEnabled ? new InsertFragmentEdit(offset, fragment) : null;
 
-		this.fireContentInserted(new DocumentEvent(this, parent, offset,
-				fragment.getContent().getLength(), edit));
+		fireContentInserted(new DocumentEvent(this, parent, offset, fragment.getContent().getLength(), edit));
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#insertText(int, java.lang.String)
-	 * 
-	 */
-	public void insertText(int offset, String text)
-			throws DocumentValidationException {
+	public void insertText(final int offset, final String text) throws DocumentValidationException {
 
-		if (offset < 1 || offset >= this.getLength()) {
-			throw new IllegalArgumentException(
-					"Offset must be between 1 and n-1");
-		}
+		if (offset < 1 || offset >= getLength())
+			throw new IllegalArgumentException("Offset must be between 1 and n-1");
 
-		Element parent = this.getElementAt(offset);
+		final Element parent = getElementAt(offset);
 
 		boolean isValid = false;
-		if (this.getCharacterAt(offset - 1) != '\0') {
+		if (getCharacterAt(offset - 1) != '\0')
 			isValid = true;
-		} else if (this.getCharacterAt(offset) != '\0') {
+		else if (getCharacterAt(offset) != '\0')
 			isValid = true;
-		} else {
-			Validator validator = this.getValidator();
+		else {
+			final Validator validator = getValidator();
 			if (validator != null) {
-				List<String> seq1 = this.getNodeNames(parent.getStartOffset() + 1,
-						offset);
-				
-				List<String> seq2 = new ArrayList<String>();
-				seq2.add("#PCDATA");
-				
-				List<String> seq3 = this
-						.getNodeNames(offset, parent.getEndOffset());
-				
-				isValid = validator.isValidSequence(parent.getName(), seq1,
-						seq2, seq3, true);
-			} else {
+				final List<QualifiedName> seq1 = getNodeNames(parent.getStartOffset() + 1, offset);
+				final List<QualifiedName> seq2 = Collections.singletonList(Validator.PCDATA);
+				final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
+
+				isValid = validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true);
+			} else
 				isValid = true;
-			}
 		}
 
-		if (!isValid) {
-			throw new DocumentValidationException("Cannot insert text '" + text
-					+ "' at offset " + offset);
-		}
+		if (!isValid)
+			throw new DocumentValidationException("Cannot insert text '" + text + "' at offset " + offset);
 
 		// Convert control chars to spaces
-		StringBuffer sb = new StringBuffer(text);
-		for (int i = 0; i < sb.length(); i++) {
-			if (Character.isISOControl(sb.charAt(i)) && sb.charAt(i) != '\n') {
+		final StringBuffer sb = new StringBuffer(text);
+		for (int i = 0; i < sb.length(); i++)
+			if (Character.isISOControl(sb.charAt(i)) && sb.charAt(i) != '\n')
 				sb.setCharAt(i, ' ');
-			}
-		}
 
-		String s = sb.toString();
+		final String s = sb.toString();
 
-		this.fireBeforeContentInserted(new DocumentEvent(this, parent, offset,
-				2, null));
+		fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
 
-		this.content.insertString(offset, s);
+		content.insertString(offset, s);
 
-		IUndoableEdit edit = this.undoEnabled ? new InsertTextEdit(offset, s)
-				: null;
+		final IUndoableEdit edit = undoEnabled ? new InsertTextEdit(offset, s) : null;
 
-		this.fireContentInserted(new DocumentEvent(this, parent, offset, s
-				.length(), edit));
+		fireContentInserted(new DocumentEvent(this, parent, offset, s.length(), edit));
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#isUndoEnabled()
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#isUndoEnabled()
 	 */
 	public boolean isUndoEnabled() {
-		return this.undoEnabled;
+		return undoEnabled;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#removeDocumentListener(org.eclipse.wst.xml.vex.core.internal.dom.DocumentListener)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#removeDocumentListener
+	 * (org.eclipse.wst.xml.vex.core.internal.dom.DocumentListener)
 	 */
-	public void removeDocumentListener(DocumentListener listener) {
-		this.listeners.remove(listener);
+	public void removeDocumentListener(final DocumentListener listener) {
+		listeners.remove(listener);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setPublicID(java.lang.String)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setPublicID(java
+	 * .lang.String)
 	 */
-	public void setPublicID(String publicID) {
+	public void setPublicID(final String publicID) {
 		this.publicID = publicID;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setSystemID(java.lang.String)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setSystemID(java
+	 * .lang.String)
 	 */
-	public void setSystemID(String systemID) {
+	public void setSystemID(final String systemID) {
 		this.systemID = systemID;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setUndoEnabled(boolean)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setUndoEnabled
+	 * (boolean)
 	 */
-	public void setUndoEnabled(boolean undoEnabled) {
+	public void setUndoEnabled(final boolean undoEnabled) {
 		this.undoEnabled = undoEnabled;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setValidator(org.eclipse.wst.xml.vex.core.internal.dom.Validator)
+	/*
+	 * (non-Javadoc)
 	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocument#setValidator(org
+	 * .eclipse.wst.xml.vex.core.internal.dom.Validator)
 	 */
-	public void setValidator(Validator validator) {
+	public void setValidator(final Validator validator) {
 		this.validator = validator;
 	}
 
@@ -689,25 +581,25 @@
 	 */
 	private class DeleteEdit implements IUndoableEdit {
 
-		private int startOffset;
-		private int endOffset;
-		private DocumentFragment frag;
+		private final int startOffset;
+		private final int endOffset;
+		private final DocumentFragment frag;
 
-		public DeleteEdit(int startOffset, int endOffset, DocumentFragment frag) {
+		public DeleteEdit(final int startOffset, final int endOffset, final DocumentFragment frag) {
 			this.startOffset = startOffset;
 			this.endOffset = endOffset;
 			this.frag = frag;
 		}
 
-		public boolean combine(IUndoableEdit edit) {
+		public boolean combine(final IUndoableEdit edit) {
 			return false;
 		}
 
 		public void undo() throws CannotUndoException {
 			try {
 				setUndoEnabled(false);
-				insertFragment(this.startOffset, this.frag);
-			} catch (DocumentValidationException ex) {
+				insertFragment(startOffset, frag);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -717,8 +609,8 @@
 		public void redo() throws CannotRedoException {
 			try {
 				setUndoEnabled(false);
-				delete(this.startOffset, this.endOffset);
-			} catch (DocumentValidationException ex) {
+				delete(startOffset, endOffset);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -732,23 +624,23 @@
 	 */
 	private class InsertElementEdit implements IUndoableEdit {
 
-		private int offset;
-		private Element element;
+		private final int offset;
+		private final Element element;
 
-		public InsertElementEdit(int offset, Element element2) {
+		public InsertElementEdit(final int offset, final Element element2) {
 			this.offset = offset;
-			this.element = element2;
+			element = element2;
 		}
 
-		public boolean combine(IUndoableEdit edit) {
+		public boolean combine(final IUndoableEdit edit) {
 			return false;
 		}
 
 		public void undo() throws CannotUndoException {
 			try {
 				setUndoEnabled(false);
-				delete(this.offset, this.offset + 2);
-			} catch (DocumentValidationException ex) {
+				delete(offset, offset + 2);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -758,8 +650,8 @@
 		public void redo() throws CannotRedoException {
 			try {
 				setUndoEnabled(false);
-				insertElement(this.offset, this.element);
-			} catch (DocumentValidationException ex) {
+				insertElement(offset, element);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -773,24 +665,24 @@
 	 */
 	private class InsertFragmentEdit implements IUndoableEdit {
 
-		private int offset;
-		private DocumentFragment frag;
+		private final int offset;
+		private final DocumentFragment frag;
 
-		public InsertFragmentEdit(int offset, DocumentFragment frag) {
+		public InsertFragmentEdit(final int offset, final DocumentFragment frag) {
 			this.offset = offset;
 			this.frag = frag;
 		}
 
-		public boolean combine(IUndoableEdit edit) {
+		public boolean combine(final IUndoableEdit edit) {
 			return false;
 		}
 
 		public void undo() throws CannotUndoException {
 			try {
 				setUndoEnabled(false);
-				int length = this.frag.getContent().getLength();
-				delete(this.offset, this.offset + length);
-			} catch (DocumentValidationException ex) {
+				final int length = frag.getContent().getLength();
+				delete(offset, offset + length);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -800,8 +692,8 @@
 		public void redo() throws CannotRedoException {
 			try {
 				setUndoEnabled(false);
-				insertFragment(this.offset, this.frag);
-			} catch (DocumentValidationException ex) {
+				insertFragment(offset, frag);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -815,19 +707,19 @@
 	 */
 	private class InsertTextEdit implements IUndoableEdit {
 
-		private int offset;
+		private final int offset;
 		private String text;
 
-		public InsertTextEdit(int offset, String text) {
+		public InsertTextEdit(final int offset, final String text) {
 			this.offset = offset;
 			this.text = text;
 		}
 
-		public boolean combine(IUndoableEdit edit) {
+		public boolean combine(final IUndoableEdit edit) {
 			if (edit instanceof InsertTextEdit) {
-				InsertTextEdit ite = (InsertTextEdit) edit;
-				if (ite.offset == this.offset + this.text.length()) {
-					this.text = this.text + ite.text;
+				final InsertTextEdit ite = (InsertTextEdit) edit;
+				if (ite.offset == offset + text.length()) {
+					text = text + ite.text;
 					return true;
 				}
 			}
@@ -837,8 +729,8 @@
 		public void undo() throws CannotUndoException {
 			try {
 				setUndoEnabled(false);
-				delete(this.offset, this.offset + this.text.length());
-			} catch (DocumentValidationException ex) {
+				delete(offset, offset + text.length());
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -848,8 +740,8 @@
 		public void redo() throws CannotRedoException {
 			try {
 				setUndoEnabled(false);
-				insertText(this.offset, this.text);
-			} catch (DocumentValidationException ex) {
+				insertText(offset, text);
+			} catch (final DocumentValidationException ex) {
 				throw new CannotUndoException();
 			} finally {
 				setUndoEnabled(true);
@@ -862,11 +754,9 @@
 	 * Assert that the given offset is within the given range, throwing
 	 * IllegalArgumentException if not.
 	 */
-	private static void assertOffset(int offset, int min, int max) {
-		if (offset < min || offset > max) {
-			throw new IllegalArgumentException("Bad offset " + offset
-					+ "must be between " + min + " and " + max);
-		}
+	private static void assertOffset(final int offset, final int min, final int max) {
+		if (offset < min || offset > max)
+			throw new IllegalArgumentException("Bad offset " + offset + "must be between " + min + " and " + max);
 	}
 
 	/**
@@ -881,62 +771,55 @@
 	 * @param parent
 	 *            parent for the cloned Element
 	 */
-	private Element cloneElement(Element original, Content content, int shift,
-			Element parent) {
+	private Element cloneElement(final Element original, final Content content, final int shift, final Element parent) {
 
-		Element clone = new Element(original.getName());
-		clone.setContent(content, original.getStartOffset() + shift, original
-				.getEndOffset()
-				+ shift);
-		List<String> attrNames = original.getAttributeNames();
-		for (int i = 0; i < attrNames.size(); i++) {
+		final Element clone = new Element(original.getName());
+		clone.setContent(content, original.getStartOffset() + shift, original.getEndOffset() + shift);
+		for (final Attribute attribute : original.getAttributes())
 			try {
-				clone.setAttribute(attrNames.get(i), original
-						.getAttribute(attrNames.get(i)));
-			} catch (DocumentValidationException ex) {
+				clone.setAttribute(attribute.getQualifiedName(), attribute.getValue());
+			} catch (final DocumentValidationException ex) {
 				throw new RuntimeException("Unexpected exception: " + ex);
 			}
-		}
 		clone.setParent(parent);
 
-		List<Element> children = original.getChildElements();
+		final List<Element> children = original.getChildElements();
 		for (int i = 0; i < children.size(); i++) {
-			Element cloneChild = this.cloneElement(children.get(i), content, shift,
-					clone);
+			final Element cloneChild = cloneElement(children.get(i), content, shift, clone);
 			clone.insertChild(i, cloneChild);
 		}
 
 		return clone;
 	}
 
-	public void fireAttributeChanged(DocumentEvent e) {
-		this.listeners.fireEvent("attributeChanged", e);
+	public void fireAttributeChanged(final DocumentEvent e) {
+		listeners.fireEvent("attributeChanged", e);
 	}
 
-	private void fireBeforeContentDeleted(DocumentEvent e) {
-		this.listeners.fireEvent("beforeContentDeleted", e);
+	private void fireBeforeContentDeleted(final DocumentEvent e) {
+		listeners.fireEvent("beforeContentDeleted", e);
 	}
 
-	private void fireBeforeContentInserted(DocumentEvent e) {
-		this.listeners.fireEvent("beforeContentInserted", e);
+	private void fireBeforeContentInserted(final DocumentEvent e) {
+		listeners.fireEvent("beforeContentInserted", e);
 	}
 
-	private void fireContentDeleted(DocumentEvent e) {
-		this.listeners.fireEvent("contentDeleted", e);
+	private void fireContentDeleted(final DocumentEvent e) {
+		listeners.fireEvent("contentDeleted", e);
 	}
 
-	private void fireContentInserted(DocumentEvent e) {
-		this.listeners.fireEvent("contentInserted", e);
+	private void fireContentInserted(final DocumentEvent e) {
+		listeners.fireEvent("contentInserted", e);
 	}
-	
-	public void setDocumentURI(String documentURI) {
+
+	public void setDocumentURI(final String documentURI) {
 		this.documentURI = documentURI;
 	}
 
 	public String getDocumentURI() {
 		return documentURI;
 	}
-	
+
 	public String getBaseURI() {
 		return getDocumentURI();
 	}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentEvent.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentEvent.java
index 86d80fd..26416db 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentEvent.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentEvent.java
@@ -12,6 +12,7 @@
 
 import java.util.EventObject;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.undo.IUndoableEdit;
 
 /**
@@ -26,7 +27,7 @@
 	private Element parentElement;
 	private int offset;
 	private int length;
-	private String attributeName;
+	private QualifiedName attributeName;
 	private String oldAttributeValue;
 	private String newAttributeValue;
 	private IUndoableEdit undoableEdit;
@@ -73,7 +74,7 @@
 	 *            IUndoableEdit that can be used to undo the change.
 	 */
 	public DocumentEvent(Document document, Element parentElement,
-			String attributeName, String oldAttributeValue,
+			QualifiedName attributeName, String oldAttributeValue,
 			String newAttributeValue, IUndoableEdit undoableEdit) {
 
 		super(document);
@@ -131,7 +132,7 @@
 	 * @return the name of the attribute that was changed.
 	 * @model
 	 */
-	public String getAttributeName() {
+	public QualifiedName getAttributeName() {
 		return attributeName;
 	}
 
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentFragment.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentFragment.java
index 1618a89..f2aacee 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentFragment.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentFragment.java
@@ -16,17 +16,21 @@
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
+import org.eclipse.core.runtime.QualifiedName;
+
 /**
  * Represents a fragment of an XML document.
  */
 public class DocumentFragment implements Serializable {
 
 	private static final long serialVersionUID = 1L;
-	
+
 	/**
 	 * Mime type representing document fragments: "text/x-vex-document-fragment"
+	 * 
 	 * @model
 	 */
 	public static final String MIME_TYPE = "application/x-vex-document-fragment";
@@ -42,64 +46,78 @@
 	 * @param elements
 	 *            Elements that make up this fragment.
 	 */
-	public DocumentFragment(Content content, List<Element> elements) {
+	public DocumentFragment(final Content content, final List<Element> elements) {
 		this.content = content;
 		this.elements = elements;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getContent()
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getContent
+	 * ()
 	 */
 	public Content getContent() {
-		return this.content;
+		return content;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getLength()
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getLength
+	 * ()
 	 */
 	public int getLength() {
-		return this.content.getLength();
+		return content.getLength();
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getElements()
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getElements
+	 * ()
 	 */
 	public List<Element> getElements() {
 		return elements;
 	}
-	
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getNodeNames()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getNodeNames
+	 * ()
 	 */
-	public List<String> getNodeNames() {
-		List<Node> nodes = getNodes();
-		List<String> names = new ArrayList<String>(nodes.size());
-		for (int i = 0; i < nodes.size(); i++) {
-			if (nodes.get(i) instanceof Text) {
+	public List<QualifiedName> getNodeNames() {
+		final List<Node> nodes = getNodes();
+		final List<QualifiedName> names = new ArrayList<QualifiedName>(nodes.size());
+		for (Node node : nodes)
+			if (node instanceof Text)
 				names.add(Validator.PCDATA);
-			} else {
-				names.add(((Element) nodes.get(i)).getName());
-			}
-		}
+			else
+				names.add(((Element) node).getQualifiedName());
 
 		return names;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getNodes()
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.wst.xml.vex.core.internal.dom.IVEXDocumentFragment#getNodes()
 	 */
 	public List<Node> getNodes() {
-		return Document.createNodeList(getContent(), 0, getContent()
-				.getLength(), getNodes(getElements()));
+		return Document.createNodeList(getContent(), 0, getContent().getLength(), getNodes(getElements()));
 	}
-	
-	private List<Node> getNodes(List<Element> elements) {
-		List<Node> nodes = new ArrayList<Node>();
-		for (Node node : elements) {
-			if (node.getNodeType().equals("Element")) {
+
+	private List<Node> getNodes(final List<Element> elements) {
+		final List<Node> nodes = new ArrayList<Node>();
+		for (final Node node : elements)
+			if (node.getNodeType().equals("Element"))
 				nodes.add(node);
-			}	
-		}
 		return nodes;
 	}
 
@@ -107,74 +125,76 @@
 	 * Custom Serialization Methods
 	 */
 
-	private void writeObject(ObjectOutputStream out) throws IOException {
+	private void writeObject(final ObjectOutputStream out) throws IOException {
 		out.writeUTF(content.getString(0, content.getLength()));
 		out.writeInt(elements.size());
-		for (int i = 0; i < elements.size(); i++) {
-			this.writeElement(elements.get(i), out);
-		}
+		for (int i = 0; i < elements.size(); i++)
+			writeElement(elements.get(i), out);
 	}
- 
-	private void writeElement(Element element, ObjectOutputStream out)
-			throws IOException {
 
-		out.writeObject(element.getName());
+	private void writeElement(final Element element, final ObjectOutputStream out) throws IOException {
+
+		out.writeObject(element.getQualifiedName());
 		out.writeInt(element.getStartOffset());
 		out.writeInt(element.getEndOffset());
-		List<String> attrNames = element.getAttributeNames();
-		out.writeInt(attrNames.size());
-		for (int i = 0; i < attrNames.size(); i++) {
-			out.writeObject(attrNames.get(i));
-			out.writeObject(element.getAttribute(attrNames.get(i)));
+		final Collection<Attribute> attributes = element.getAttributes();
+		out.writeInt(attributes.size());
+		for (final Attribute attribute : attributes) {
+			out.writeObject(attribute.getQualifiedName());
+			out.writeObject(attribute.getValue());
 		}
-		List<Element> children = element.getChildElements();
+		final List<Element> children = element.getChildElements();
 		out.writeInt(children.size());
-		for (int i = 0; i < children.size(); i++) {
-			this.writeElement(children.get(i), out);
-		}
+		for (int i = 0; i < children.size(); i++)
+			writeElement(children.get(i), out);
 	}
 
-	private void readObject(ObjectInputStream in) throws IOException,
-			ClassNotFoundException {
-
-		String s = in.readUTF();
-		this.content = new GapContent(s.length());
+	private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
+		final String s = in.readUTF();
+		content = new GapContent(s.length());
 		content.insertString(0, s);
-		int n = in.readInt();
+		final int n = in.readInt();
 		elements = new ArrayList<Element>(n);
-		for (int i = 0; i < n; i++) {
+		for (int i = 0; i < n; i++)
 			elements.add(readElement(in));
-		}
 	}
 
-	private Element readElement(ObjectInputStream in) throws IOException,
-			ClassNotFoundException {
+	private Element readElement(final ObjectInputStream in) throws IOException, ClassNotFoundException {
+		final QualifiedName elementName = createQualifiedName(in.readObject());
+		final int startOffset = in.readInt();
+		final int endOffset = in.readInt();
+		final Element element = new Element(elementName);
+		element.setContent(content, startOffset, endOffset);
 
-		String name = (String) in.readObject();
-		int startOffset = in.readInt();
-		int endOffset = in.readInt();
-		Element element = new Element(name);
-		element.setContent(this.content, startOffset, endOffset);
-
-		int attrCount = in.readInt();
+		final int attrCount = in.readInt();
 		for (int i = 0; i < attrCount; i++) {
-			String key = (String) in.readObject();
-			String value = (String) in.readObject();
+			final QualifiedName attributeName = createQualifiedName(in.readObject());
+			final String value = (String) in.readObject();
 			try {
-				element.setAttribute(key, value);
-			} catch (DocumentValidationException e) {
+				element.setAttribute(attributeName, value);
+			} catch (final DocumentValidationException e) {
 				// Should never happen; there ain't no document
 				e.printStackTrace();
 			}
 		}
 
-		int childCount = in.readInt();
+		final int childCount = in.readInt();
 		for (int i = 0; i < childCount; i++) {
-			Element child = this.readElement(in);
+			final Element child = readElement(in);
 			child.setParent(element);
 			element.insertChild(i, child);
 		}
 
 		return element;
 	}
+
+	private static QualifiedName createQualifiedName(final Object object) {
+		final String serializedQualifiedName = object.toString();
+		final int localNameStartIndex = serializedQualifiedName.lastIndexOf(':') + 1;
+		if (localNameStartIndex == 0)
+			return new QualifiedName(null, serializedQualifiedName);
+		final String qualifier = serializedQualifiedName.substring(0, localNameStartIndex - 1);
+		final String localName = serializedQualifiedName.substring(localNameStartIndex);
+		return new QualifiedName(qualifier, localName);
+	}
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
index 2269504..3f50699 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
@@ -16,7 +16,7 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.util.Arrays;
-import java.util.Collections;
+import java.util.Collection;
 import java.util.List;
 
 import org.eclipse.wst.xml.vex.core.internal.validator.AttributeDefinition;
@@ -46,8 +46,8 @@
 	 * Class constructor.
 	 */
 	public DocumentWriter() {
-		this.indent = "  ";
-		this.wrapColumn = 72;
+		indent = "  ";
+		wrapColumn = 72;
 	}
 
 /**
@@ -57,24 +57,23 @@
      * @param s the string to be escaped.
      * @return the escaped string
      */
-	public static String escape(String s) {
-		StringBuffer sb = new StringBuffer(s.length());
+	public static String escape(final String s) {
+		final StringBuffer sb = new StringBuffer(s.length());
 
 		for (int i = 0; i < s.length(); i++) {
-			char c = s.charAt(i);
-			if (c == '<') {
+			final char c = s.charAt(i);
+			if (c == '<')
 				sb.append("&lt;");
-			} else if (c == '>') {
+			else if (c == '>')
 				sb.append("&gt;");
-			} else if (c == '&') {
+			else if (c == '&')
 				sb.append("&amp;");
-			} else if (c == '"') {
+			else if (c == '"')
 				sb.append("&quot;");
-			} else if (c == '\'') {
+			else if (c == '\'')
 				sb.append("&apos;");
-			} else {
+			else
 				sb.append(c);
-			}
 		}
 		return sb.toString();
 	}
@@ -83,7 +82,7 @@
 	 * Returns the indent string. By default this is two spaces.
 	 */
 	public String getIndent() {
-		return this.indent;
+		return indent;
 	}
 
 	/**
@@ -98,7 +97,7 @@
 	 * 72.
 	 */
 	public int getWrapColumn() {
-		return this.wrapColumn;
+		return wrapColumn;
 	}
 
 	/**
@@ -107,7 +106,7 @@
 	 * @param indent
 	 *            new value for the indent string.
 	 */
-	public void setIndent(String indent) {
+	public void setIndent(final String indent) {
 		this.indent = indent;
 	}
 
@@ -119,7 +118,7 @@
 	 * @param whitespacePolicy
 	 *            The whitespacePolicy to set.
 	 */
-	public void setWhitespacePolicy(IWhitespacePolicy whitespacePolicy) {
+	public void setWhitespacePolicy(final IWhitespacePolicy whitespacePolicy) {
 		this.whitespacePolicy = whitespacePolicy;
 	}
 
@@ -129,58 +128,56 @@
 	 * @param wrapColumn
 	 *            new value for the wrap column.
 	 */
-	public void setWrapColumn(int wrapColumn) {
+	public void setWrapColumn(final int wrapColumn) {
 		this.wrapColumn = wrapColumn;
 	}
 
-	public void write(Document doc, OutputStream os) throws IOException {
+	public void write(final Document doc, final OutputStream os) throws IOException {
 
-		OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
-		PrintWriter pw = new PrintWriter(osw);
+		final OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
+		final PrintWriter pw = new PrintWriter(osw);
 		pw.println("<?xml version='1.0'?>");
-		
-		if (((Document)doc).getSystemID() != null) {
-			StringBuffer sb = new StringBuffer();
+
+		if ((doc).getSystemID() != null) {
+			final StringBuffer sb = new StringBuffer();
 			sb.append("<!DOCTYPE ");
-			sb.append(doc.getRootElement().getName());
+			sb.append(doc.getRootElement().getPrefixedName());
 			if (doc.getPublicID() != null) {
 				sb.append(" PUBLIC");
 				sb.append(" \"");
 				sb.append(doc.getPublicID());
 				sb.append("\"");
-			} else {
+			} else
 				sb.append(" SYSTEM");
-			}
 			sb.append(" \"");
-			sb.append(((Document)doc).getSystemID());
+			sb.append((doc).getSystemID());
 			sb.append("\">");
 			pw.println(sb.toString());
 		}
-		this.writeNode(doc.getRootElement(), pw, "");
+		writeNode(doc.getRootElement(), pw, "");
 		pw.flush();
 	}
 
 	// ====================================================== PRIVATE
 
-	private void writeNode(Node node, PrintWriter pw, String indent) {
+	private void writeNode(final Node node, final PrintWriter pw, final String indent) {
 
 		if (node instanceof Text) {
-			TextWrapper wrapper = new TextWrapper();
+			final TextWrapper wrapper = new TextWrapper();
 			wrapper.add(escape(node.getText()));
 
-			String[] lines = wrapper.wrap(this.wrapColumn - indent.length());
+			final String[] lines = wrapper.wrap(wrapColumn - indent.length());
 
-			for (int i = 0; i < lines.length; i++) {
+			for (final String line : lines) {
 				pw.print(indent);
-				pw.println(lines[i]);
+				pw.println(line);
 			}
 
 		} else {
 
-			Element element = (Element) node;
+			final Element element = (Element) node;
 
-			if (this.whitespacePolicy != null
-					&& this.whitespacePolicy.isPre(element)) {
+			if (whitespacePolicy != null && whitespacePolicy.isPre(element)) {
 				pw.print(indent);
 				writeNodeNoWrap(node, pw);
 				pw.println();
@@ -188,171 +185,144 @@
 			}
 
 			boolean hasBlockChild = false;
-			List<Element> children = element.getChildElements();
-			for (int i = 0; i < children.size(); i++) {
-				if (this.whitespacePolicy != null
-						&& this.whitespacePolicy.isBlock(children.get(i))) {
+			final List<Element> children = element.getChildElements();
+			for (int i = 0; i < children.size(); i++)
+				if (whitespacePolicy != null && whitespacePolicy.isBlock(children.get(i))) {
 					hasBlockChild = true;
 					break;
 				}
-			}
 
 			if (hasBlockChild) {
 				pw.print(indent);
 				pw.print("<");
-				pw.print(element.getName());
+				pw.print(element.getPrefixedName());
 
-				TextWrapper wrapper = new TextWrapper();
-				wrapper.addNoSplit(this.getAttributeString(element));
-				int outdent = indent.length() + 1 + element.getName().length();
-				String[] lines = wrapper.wrap(this.wrapColumn - outdent);
-				char[] bigIndent = new char[outdent];
+				final TextWrapper wrapper = new TextWrapper();
+				wrapper.addNoSplit(getAttributeString(element));
+				final int outdent = indent.length() + 1 + element.getPrefixedName().length();
+				final String[] lines = wrapper.wrap(wrapColumn - outdent);
+				final char[] bigIndent = new char[outdent];
 				Arrays.fill(bigIndent, ' ');
 				for (int i = 0; i < lines.length; i++) {
-					if (i > 0) {
+					if (i > 0)
 						pw.print(bigIndent);
-					}
 					pw.print(lines[i]);
-					if (i < lines.length - 1) {
+					if (i < lines.length - 1)
 						pw.println();
-					}
 				}
 				pw.println(">");
 
-				String childIndent = indent + this.indent;
-				List<Node> content = element.getChildNodes();
-				for (int i = 0; i < content.size(); i++) {
-					this.writeNode(content.get(i), pw, childIndent);
-				}
+				final String childIndent = indent + this.indent;
+				final List<Node> content = element.getChildNodes();
+				for (int i = 0; i < content.size(); i++)
+					writeNode(content.get(i), pw, childIndent);
 				pw.print(indent);
 				pw.print("</");
-				pw.print(element.getName());
+				pw.print(element.getPrefixedName());
 				pw.println(">");
 			} else {
-				TextWrapper wrapper = new TextWrapper();
-				this.addNode(element, wrapper);
-				String[] lines = wrapper
-						.wrap(this.wrapColumn - indent.length());
-				for (int i = 0; i < lines.length; i++) {
+				final TextWrapper wrapper = new TextWrapper();
+				addNode(element, wrapper);
+				final String[] lines = wrapper.wrap(wrapColumn - indent.length());
+				for (final String line : lines) {
 					pw.print(indent);
-					pw.println(lines[i]);
+					pw.println(line);
 				}
 			}
 
 		}
 	}
 
-	private void writeNodeNoWrap(Node node, PrintWriter pw) {
+	private void writeNodeNoWrap(final Node node, final PrintWriter pw) {
 
-		if (node instanceof Text) {
+		if (node instanceof Text)
 			pw.print(escape(node.getText()));
-		} else {
+		else {
 
-			Element element = (Element) node;
+			final Element element = (Element) node;
 
 			pw.print("<");
-			pw.print(element.getName());
-			pw.print(this.getAttributeString(element));
+			pw.print(element.getPrefixedName());
+			pw.print(getAttributeString(element));
 			pw.print(">");
 
-			List<Node> content = element.getChildNodes();
-			for (int i = 0; i < content.size(); i++) {
-				this.writeNodeNoWrap(content.get(i), pw);
-			}
+			for (Node child : element.getChildNodes())
+				writeNodeNoWrap(child, pw);
 
 			pw.print("</");
-			pw.print(element.getName());
+			pw.print(element.getPrefixedName());
 			pw.print(">");
 		}
 	}
 
-	private String attrToString(String name, String value) {
-		StringBuffer sb = new StringBuffer();
-		sb.append(" ");
-		sb.append(name);
-		sb.append("=\"");
-		sb.append(escape(value));
-		sb.append("\"");
-		return sb.toString();
+	private String attrToString(final Attribute attribute) {
+		final StringBuffer result = new StringBuffer();
+		result.append(" ");
+		result.append(attribute.getPrefixedName());
+		result.append("=\"");
+		result.append(escape(attribute.getValue()));
+		result.append("\"");
+		return result.toString();
 	}
 
-	private void addNode(Node node, TextWrapper wrapper) {
-		if (node instanceof Text) {
+	private void addNode(final Node node, final TextWrapper wrapper) {
+		if (node instanceof Text)
 			wrapper.add(escape(node.getText()));
-		} else {
-			Element element = (Element) node;
-			List<Node> content = element.getChildNodes();
-			List<String> attrs = element.getAttributeNames();
-			Collections.sort(attrs);
+		else {
+			final Element element = (Element) node;
+			final List<Node> content = element.getChildNodes();
+			final Collection<Attribute> attributes = element.getAttributes();
 
-			if (attrs.isEmpty()) {
-				if (content.isEmpty()) {
-					wrapper.add("<" + element.getName() + " />");
-				} else {
-					wrapper.add("<" + element.getName() + ">");
-				}
+			if (attributes.isEmpty()) {
+				if (content.isEmpty())
+					wrapper.add("<" + element.getPrefixedName() + "/>");
+				else
+					wrapper.add("<" + element.getPrefixedName() + ">");
 			} else {
-				Validator validator = element.getDocument().getValidator();
-				StringBuffer sb = new StringBuffer();
-				for (int i = 0; i < attrs.size(); i++) {
-					sb.setLength(0);
-					if (i == 0) {
-						sb.append("<" + element.getName());
-					}
-					if (!attrHasDefaultValue(validator, element, attrs.get(i))) {
-						sb.append(attrToString(attrs.get(i), element
-								.getAttribute(attrs.get(i))));
-					}
-					if (i == attrs.size() - 1) {
-						if (content.isEmpty()) {
-							sb.append("/>");
-						} else {
-							sb.append(">");
-						}
-					}
-					wrapper.addNoSplit(sb.toString());
+				final Validator validator = element.getDocument().getValidator();
+				final StringBuffer stringBuffer = new StringBuffer();
+				stringBuffer.append("<" + element.getPrefixedName());
+				for (final Attribute attribute : attributes) {
+					if (!attrHasDefaultValue(validator, attribute))
+						stringBuffer.append(attrToString(attribute));
 				}
+				if (content.isEmpty())
+					stringBuffer.append("/>");
+				else
+					stringBuffer.append(">");
+				wrapper.addNoSplit(stringBuffer.toString());
 			}
 
-			for (int i = 0; i < content.size(); i++) {
+			for (int i = 0; i < content.size(); i++)
 				addNode(content.get(i), wrapper);
-			}
 
-			if (!content.isEmpty()) {
-				wrapper.add("</" + element.getName() + ">");
-			}
+			if (!content.isEmpty())
+				wrapper.add("</" + element.getPrefixedName() + ">");
 		}
 	}
 
-	private String getAttributeString(Element element) {
+	private String getAttributeString(final Element element) {
+		final Validator validator = element.getDocument().getValidator();
 
-		Validator validator = element.getDocument().getValidator();
-
-		List<String> attrs = element.getAttributeNames();
-		Collections.sort(attrs);
-		StringBuffer sb = new StringBuffer();
-		for (int i = 0; i < attrs.size(); i++) {
-			if (attrHasDefaultValue(validator, element, attrs.get(i))) {
-				continue;
+		final StringBuffer result = new StringBuffer();
+		for (final Attribute attribute : element.getAttributes())
+			if (!attrHasDefaultValue(validator, attribute)) {
+				result.append(" ");
+				result.append(attribute.getPrefixedName());
+				result.append("=\"");
+				result.append(escape(attribute.getValue()));
+				result.append("\"");
 			}
-			sb.append(" ");
-			sb.append(attrs.get(i));
-			sb.append("=\"");
-			sb.append(escape(element.getAttribute(attrs.get(i))));
-			sb.append("\"");
-		}
-		return sb.toString();
+		return result.toString();
 	}
 
-	private static boolean attrHasDefaultValue(Validator validator,
-			Element element, String attribute) {
+	private static boolean attrHasDefaultValue(final Validator validator, final Attribute attribute) {
 		if (validator != null) {
-			AttributeDefinition ad = validator.getAttributeDefinition(element
-					.getName(), attribute);
-			if (ad != null) {
-				String value = element.getAttribute(attribute);
-				String defaultValue = ad.getDefaultValue();
-				return value != null && value.equals(defaultValue);
+			final AttributeDefinition attributeDefinition = validator.getAttributeDefinition(attribute);
+			if (attributeDefinition != null) {
+				final String currentValue = attribute.getValue();
+				final String defaultValue = attributeDefinition.getDefaultValue();
+				return currentValue.equals(defaultValue);
 			}
 		}
 		return false;
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 9d9cac7..efc843b 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
@@ -12,8 +12,8 @@
 package org.eclipse.wst.xml.vex.core.internal.dom;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -21,6 +21,7 @@
 import java.util.Map.Entry;
 
 import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.wst.xml.vex.core.internal.core.QualifiedNameComparator;
 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;
@@ -31,13 +32,13 @@
  */
 public class Element extends Node implements Cloneable {
 
-	private static final String XML_BASE_ATTRIBUTE = "xml:base";
+	private static final QualifiedName XML_BASE_ATTRIBUTE = new QualifiedName(Namespace.XML_NAMESPACE_URI, "base");
 	
 	private final QualifiedName name;
 	
 	private Element parent = null;
 	private List<Node> childNodes = new ArrayList<Node>();
-	private Map<String, Attribute> attributes = new HashMap<String, Attribute>();
+	private Map<QualifiedName, Attribute> attributes = new HashMap<QualifiedName, Attribute>();
 	private Map<String, String> namespaceDeclarations = new HashMap<String, String>();
 
 	public Element(final String localName) {
@@ -55,10 +56,9 @@
 
 	public Object clone() {
 		try {
-			Element element = new Element(this.getName());
-
+			final Element element = new Element(getQualifiedName());
 			//add the attributes to the element instance to be cloned
-			for (Map.Entry<String, Attribute> attr : this.attributes.entrySet())
+			for (Map.Entry<QualifiedName, Attribute> attr : this.attributes.entrySet())
 				element.setAttribute(attr.getKey(), attr.getValue().getValue());
 			return element;
 		} catch (DocumentValidationException ex) {
@@ -67,15 +67,34 @@
 		}
 	}
 
-	public String getAttribute(String name) {
-		Attribute attribute = attributes.get(name);
-		if (attribute == null)
+	public Attribute getAttribute(String localName) {
+		return getAttribute(qualify(localName));
+	}
+	
+	public Attribute getAttribute(QualifiedName name) {
+		return attributes.get(name);
+	}
+	
+	public String getAttributeValue(String localName) {
+		return getAttributeValue(qualify(localName));
+	}
+
+	public String getAttributeValue(QualifiedName name) {
+		final Attribute attribute = getAttribute(name);
+		if (attribute == null || "".equals(attribute.getValue().trim()))
 			return null;
 		return attribute.getValue();
 	}
-
-	public void removeAttribute(String name) throws DocumentValidationException {
-		final String oldValue = this.getAttribute(name);
+	
+	public void removeAttribute(String localName) throws DocumentValidationException {
+		removeAttribute(qualify(localName));
+	}
+	
+	public void removeAttribute(QualifiedName name) throws DocumentValidationException {
+		final Attribute attribute = this.getAttribute(name);
+		if (attribute == null)
+			return;
+		final String oldValue = attribute.getValue();
 		final String newValue = null;
 		if (oldValue != null)
 			this.attributes.remove(name);
@@ -89,6 +108,14 @@
 	}
 
 	public void setAttribute(String name, String value) throws DocumentValidationException {
+		setAttribute(qualify(name), value);
+	}
+	
+	private QualifiedName qualify(String localName) {
+		return new QualifiedName(name.getQualifier(), localName);
+	}
+	
+	public void setAttribute(QualifiedName name, String value) throws DocumentValidationException {
 		final Attribute oldAttribute = attributes.get(name);
 		final String oldValue = oldAttribute != null ? oldAttribute.getValue() : null;
 		
@@ -114,9 +141,19 @@
 		}
 	}
 
-	public List<String> getAttributeNames() {
-		final Collection<String> names = this.attributes.keySet();
-		return Arrays.<String> asList(names.toArray(new String[names.size()]));
+	public Collection<Attribute> getAttributes() {
+		final ArrayList<Attribute> result = new ArrayList<Attribute>(attributes.values());
+		Collections.sort(result);
+		return Collections.unmodifiableCollection(result);
+	}
+	
+	public List<QualifiedName> getAttributeNames() {
+		ArrayList<QualifiedName> result = new ArrayList<QualifiedName>();
+		for (Attribute attribute : attributes.values()) {
+			result.add(attribute.getQualifiedName());
+		}
+		Collections.sort(result, new QualifiedNameComparator());
+		return result;
 	}
 
 	public Iterator<Node> getChildIterator() {
@@ -209,16 +246,12 @@
 		StringBuffer sb = new StringBuffer();
 		sb.append("<");
 		sb.append(this.getPrefixedName().toString());
-		List<String> attrs = this.getAttributeNames();
-
-		for (int i = 0; i < attrs.size(); i++) {
-			if (i > 0) {
-				sb.append(",");
-			}
+		
+		for (Attribute attribute : getAttributes()) {
 			sb.append(" ");
-			sb.append(attrs.get(i));
+			sb.append(attribute.getPrefixedName());
 			sb.append("=\"");
-			sb.append(this.getAttribute(attrs.get(i)));
+			sb.append(attribute.getValue());
 			sb.append("\"");
 		}
 
@@ -235,11 +268,11 @@
 
 	private class AttributeChangeEdit implements IUndoableEdit {
 
-		private String name;
+		private QualifiedName name;
 		private String oldValue;
 		private String newValue;
 
-		public AttributeChangeEdit(String name, String oldValue, String newValue) {
+		public AttributeChangeEdit(QualifiedName name, String oldValue, String newValue) {
 			this.name = name;
 			this.oldValue = oldValue;
 			this.newValue = newValue;
@@ -341,9 +374,9 @@
 
 	@Override
 	public String getBaseURI() {
-		final String baseAttributeValue = getAttribute(XML_BASE_ATTRIBUTE);
-		if (baseAttributeValue != null)
-			return baseAttributeValue;
+		final Attribute baseAttribute = getAttribute(XML_BASE_ATTRIBUTE);
+		if (baseAttribute != null)
+			return baseAttribute.getValue();
 		if (getParent() != null)
 			return getParent().getBaseURI();
 		if (getDocument() != null)
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Namespace.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Namespace.java
new file mode 100644
index 0000000..664cd0e
--- /dev/null
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Namespace.java
@@ -0,0 +1,26 @@
+/*******************************************************************************

+ * Copyright (c) 2010 Florian Thienel and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * Contributors:

+ * 		Florian Thienel - initial API and implementation

+ *******************************************************************************/

+package org.eclipse.wst.xml.vex.core.internal.dom;

+

+/**

+ * @author Florian Thienel

+ */

+public class Namespace {

+	

+	public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";

+	

+	public static final String XML_NAMESPACE_PREFIX = "xml";

+	

+	public static final String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";

+	

+	public static final String XMLNS_NAMESPACE_PREFIX = "xmlns";

+

+}

diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Validator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Validator.java
index 3f4c546..b32adb9 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Validator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Validator.java
@@ -12,9 +12,10 @@
 package org.eclipse.wst.xml.vex.core.internal.dom;
 
 import java.io.Serializable;
-import java.util.Set;
 import java.util.List;
+import java.util.Set;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.validator.AttributeDefinition;
 
 /**
@@ -25,11 +26,11 @@
 public interface Validator extends Serializable {
 
 	/**
-	 * String indicating that character data is allowed at the given point in
+	 * QualifiedName indicating that character data is allowed at the given point in
 	 * the document.
 	 * @model
 	 */
-	public static final String PCDATA = "#PCDATA";
+	public static final QualifiedName PCDATA = new QualifiedName(null, "#PCDATA");
 
 	/**
 	 * Returns the AttributeDefinition for a particular attribute.
@@ -40,8 +41,7 @@
 	 *            Name of the attribute.
 	 * @model
 	 */
-	public AttributeDefinition getAttributeDefinition(String element,
-			String attribute);
+	public AttributeDefinition getAttributeDefinition(Attribute attribute);
 
 	/**
 	 * Returns the attribute definitions that apply to the given element.
@@ -50,17 +50,17 @@
 	 *            Name of the element to check.
 	 * @model
 	 */
-	public List<AttributeDefinition> getAttributeDefinitions(String element);
+	public List<AttributeDefinition> getAttributeDefinitions(QualifiedName element);
 
 	/**
-	 * Returns a set of Strings representing valid root elements for the given
+	 * Returns a set of QualifiedNames representing valid root elements for the given
 	 * document type.
 	 * @model 
 	 */
-	public Set<String> getValidRootElements();
+	public Set<QualifiedName> getValidRootElements();
 
 	/**
-	 * Returns a set of Strings representing items that are valid at point in
+	 * Returns a set of QualifiedNames representing items that are valid at point in
 	 * the child nodes of a given element. Each string is either an element name
 	 * or Validator.PCDATA.
 	 * 
@@ -68,7 +68,7 @@
 	 *            Name of the parent element.
 	 * @model 
 	 */
-	public Set<String> getValidItems(String element);
+	public Set<QualifiedName> getValidItems(QualifiedName element);
 
 	/**
 	 * Returns true if the given sequence is valid for the given element.
@@ -83,7 +83,7 @@
 	 *            If true, an valid but incomplete sequence is acceptable.
 	 * @model
 	 */
-	public boolean isValidSequence(String element, List<String> nodes,
+	public boolean isValidSequence(QualifiedName element, List<QualifiedName> nodes,
 			boolean partial);
 
 	/**
@@ -105,7 +105,7 @@
 	 *            If true, an valid but incomplete sequence is acceptable.
 	 * @model
 	 */
-	public boolean isValidSequence(String element, List<String> seq1,
-			List<String> seq2, List<String> seq3, boolean partial);
+	public boolean isValidSequence(QualifiedName element, List<QualifiedName> seq1,
+			List<QualifiedName> seq2, List<QualifiedName> seq3, boolean partial);
 
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java
deleted file mode 100644
index 1d0f1b5..0000000
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 John Krasnay and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *     John Krasnay - initial API and implementation
- *     Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
- *******************************************************************************/
-package org.eclipse.wst.xml.vex.core.internal.validator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.xml.vex.core.internal.dom.Validator;
-
-/**
- * Partial implementation of the Validator interface.
- * @deprecated
- */
-public abstract class AbstractValidator implements Validator {
-
-	/**
-	 * @see Validator#isValidSequence
-	 * @deprecated
-	 */
-	public boolean isValidSequence(String element, List<String> seq1,
-			List<String> seq2, List<String> seq3, boolean partial) {
-
-		List<String> list = new ArrayList<String>();
-		for (int i = 0; i < seq1.size(); i++) {
-			list.add(seq1.get(i));
-		}
-		if (seq2 != null) {
-			for (int i = 0; i < seq2.size(); i++) {
-				if (i == 0 && seq2.get(i).equals(Validator.PCDATA)
-						&& !list.isEmpty()
-						&& list.get(list.size() - 1).equals(Validator.PCDATA)) {
-					// Avoid consecutive PCDATA's
-					continue;
-				}
-				list.add(seq2.get(i));
-			}
-		}
-		if (seq3 != null) {
-			for (int i = 0; i < seq3.size(); i++) {
-				if (i == 0 && seq3.get(i).equals(Validator.PCDATA)
-						&& !list.isEmpty()
-						&& list.get(list.size() - 1).equals(Validator.PCDATA)) {
-					// Avoid consecutive PCDATA's
-					continue;
-				}
-				list.add(seq3.get(i));
-			}
-		}
-
-		return this.isValidSequence(element, list, partial);
-	}
-
-}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
index 11f8d78..feed31c 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
@@ -21,6 +21,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
 import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
 import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
@@ -34,6 +35,7 @@
 import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMValidator.ElementContentComparator;
 import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMValidator.ElementPathRecordingResult;
 import org.eclipse.wst.xml.core.internal.contentmodel.internal.util.CMValidator.StringElementContentComparator;
+import org.eclipse.wst.xml.vex.core.internal.dom.Attribute;
 import org.eclipse.wst.xml.vex.core.internal.dom.Validator;
 import org.eclipse.wst.xml.vex.core.internal.validator.AttributeDefinition.Type;
 
@@ -74,7 +76,9 @@
 		return new WTPVEXValidator(url);
 	}
 
-	public AttributeDefinition getAttributeDefinition(final String elementName, final String attributeName) {
+	public AttributeDefinition getAttributeDefinition(final Attribute attribute) {
+		final QualifiedName elementName = attribute.getParent().getQualifiedName();
+		final String attributeName = attribute.getLocalName();
 		final CMElementDeclaration cmElement = getElementDeclaration(elementName);
 		/*
 		 * #342320: If we do not find the element, it is acutally not valid.
@@ -99,18 +103,17 @@
 		return new AttributeDefinition(attributeName, Type.CDATA, /* default value */"", /* values */new String[0], /* required */false, /* fixed */true);
 	}
 
-	public List<AttributeDefinition> getAttributeDefinitions(final String element) {
-		final CMElementDeclaration cmElement = getElementDeclaration(element);
+	public List<AttributeDefinition> getAttributeDefinitions(final QualifiedName elementName) {
+		final CMElementDeclaration cmelement = getElementDeclaration(elementName);
 		/*
 		 * #342320: If we do not find the element, it is acutally not valid.
 		 * But we are benevolent here since we do not want to loose data at this
 		 * point.
 		 */
-		if (cmElement == null)
+		if (cmelement == null)
 			return Collections.emptyList();
-		
-		final List<AttributeDefinition> attributeList = new ArrayList<AttributeDefinition>(cmElement.getAttributes().getLength());
-		final Iterator<?> iter = cmElement.getAttributes().iterator();
+		final List<AttributeDefinition> attributeList = new ArrayList<AttributeDefinition>(cmelement.getAttributes().getLength());
+		final Iterator<?> iter = cmelement.getAttributes().iterator();
 		while (iter.hasNext()) {
 			final CMAttributeDeclaration attribute = (CMAttributeDeclaration) iter.next();
 			final AttributeDefinition vexAttr = createAttributeDefinition(attribute);
@@ -120,8 +123,8 @@
 		return attributeList;
 	}
 
-	private CMElementDeclaration getElementDeclaration(final String element) {
-		return (CMElementDeclaration) getSchema().getElements().getNamedItem(element);
+	private CMElementDeclaration getElementDeclaration(final QualifiedName elementName) {
+		return (CMElementDeclaration) getSchema().getElements().getNamedItem(elementName.getLocalName());
 	}
 
 	private AttributeDefinition createAttributeDefinition(final CMAttributeDeclaration attribute) {
@@ -143,32 +146,36 @@
 		return vexAttr;
 	}
 
-	public Set<String> getValidItems(final String element) {
-		final CMElementDeclaration elementDec = (CMElementDeclaration) getSchema().getElements().getNamedItem(element);
+	public Set<QualifiedName> getValidItems(final QualifiedName element) {
+		final CMElementDeclaration elementDeclaration = getElementDeclaration(element);
 		/*
 		 * #342320: If we do not find the element, it is acutally not valid.
 		 * But we are benevolent here since we do not want to loose data at this
 		 * point.
 		 */
-		if (elementDec == null)
+		if (elementDeclaration == null)
 			return Collections.emptySet();
-		final Set<String> results = new HashSet<String>();
-		for (final CMNode node : getAvailableContent(element, elementDec))
+		final Set<QualifiedName> result = new HashSet<QualifiedName>();
+		for (final CMNode node : getAvailableContent(elementDeclaration))
 			if (node instanceof CMElementDeclaration) {
-				final CMElementDeclaration elem = (CMElementDeclaration) node;
-				results.add(elem.getElementName());
+				final CMElementDeclaration childDeclaration = (CMElementDeclaration) node;
+				result.add(createQualifiedElementName(childDeclaration));
 			}
-		return results;
+		return result;
+	}
+
+	private static QualifiedName createQualifiedElementName(final CMElementDeclaration elementDeclaration) {
+		return new QualifiedName(null, elementDeclaration.getElementName());
 	}
 
 	/**
 	 * Returns a list of all CMNode 'meta data' that may be potentially added to
 	 * the element.
 	 */
-	protected List<CMNode> getAvailableContent(final String element, final CMElementDeclaration ed) {
+	private List<CMNode> getAvailableContent(final CMElementDeclaration elementDeclaration) {
 		final List<CMNode> list = new ArrayList<CMNode>();
-		if (ed.getContentType() == CMElementDeclaration.ELEMENT || ed.getContentType() == CMElementDeclaration.MIXED) {
-			final CMContent content = ed.getContent();
+		if (elementDeclaration.getContentType() == CMElementDeclaration.ELEMENT || elementDeclaration.getContentType() == CMElementDeclaration.MIXED) {
+			final CMContent content = elementDeclaration.getContent();
 			if (content instanceof CMElementDeclaration)
 				list.add(content);
 			else if (content instanceof CMGroup) {
@@ -193,25 +200,28 @@
 		return list;
 	}
 
-	public Set<String> getValidRootElements() {
-		final Set<String> results = new HashSet<String>();
+	public Set<QualifiedName> getValidRootElements() {
+		final HashSet<QualifiedName> result = new HashSet<QualifiedName>();
 		final Iterator<?> iter = getSchema().getElements().iterator();
 		while (iter.hasNext()) {
 			final CMElementDeclaration element = (CMElementDeclaration) iter.next();
-			results.add(element.getElementName());
+			result.add(createQualifiedElementName(element));
 		}
 
-		return results;
+		return result;
 	}
 
-	public boolean isValidSequence(final String element, final List<String> nodes, final boolean partial) {
-		final CMNode parent = getSchema().getElements().getNamedItem(element);
+	public boolean isValidSequence(final QualifiedName element, final List<QualifiedName> nodes, final boolean partial) {
+		final CMNode parent = getSchema().getElements().getNamedItem(element.getLocalName());
 		if (!(parent instanceof CMElementDeclaration))
 			return true;
 
 		final CMElementDeclaration elementDeclaration = (CMElementDeclaration) parent;
 		final ElementPathRecordingResult validationResult = new ElementPathRecordingResult();
-		validator.validate(elementDeclaration, nodes, ELEMENT_CONTENT_COMPARATOR, validationResult);
+		final List<String> nodeNames = new ArrayList<String>();
+		for (QualifiedName node : nodes)
+			nodeNames.add(node.getLocalName()); // TODO learn how the WTP content model handles namespaces
+		validator.validate(elementDeclaration, nodeNames, ELEMENT_CONTENT_COMPARATOR, validationResult);
 
 		final int elementCount = getElementCount(nodes);
 		if (partial && elementCount > 0)
@@ -220,16 +230,16 @@
 		return validationResult.isValid;
 	}
 
-	private static int getElementCount(final List<String> nodes) {
+	private static int getElementCount(final List<QualifiedName> nodes) {
 		int count = 0;
-		for (final String node : nodes)
-			if (ELEMENT_CONTENT_COMPARATOR.isElement(node))
+		for (final QualifiedName node : nodes)
+			if (ELEMENT_CONTENT_COMPARATOR.isElement(node.getLocalName()))
 				count++;
 		return count;
 	}
 
-	public boolean isValidSequence(final String element, final List<String> seq1, final List<String> seq2, final List<String> seq3, final boolean partial) {
-		final List<String> joinedSequence = new ArrayList<String>();
+	public boolean isValidSequence(final QualifiedName element, final List<QualifiedName> seq1, final List<QualifiedName> seq2, final List<QualifiedName> seq3, final boolean partial) {
+		final List<QualifiedName> joinedSequence = new ArrayList<QualifiedName>();
 		if (seq1 != null)
 			joinedSequence.addAll(seq1);
 		if (seq2 != null)
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
index e793dcf..0673bce 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
@@ -16,6 +16,7 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -24,10 +25,12 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.core.Caret;
 import org.eclipse.wst.xml.vex.core.internal.core.Color;
 import org.eclipse.wst.xml.vex.core.internal.core.Graphics;
 import org.eclipse.wst.xml.vex.core.internal.core.IntRange;
+import org.eclipse.wst.xml.vex.core.internal.core.QualifiedNameComparator;
 import org.eclipse.wst.xml.vex.core.internal.core.Rectangle;
 import org.eclipse.wst.xml.vex.core.internal.css.CSS;
 import org.eclipse.wst.xml.vex.core.internal.css.StyleSheet;
@@ -85,7 +88,7 @@
 
 	private boolean debugging;
 
-	private HostComponent hostComponent;
+	private final HostComponent hostComponent;
 	private int layoutWidth = 500; // something reasonable to handle a document
 	// being set before the widget is sized
 
@@ -122,45 +125,42 @@
 
 	private boolean antiAliased = false;
 
-	private DocumentListener documentListener = new DocumentListener() {
+	private final DocumentListener documentListener = new DocumentListener() {
 
-		public void attributeChanged(DocumentEvent e) {
+		public void attributeChanged(final DocumentEvent e) {
 			invalidateElementBox(e.getParentElement());
 
 			// flush cached styles, since they might depend attribute values
 			// via conditional selectors
 			getStyleSheet().flushStyles(e.getParentElement());
 
-			if (beginWorkCount == 0) {
+			if (beginWorkCount == 0)
 				VexWidgetImpl.this.relayout();
-			}
 
 			addEdit(e.getUndoableEdit(), getCaretOffset());
 			hostComponent.fireSelectionChanged();
 		}
 
-		public void beforeContentDeleted(DocumentEvent e) {
+		public void beforeContentDeleted(final DocumentEvent e) {
 		}
 
-		public void beforeContentInserted(DocumentEvent e) {
+		public void beforeContentInserted(final DocumentEvent e) {
 		}
 
-		public void contentDeleted(DocumentEvent e) {
+		public void contentDeleted(final DocumentEvent e) {
 			invalidateElementBox(e.getParentElement());
 
-			if (beginWorkCount == 0) {
+			if (beginWorkCount == 0)
 				VexWidgetImpl.this.relayout();
-			}
 
 			addEdit(e.getUndoableEdit(), getCaretOffset());
 		}
 
-		public void contentInserted(DocumentEvent e) {
+		public void contentInserted(final DocumentEvent e) {
 			invalidateElementBox(e.getParentElement());
 
-			if (beginWorkCount == 0) {
+			if (beginWorkCount == 0)
 				VexWidgetImpl.this.relayout();
-			}
 
 			addEdit(e.getUndoableEdit(), getCaretOffset());
 		}
@@ -170,16 +170,16 @@
 	/**
 	 * Class constructor.
 	 */
-	public VexWidgetImpl(HostComponent hostComponent) {
+	public VexWidgetImpl(final HostComponent hostComponent) {
 		this.hostComponent = hostComponent;
 	}
 
 	public void beginWork() {
-		if (this.beginWorkCount == 0) {
-			this.beginWorkCaretOffset = this.getCaretOffset();
-			this.compoundEdit = new CompoundEdit();
+		if (beginWorkCount == 0) {
+			beginWorkCaretOffset = getCaretOffset();
+			compoundEdit = new CompoundEdit();
 		}
-		this.beginWorkCount++;
+		beginWorkCount++;
 	}
 
 	/**
@@ -189,202 +189,170 @@
 	 * @param frag
 	 *            DocumentFragment to be inserted.
 	 */
-	public boolean canInsertFragment(DocumentFragment frag) {
+	public boolean canInsertFragment(final DocumentFragment frag) {
 
-		Document doc = this.getDocument();
-		if (doc == null) {
+		final Document doc = getDocument();
+		if (doc == null)
 			return false;
-		}
 
-		Validator validator = doc.getValidator();
-		if (validator == null) {
+		final Validator validator = doc.getValidator();
+		if (validator == null)
 			return true;
+
+		int startOffset = getCaretOffset();
+		int endOffset = getCaretOffset();
+		if (hasSelection()) {
+			startOffset = getSelectionStart();
+			endOffset = getSelectionEnd();
 		}
 
-		int startOffset = this.getCaretOffset();
-		int endOffset = this.getCaretOffset();
-		if (this.hasSelection()) {
-			startOffset = this.getSelectionStart();
-			endOffset = this.getSelectionEnd();
-		}
+		final Element parent = getDocument().getElementAt(startOffset);
+		final List<QualifiedName> seq1 = doc.getNodeNames(parent.getStartOffset() + 1, startOffset);
+		final List<QualifiedName> seq2 = frag.getNodeNames();
+		final List<QualifiedName> seq3 = doc.getNodeNames(endOffset, parent.getEndOffset());
 
-		Element parent = this.getDocument().getElementAt(startOffset);
-		List<String> seq1 = doc.getNodeNames(parent.getStartOffset() + 1,
-				startOffset);
-
-		List<String> seq2 = frag.getNodeNames();
-		
-		List<String> seq3 = doc.getNodeNames(endOffset, parent.getEndOffset());
-
-
-		return validator.isValidSequence(parent.getName(), seq1, seq2, seq3,
-				true);
+		return validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true);
 	}
 
 	/**
 	 * Returns true if text can be inserted at the current position.
 	 */
 	public boolean canInsertText() {
-
-		Document doc = this.getDocument();
-		if (doc == null) {
+		final Document doc = getDocument();
+		if (doc == null)
 			return false;
-		}
 
-		Validator validator = this.document.getValidator();
-		if (validator == null) {
+		final Validator validator = document.getValidator();
+		if (validator == null)
 			return true;
+
+		int startOffset = getCaretOffset();
+		int endOffset = getCaretOffset();
+		if (hasSelection()) {
+			startOffset = getSelectionStart();
+			endOffset = getSelectionEnd();
 		}
 
-		int startOffset = this.getCaretOffset();
-		int endOffset = this.getCaretOffset();
-		if (this.hasSelection()) {
-			startOffset = this.getSelectionStart();
-			endOffset = this.getSelectionEnd();
-		}
+		final Element parent = getDocument().getElementAt(startOffset);
+		final List<QualifiedName> seq1 = doc.getNodeNames(parent.getStartOffset() + 1, startOffset);
+		final List<QualifiedName> seq2 = Collections.singletonList(Validator.PCDATA);
+		final List<QualifiedName> seq3 = doc.getNodeNames(endOffset, parent.getEndOffset());
 
-		Element parent = this.getDocument().getElementAt(startOffset);
-		List<String> seq1 = doc.getNodeNames(parent.getStartOffset() + 1,
-				startOffset);
-
-		List<String> seq2 = new ArrayList<String>();
-		seq2.add(Validator.PCDATA);
-		
-		List<String> seq3 = doc.getNodeNames(endOffset, parent.getEndOffset());
-
-
-		return validator.isValidSequence(parent.getName(), seq1, seq2, seq3,
-				true);
+		return validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true);
 	}
 
 	public boolean canPaste() {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public boolean canPasteText() {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public boolean canRedo() {
-		return !this.redoList.isEmpty();
+		return !redoList.isEmpty();
 	}
 
 	public boolean canUndo() {
-		return !this.undoList.isEmpty();
+		return !undoList.isEmpty();
 	}
 
 	public boolean canUnwrap() {
-		Document doc = this.getDocument();
-		if (doc == null) {
+		final Document doc = getDocument();
+		if (doc == null)
 			return false;
-		}
 
-		Validator validator = doc.getValidator();
-		if (validator == null) {
+		final Validator validator = doc.getValidator();
+		if (validator == null)
 			return false;
-		}
 
-		Element element = doc.getElementAt(this.getCaretOffset());
-		Element parent = element.getParent();
-		if (parent == null) {
+		final Element element = doc.getElementAt(getCaretOffset());
+		final Element parent = element.getParent();
+		if (parent == null)
 			// can't unwrap the root
 			return false;
-		}
 
-		List<String> seq1 = doc.getNodeNames(parent.getStartOffset() + 1, element
-				.getStartOffset());
-		
-		List<String> seq2 = doc.getNodeNames(element.getStartOffset() + 1, element
-				.getEndOffset());
+		final List<QualifiedName> seq1 = doc.getNodeNames(parent.getStartOffset() + 1, element.getStartOffset());
+		final List<QualifiedName> seq2 = doc.getNodeNames(element.getStartOffset() + 1, element.getEndOffset());
+		final List<QualifiedName> seq3 = doc.getNodeNames(element.getEndOffset() + 1, parent.getEndOffset());
 
-		List<String> seq3 = doc.getNodeNames(element.getEndOffset() + 1, parent
-				.getEndOffset());
-
-
-		return validator.isValidSequence(parent.getName(), seq1, seq2, seq3,
-				true);
+		return validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true);
 	}
 
 	public void copySelection() {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public void cutSelection() {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public void deleteNextChar() throws DocumentValidationException {
-		if (this.hasSelection()) {
-			this.deleteSelection();
-		} else {
-			int offset = this.getCaretOffset();
-			Document doc = this.getDocument();
-			int n = doc.getLength() - 1;
-			Element element = doc.getElementAt(offset);
+		if (hasSelection())
+			deleteSelection();
+		else {
+			final int offset = getCaretOffset();
+			final Document doc = getDocument();
+			final int n = doc.getLength() - 1;
+			final Element element = doc.getElementAt(offset);
 
 			if (offset == n) {
 				// nop
-			} else if (this.isBetweenMatchingElements(offset)) {
-				this.joinElementsAt(offset);
-			} else if (this.isBetweenMatchingElements(offset + 1)) {
-				this.joinElementsAt(offset + 1);
-			} else if (element.isEmpty()) {
+			} else if (isBetweenMatchingElements(offset))
+				joinElementsAt(offset);
+			else if (isBetweenMatchingElements(offset + 1))
+				joinElementsAt(offset + 1);
+			else if (element.isEmpty()) {
 				// deleting the right sentinel of an empty element
 				// so just delete the whole element an move on
 				this.moveTo(offset - 1, false);
 				this.moveTo(offset + 1, true);
-				this.deleteSelection();
+				deleteSelection();
 			} else if (doc.getElementAt(offset + 1).isEmpty()) {
 				// deleting the left sentinel of an empty element
 				// so just delete the whole element an move on
 				this.moveTo(offset + 2, true);
-				this.deleteSelection();
-			} else {
-				if (doc.getCharacterAt(offset) != 0) {
-					this.moveTo(offset, false);
-					this.moveTo(offset + 1, true);
-					this.deleteSelection();
-				}
+				deleteSelection();
+			} else if (doc.getCharacterAt(offset) != 0) {
+				this.moveTo(offset, false);
+				this.moveTo(offset + 1, true);
+				deleteSelection();
 			}
 		}
 	}
 
 	public void deletePreviousChar() throws DocumentValidationException {
 
-		if (this.hasSelection()) {
-			this.deleteSelection();
-		} else {
-			int offset = this.getCaretOffset();
-			Document doc = this.getDocument();
-			Element element = doc.getElementAt(offset);
+		if (hasSelection())
+			deleteSelection();
+		else {
+			int offset = getCaretOffset();
+			final Document doc = getDocument();
+			final Element element = doc.getElementAt(offset);
 
 			if (offset == 1) {
 				// nop
-			} else if (this.isBetweenMatchingElements(offset)) {
-				this.joinElementsAt(offset);
-			} else if (this.isBetweenMatchingElements(offset - 1)) {
-				this.joinElementsAt(offset - 1);
-			} else if (element.isEmpty()) {
+			} else if (isBetweenMatchingElements(offset))
+				joinElementsAt(offset);
+			else if (isBetweenMatchingElements(offset - 1))
+				joinElementsAt(offset - 1);
+			else if (element.isEmpty()) {
 				// deleting the left sentinel of an empty element
 				// so just delete the whole element an move on
 				this.moveTo(offset - 1, false);
 				this.moveTo(offset + 1, true);
-				this.deleteSelection();
+				deleteSelection();
 			} else if (doc.getElementAt(offset - 1).isEmpty()) {
 				// deleting the right sentinel of an empty element
 				// so just delete the whole element an move on
 				this.moveTo(offset - 2, true);
-				this.deleteSelection();
+				deleteSelection();
 			} else {
 				offset--;
 				if (doc.getCharacterAt(offset) != 0) {
 					this.moveTo(offset, false);
 					this.moveTo(offset + 1, true);
-					this.deleteSelection();
+					deleteSelection();
 				}
 			}
 		}
@@ -393,71 +361,65 @@
 
 	public void deleteSelection() {
 		try {
-			if (this.hasSelection()) {
-				this.document.delete(this.getSelectionStart(), this
-						.getSelectionEnd());
-				this.moveTo(this.getSelectionStart());
+			if (hasSelection()) {
+				document.delete(getSelectionStart(), getSelectionEnd());
+				this.moveTo(getSelectionStart());
 			}
-		} catch (DocumentValidationException ex) {
+		} catch (final DocumentValidationException ex) {
 			ex.printStackTrace(); // This should never happen, because we
 			// constrain the selection
 		}
 	}
 
-	public void doWork(Runnable runnable) {
+	public void doWork(final Runnable runnable) {
 		this.doWork(false, runnable);
 	}
 
-	public void doWork(boolean savePosition, Runnable runnable) {
+	public void doWork(final boolean savePosition, final Runnable runnable) {
 		Position position = null;
 
-		if (savePosition) {
-			position = this.getDocument().createPosition(this.getCaretOffset());
-		}
+		if (savePosition)
+			position = getDocument().createPosition(getCaretOffset());
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 			runnable.run();
 			success = true;
-		} catch (Exception ex) {
+		} catch (final Exception ex) {
 			ex.printStackTrace();
 		} finally {
-			this.endWork(success);
-			if (position != null) {
+			endWork(success);
+			if (position != null)
 				this.moveTo(position.getOffset());
-			}
 		}
 	}
 
-	public void endWork(boolean success) {
-		this.beginWorkCount--;
-		if (this.beginWorkCount == 0) {
+	public void endWork(final boolean success) {
+		beginWorkCount--;
+		if (beginWorkCount == 0) {
 			// this.compoundEdit.end();
 			if (success) {
-				this.undoList.add(new UndoableAndOffset(this.compoundEdit,
-						this.beginWorkCaretOffset));
-				this.undoDepth++;
-				if (undoList.size() > MAX_UNDO_STACK_SIZE) {
+				undoList.add(new UndoableAndOffset(compoundEdit, beginWorkCaretOffset));
+				undoDepth++;
+				if (undoList.size() > MAX_UNDO_STACK_SIZE)
 					undoList.removeFirst();
-				}
-				this.redoList.clear();
-				this.relayout();
-				this.hostComponent.fireSelectionChanged();
-			} else {
+				redoList.clear();
+				relayout();
+				hostComponent.fireSelectionChanged();
+			} else
 				try {
-					this.compoundEdit.undo();
-					this.moveTo(this.beginWorkCaretOffset);
-				} catch (CannotUndoException e) {
+					compoundEdit.undo();
+					this.moveTo(beginWorkCaretOffset);
+				} catch (final CannotUndoException e) {
 					// TODO: handle exception
 				}
-			}
-			this.compoundEdit = null;
+			compoundEdit = null;
 		}
 	}
 
-	public Box findInnermostBox(IBoxFilter filter) {
-		return this.findInnermostBox(filter, this.getCaretOffset());
+	public Box findInnermostBox(final IBoxFilter filter) {
+		return this.findInnermostBox(filter, getCaretOffset());
 	}
 
 	/**
@@ -469,34 +431,27 @@
 	 * @param offset
 	 *            Document offset around which to search.
 	 */
-	private Box findInnermostBox(IBoxFilter filter, int offset) {
+	private Box findInnermostBox(final IBoxFilter filter, final int offset) {
 
-		Box box = this.rootBox.getChildren()[0];
+		Box box = rootBox.getChildren()[0];
 		Box matchingBox = null;
 
 		for (;;) {
-			if (filter.matches(box)) {
+			if (filter.matches(box))
 				matchingBox = box;
-			}
 
-			Box original = box;
-			Box[] children = box.getChildren();
-			for (int i = 0; i < children.length; i++) {
-
-				Box child = children[i];
-
-				if (child.hasContent() && offset >= child.getStartOffset()
-						&& offset <= child.getEndOffset()) {
+			final Box original = box;
+			final Box[] children = box.getChildren();
+			for (final Box child : children)
+				if (child.hasContent() && offset >= child.getStartOffset() && offset <= child.getEndOffset()) {
 					box = child;
 					break;
 				}
-			}
 
-			if (box == original) {
+			if (box == original)
 				// No child found containing offset,
 				// so just return the latest match.
 				return matchingBox;
-			}
 		}
 
 	}
@@ -506,31 +461,30 @@
 	 * background color of the root element.
 	 */
 	public Color getBackgroundColor() {
-		return this.styleSheet.getStyles(this.document.getRootElement())
-				.getBackgroundColor();
+		return styleSheet.getStyles(document.getRootElement()).getBackgroundColor();
 	}
 
 	public BoxFactory getBoxFactory() {
-		return this.boxFactory;
+		return boxFactory;
 	}
 
 	/**
 	 * Returns the current caret.
 	 */
 	public Caret getCaret() {
-		return this.caret;
+		return caret;
 	}
 
 	public int getCaretOffset() {
-		return this.caretOffset;
+		return caretOffset;
 	}
 
 	public Element getCurrentElement() {
-		return this.currentElement;
+		return currentElement;
 	}
 
 	public Document getDocument() {
-		return this.document;
+		return document;
 	}
 
 	/**
@@ -538,67 +492,77 @@
 	 * width.
 	 */
 	public int getHeight() {
-		return this.rootBox.getHeight();
+		return rootBox.getHeight();
 	}
 
 	public String[] getValidInsertElements() {
+		final Document doc = getDocument();
+		if (doc == null)
+			return new String[0];
 
-		Document doc = this.getDocument();
-		if (doc == null) return new String[0];
+		final Validator validator = doc.getValidator();
+		if (validator == null)
+			return new String[0];
 
-		Validator validator = doc.getValidator();
-		if (validator == null) return new String[0];
-
-		int startOffset = this.getCaretOffset();
-		int endOffset = this.getCaretOffset();
-		if (this.hasSelection()) {
-			startOffset = this.getSelectionStart();
-			endOffset = this.getSelectionEnd();
+		int startOffset = getCaretOffset();
+		int endOffset = getCaretOffset();
+		if (hasSelection()) {
+			startOffset = getSelectionStart();
+			endOffset = getSelectionEnd();
 		}
 
-		Element parent = doc.getElementAt(startOffset);
-		
-		Set<String> validItems = validator.getValidItems(parent.getName());
-		List<String> candidates = new ArrayList<String>(validItems);
-		candidates.remove(Validator.PCDATA);
-		
+		final Element parent = doc.getElementAt(startOffset);
+
+		final List<QualifiedName> candidates = createCandidatesList(validator, parent, Validator.PCDATA);
+
 		// filter invalid sequences
-		List<String> nodesBefore = doc.getNodeNames(parent.getStartOffset() + 1, startOffset);
-		List<String> nodesAfter = doc.getNodeNames(endOffset, parent.getEndOffset());
-		int sequenceLength = nodesBefore.size() + 1 + nodesAfter.size();
-		for (Iterator<String> iter = candidates.iterator(); iter.hasNext();) {
-			String candidate = iter.next();
-			List<String> sequence = new ArrayList<String>(sequenceLength);
+		final List<QualifiedName> nodesBefore = doc.getNodeNames(parent.getStartOffset() + 1, startOffset);
+		final List<QualifiedName> nodesAfter = doc.getNodeNames(endOffset, parent.getEndOffset());
+		final int sequenceLength = nodesBefore.size() + 1 + nodesAfter.size();
+		for (final Iterator<QualifiedName> iter = candidates.iterator(); iter.hasNext();) {
+			final QualifiedName candidate = iter.next();
+			final List<QualifiedName> sequence = new ArrayList<QualifiedName>(sequenceLength);
 			sequence.addAll(nodesBefore);
 			sequence.add(candidate);
 			sequence.addAll(nodesAfter);
-			if (!validator.isValidSequence(parent.getName(), sequence, true)) {
+			if (!validator.isValidSequence(parent.getQualifiedName(), sequence, true))
 				iter.remove();
-			}
 		}
 
-		// If there's a selection, root out those candidates that can't
-		// contain it.
+		// If there's a selection, root out those candidates that can't contain it.
 		if (hasSelection()) {
-			List<String> selectedNodes = doc.getNodeNames(startOffset, endOffset);
+			final List<QualifiedName> selectedNodes = doc.getNodeNames(startOffset, endOffset);
 
-			for (Iterator<String> iter = candidates.iterator(); iter.hasNext();) {
-				String candidate = iter.next();
-				if (!validator.isValidSequence(candidate, selectedNodes, true)) {
+			for (final Iterator<QualifiedName> iter = candidates.iterator(); iter.hasNext();) {
+				final QualifiedName candidate = iter.next();
+				if (!validator.isValidSequence(candidate, selectedNodes, true))
 					iter.remove();
-				}
 			}
 		}
 
-		Collections.sort(candidates);
-		return (String[]) candidates.toArray(new String[candidates.size()]);
+		Collections.sort(candidates, new QualifiedNameComparator());
+		final String[] result = new String[candidates.size()];
+		int i = 0;
+		for (QualifiedName candidate : candidates)
+			result[i++] = candidate.getLocalName(); // TODO handle namespaces in VexWidget
+		return result;
+	}
+
+	private static List<QualifiedName> createCandidatesList(final Validator validator, final Element parent, final QualifiedName... exceptions) {
+		final Set<QualifiedName> validItems = validator.getValidItems(parent.getQualifiedName());
+		final List<QualifiedName> exceptionItems = Arrays.asList(exceptions);
+		final List<QualifiedName> result = new ArrayList<QualifiedName>();
+		for (final QualifiedName validItem : validItems)
+			if (!exceptionItems.contains(validItem))
+				result.add(validItem);
+		return result;
 	}
 
 	/**
 	 * Returns the value of the antiAliased flag.
 	 */
 	public boolean isAntiAliased() {
-		return this.antiAliased;
+		return antiAliased;
 	}
 
 	public boolean isDebugging() {
@@ -606,269 +570,244 @@
 	}
 
 	public String[] getValidMorphElements() {
+		final Document doc = getDocument();
+		if (doc == null)
+			return new String[0];
 
-		Document doc = this.getDocument();
-		if (doc == null) return new String[0];
+		final Validator validator = doc.getValidator();
+		if (validator == null)
+			return new String[0];
 
-		Validator validator = doc.getValidator();
-		if (validator == null) return new String[0];
-
-		Element element = doc.getElementAt(this.getCaretOffset());
-		Element parent = element.getParent();
-		if (parent == null) {
+		final Element element = doc.getElementAt(getCaretOffset());
+		final Element parent = element.getParent();
+		if (parent == null)
 			// can't morph the root
 			return new String[0];
-		}
 
-		Set<String> validItems = validator.getValidItems(parent.getName());
-		List<String> result = new ArrayList<String>(validItems);
-		result.remove(Validator.PCDATA);
-		result.remove(element.getName()); // exclude converting to the same
+		final List<QualifiedName> result = createCandidatesList(validator, parent, Validator.PCDATA, element.getQualifiedName());
 
 		// root out those that can't contain the current content
-		List<String> content = doc.getNodeNames(element.getStartOffset() + 1,
-				element.getEndOffset());
-		
-		for (Iterator<String> iter = result.iterator(); iter.hasNext();) {
-			String candidate = iter.next();
-			if (!validator.isValidSequence(candidate, content, true)) {
+		final List<QualifiedName> content = doc.getNodeNames(element.getStartOffset() + 1, element.getEndOffset());
+
+		for (final Iterator<QualifiedName> iter = result.iterator(); iter.hasNext();) {
+			final QualifiedName candidate = iter.next();
+			if (!validator.isValidSequence(candidate, content, true))
 				iter.remove();
-			}
 		}
 
-		Collections.sort(result);
+		Collections.sort(result, new QualifiedNameComparator());
 		return result.toArray(new String[result.size()]);
 	}
 
 	public int getSelectionEnd() {
-		return this.selectionEnd;
+		return selectionEnd;
 	}
 
 	public int getSelectionStart() {
-		return this.selectionStart;
+		return selectionStart;
 	}
 
 	public DocumentFragment getSelectedFragment() {
-		if (this.hasSelection()) {
-			return this.document.getFragment(this.getSelectionStart(), this
-					.getSelectionEnd());
-		} else {
+		if (hasSelection())
+			return document.getFragment(getSelectionStart(), getSelectionEnd());
+		else
 			return null;
-		}
 	}
 
 	public String getSelectedText() {
-		if (this.hasSelection()) {
-			return this.document.getText(this.getSelectionStart(), this
-					.getSelectionEnd());
-		} else {
+		if (hasSelection())
+			return document.getText(getSelectionStart(), getSelectionEnd());
+		else
 			return "";
-		}
 	}
 
 	public StyleSheet getStyleSheet() {
-		return this.styleSheet;
+		return styleSheet;
 	}
 
 	public int getUndoDepth() {
-		return this.undoDepth;
+		return undoDepth;
 	}
 
 	public int getLayoutWidth() {
-		return this.layoutWidth;
+		return layoutWidth;
 	}
 
 	public RootBox getRootBox() {
-		return this.rootBox;
+		return rootBox;
 	}
 
 	public boolean hasSelection() {
-		return this.getSelectionStart() != this.getSelectionEnd();
+		return getSelectionStart() != getSelectionEnd();
 	}
 
-	public void insertChar(char c) throws DocumentValidationException {
-		if (this.hasSelection()) {
-			this.deleteSelection();
-		}
-		this.document.insertText(this.getCaretOffset(), Character.toString(c));
+	public void insertChar(final char c) throws DocumentValidationException {
+		if (hasSelection())
+			deleteSelection();
+		document.insertText(getCaretOffset(), Character.toString(c));
 		this.moveBy(+1);
 	}
 
-	public void insertFragment(DocumentFragment frag)
-			throws DocumentValidationException {
+	public void insertFragment(final DocumentFragment frag) throws DocumentValidationException {
 
-		if (this.hasSelection()) {
-			this.deleteSelection();
-		}
+		if (hasSelection())
+			deleteSelection();
 
-		this.document.insertFragment(this.getCaretOffset(), frag);
-		this.moveTo(this.getCaretOffset() + frag.getLength());
+		document.insertFragment(getCaretOffset(), frag);
+		this.moveTo(getCaretOffset() + frag.getLength());
 	}
 
-	public void insertElement(Element element)
-			throws DocumentValidationException {
+	public void insertElement(final Element element) throws DocumentValidationException {
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 
 			DocumentFragment frag = null;
-			if (this.hasSelection()) {
-				frag = this.getSelectedFragment();
-				this.deleteSelection();
+			if (hasSelection()) {
+				frag = getSelectedFragment();
+				deleteSelection();
 			}
 
-			this.document.insertElement(this.getCaretOffset(), element);
-			this.moveTo(this.getCaretOffset() + 1);
-			if (frag != null) {
-				this.insertFragment(frag);
-			}
-			this.scrollCaretVisible();
+			document.insertElement(getCaretOffset(), element);
+			this.moveTo(getCaretOffset() + 1);
+			if (frag != null)
+				insertFragment(frag);
+			scrollCaretVisible();
 			success = true;
 		} finally {
-			this.endWork(success);
+			endWork(success);
 		}
 	}
 
-	public void insertText(String text) throws DocumentValidationException {
+	public void insertText(final String text) throws DocumentValidationException {
 
-		if (this.hasSelection()) {
-			this.deleteSelection();
-		}
+		if (hasSelection())
+			deleteSelection();
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 			int i = 0;
 			for (;;) {
-				int j = text.indexOf('\n', i);
-				if (j == -1) {
+				final int j = text.indexOf('\n', i);
+				if (j == -1)
 					break;
-				}
-				this.document.insertText(this.getCaretOffset(), text.substring(
-						i, j));
-				this.moveTo(this.getCaretOffset() + (j - i));
-				this.split();
+				document.insertText(getCaretOffset(), text.substring(i, j));
+				this.moveTo(getCaretOffset() + j - i);
+				split();
 				i = j + 1;
 			}
 
 			if (i < text.length()) {
-				this.document.insertText(this.getCaretOffset(), text
-						.substring(i));
-				this.moveTo(this.getCaretOffset() + (text.length() - i));
+				document.insertText(getCaretOffset(), text.substring(i));
+				this.moveTo(getCaretOffset() + text.length() - i);
 			}
 			success = true;
 		} finally {
-			this.endWork(success);
+			endWork(success);
 		}
 	}
 
-	public void morph(Element element) throws DocumentValidationException {
+	public void morph(final Element element) throws DocumentValidationException {
 
-		Document doc = this.getDocument();
-		int offset = this.getCaretOffset();
-		Element currentElement = doc.getElementAt(offset);
+		final Document doc = getDocument();
+		final int offset = getCaretOffset();
+		final Element currentElement = doc.getElementAt(offset);
 
-		if (currentElement == doc.getRootElement()) {
-			throw new DocumentValidationException(
-					"Cannot morph the root element.");
-		}
+		if (currentElement == doc.getRootElement())
+			throw new DocumentValidationException("Cannot morph the root element.");
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 			this.moveTo(currentElement.getStartOffset() + 1, false);
 			this.moveTo(currentElement.getEndOffset(), true);
-			DocumentFragment frag = this.getSelectedFragment();
-			this.deleteSelection();
+			final DocumentFragment frag = getSelectedFragment();
+			deleteSelection();
 			this.moveBy(-1, false);
 			this.moveBy(2, true);
-			this.deleteSelection();
-			this.insertElement(element);
-			if (frag != null) {
-				this.insertFragment(frag);
-			}
+			deleteSelection();
+			insertElement(element);
+			if (frag != null)
+				insertFragment(frag);
 			this.moveTo(offset, false);
 			success = true;
 		} finally {
-			this.endWork(success);
+			endWork(success);
 		}
 
 	}
 
-	public void moveBy(int distance) {
-		this.moveTo(this.getCaretOffset() + distance, false);
+	public void moveBy(final int distance) {
+		this.moveTo(getCaretOffset() + distance, false);
 	}
 
-	public void moveBy(int distance, boolean select) {
-		this.moveTo(this.getCaretOffset() + distance, select);
+	public void moveBy(final int distance, final boolean select) {
+		this.moveTo(getCaretOffset() + distance, select);
 	}
 
-	public void moveTo(int offset) {
+	public void moveTo(final int offset) {
 		this.moveTo(offset, false);
 	}
 
-	public void moveTo(int offset, boolean select) {
+	public void moveTo(final int offset, final boolean select) {
 
-		if (offset >= 1 && offset <= this.document.getLength() - 1) {
+		if (offset >= 1 && offset <= document.getLength() - 1) {
 
 			// repaint the selection area, if any
-			this.repaintCaret();
-			this.repaintRange(this.getSelectionStart(), this.getSelectionEnd());
+			repaintCaret();
+			repaintRange(getSelectionStart(), getSelectionEnd());
 
-			Element oldElement = this.currentElement;
+			final Element oldElement = currentElement;
 
-			this.caretOffset = offset;
+			caretOffset = offset;
 
-			this.currentElement = this.document.getElementAt(offset);
+			currentElement = document.getElementAt(offset);
 
 			if (select) {
-				this.selectionStart = Math.min(this.mark, this.caretOffset);
-				this.selectionEnd = Math.max(this.mark, this.caretOffset);
+				selectionStart = Math.min(mark, caretOffset);
+				selectionEnd = Math.max(mark, caretOffset);
 
 				// move selectionStart and selectionEnd to make sure we don't
 				// select a partial element
-				Element commonElement = this.document.findCommonElement(
-						this.selectionStart, this.selectionEnd);
+				final Element commonElement = document.findCommonElement(selectionStart, selectionEnd);
 
-				Element element = this.document
-						.getElementAt(this.selectionStart);
+				Element element = document.getElementAt(selectionStart);
 				while (element != commonElement) {
-					this.selectionStart = element.getStartOffset();
-					element = this.document.getElementAt(this.selectionStart);
+					selectionStart = element.getStartOffset();
+					element = document.getElementAt(selectionStart);
 				}
 
-				element = this.document.getElementAt(this.selectionEnd);
+				element = document.getElementAt(selectionEnd);
 				while (element != commonElement) {
-					this.selectionEnd = element.getEndOffset() + 1;
-					element = this.document.getElementAt(this.selectionEnd);
+					selectionEnd = element.getEndOffset() + 1;
+					element = document.getElementAt(selectionEnd);
 				}
 
 			} else {
-				this.mark = offset;
-				this.selectionStart = offset;
-				this.selectionEnd = offset;
+				mark = offset;
+				selectionStart = offset;
+				selectionEnd = offset;
 			}
 
-			if (this.beginWorkCount == 0) {
-				this.relayout();
-			}
+			if (beginWorkCount == 0)
+				relayout();
 
-			Graphics g = this.hostComponent.createDefaultGraphics();
-			LayoutContext context = this.createLayoutContext(g);
-			this.caret = this.rootBox.getCaret(context, offset);
+			final Graphics g = hostComponent.createDefaultGraphics();
+			final LayoutContext context = createLayoutContext(g);
+			caret = rootBox.getCaret(context, offset);
 
-			Element element = this.getCurrentElement();
+			Element element = getCurrentElement();
 			if (element != oldElement) {
-				this.caretColor = Color.BLACK;
+				caretColor = Color.BLACK;
 				while (element != null) {
-					Color bgColor = this.styleSheet.getStyles(element)
-							.getBackgroundColor();
+					final Color bgColor = styleSheet.getStyles(element).getBackgroundColor();
 					if (bgColor != null) {
-						int red = ~bgColor.getRed() & 0xff;
-						int green = ~bgColor.getGreen() & 0xff;
-						int blue = ~bgColor.getBlue() & 0xff;
-						this.caretColor = new Color(red, green, blue);
+						final int red = ~bgColor.getRed() & 0xff;
+						final int green = ~bgColor.getGreen() & 0xff;
+						final int blue = ~bgColor.getBlue() & 0xff;
+						caretColor = new Color(red, green, blue);
 						break;
 					}
 					element = element.getParent();
@@ -877,99 +816,83 @@
 
 			g.dispose();
 
-			this.magicX = -1;
+			magicX = -1;
 
-			this.scrollCaretVisible();
+			scrollCaretVisible();
 
-			this.hostComponent.fireSelectionChanged();
+			hostComponent.fireSelectionChanged();
 
-			this.caretVisible = true;
+			caretVisible = true;
 
-			this.repaintRange(this.getSelectionStart(), this.getSelectionEnd());
+			repaintRange(getSelectionStart(), getSelectionEnd());
 		}
 	}
 
-	public void moveToLineEnd(boolean select) {
-		this.moveTo(this.rootBox.getLineEndOffset(this.getCaretOffset()),
-				select);
+	public void moveToLineEnd(final boolean select) {
+		this.moveTo(rootBox.getLineEndOffset(getCaretOffset()), select);
 	}
 
-	public void moveToLineStart(boolean select) {
-		this.moveTo(this.rootBox.getLineStartOffset(this.getCaretOffset()),
-				select);
+	public void moveToLineStart(final boolean select) {
+		this.moveTo(rootBox.getLineStartOffset(getCaretOffset()), select);
 	}
 
-	public void moveToNextLine(boolean select) {
-		int x = this.magicX == -1 ? this.caret.getBounds().getX() : this.magicX;
+	public void moveToNextLine(final boolean select) {
+		final int x = magicX == -1 ? caret.getBounds().getX() : magicX;
 
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		int offset = this.rootBox.getNextLineOffset(
-				this.createLayoutContext(g), this.getCaretOffset(), x);
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final int offset = rootBox.getNextLineOffset(createLayoutContext(g), getCaretOffset(), x);
 		g.dispose();
 
 		this.moveTo(offset, select);
-		this.magicX = x;
+		magicX = x;
 	}
 
-	public void moveToNextPage(boolean select) {
-		int x = this.magicX == -1 ? this.caret.getBounds().getX() : this.magicX;
-		int y = this.caret.getY()
-				+ Math
-						.round(this.hostComponent.getViewport().getHeight() * 0.9f);
-		this.moveTo(this.viewToModel(x, y), select);
-		this.magicX = x;
+	public void moveToNextPage(final boolean select) {
+		final int x = magicX == -1 ? caret.getBounds().getX() : magicX;
+		final int y = caret.getY() + Math.round(hostComponent.getViewport().getHeight() * 0.9f);
+		this.moveTo(viewToModel(x, y), select);
+		magicX = x;
 	}
 
-	public void moveToNextWord(boolean select) {
-		Document doc = this.getDocument();
-		int n = doc.getLength() - 1;
-		int offset = this.getCaretOffset();
-		while (offset < n
-				&& !Character.isLetterOrDigit(doc.getCharacterAt(offset))) {
+	public void moveToNextWord(final boolean select) {
+		final Document doc = getDocument();
+		final int n = doc.getLength() - 1;
+		int offset = getCaretOffset();
+		while (offset < n && !Character.isLetterOrDigit(doc.getCharacterAt(offset)))
 			offset++;
-		}
 
-		while (offset < n
-				&& Character.isLetterOrDigit(doc.getCharacterAt(offset))) {
+		while (offset < n && Character.isLetterOrDigit(doc.getCharacterAt(offset)))
 			offset++;
-		}
 
 		this.moveTo(offset, select);
 	}
 
-	public void moveToPreviousLine(boolean select) {
-		int x = this.magicX == -1 ? this.caret.getBounds().getX() : this.magicX;
+	public void moveToPreviousLine(final boolean select) {
+		final int x = magicX == -1 ? caret.getBounds().getX() : magicX;
 
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		int offset = this.rootBox.getPreviousLineOffset(this
-				.createLayoutContext(g), this.getCaretOffset(), x);
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final int offset = rootBox.getPreviousLineOffset(createLayoutContext(g), getCaretOffset(), x);
 		g.dispose();
 
 		this.moveTo(offset, select);
-		this.magicX = x;
+		magicX = x;
 	}
 
-	public void moveToPreviousPage(boolean select) {
-		int x = this.magicX == -1 ? this.caret.getBounds().getX() : this.magicX;
-		int y = this.caret.getY()
-				- Math
-						.round(this.hostComponent.getViewport().getHeight() * 0.9f);
-		this.moveTo(this.viewToModel(x, y), select);
-		this.magicX = x;
+	public void moveToPreviousPage(final boolean select) {
+		final int x = magicX == -1 ? caret.getBounds().getX() : magicX;
+		final int y = caret.getY() - Math.round(hostComponent.getViewport().getHeight() * 0.9f);
+		this.moveTo(viewToModel(x, y), select);
+		magicX = x;
 	}
 
-	public void moveToPreviousWord(boolean select) {
-		Document doc = this.getDocument();
-		int offset = this.getCaretOffset();
-		while (offset > 1
-				&& !Character.isLetterOrDigit(doc.getCharacterAt(offset - 1))) {
+	public void moveToPreviousWord(final boolean select) {
+		final Document doc = getDocument();
+		int offset = getCaretOffset();
+		while (offset > 1 && !Character.isLetterOrDigit(doc.getCharacterAt(offset - 1)))
 			offset--;
-		}
 
-		while (offset > 1
-				&& Character.isLetterOrDigit(doc.getCharacterAt(offset - 1))) {
+		while (offset > 1 && Character.isLetterOrDigit(doc.getCharacterAt(offset - 1)))
 			offset--;
-		}
 
 		this.moveTo(offset, select);
 	}
@@ -985,13 +908,12 @@
 	 * @param y
 	 *            y-coordinate at which to draw the widget
 	 */
-	public void paint(Graphics g, int x, int y) {
+	public void paint(final Graphics g, final int x, final int y) {
 
-		if (this.rootBox == null) {
+		if (rootBox == null)
 			return;
-		}
 
-		LayoutContext context = this.createLayoutContext(g);
+		final LayoutContext context = createLayoutContext(g);
 
 		// Since we may be scrolling to sections of the document that have
 		// yet to be layed out, lay out any exposed area.
@@ -999,19 +921,15 @@
 		// TODO: this will probably be inaccurate, since we should really
 		// iterate the layout, but we don't have an offset around which
 		// to iterate...what to do, what to do....
-		Rectangle rect = g.getClipBounds();
-		int oldHeight = this.rootBox.getHeight();
-		this.rootBox.layout(context, rect.getY(), rect.getY()
-				+ rect.getHeight());
-		if (this.rootBox.getHeight() != oldHeight) {
-			this.hostComponent.setPreferredSize(this.rootBox.getWidth(),
-					this.rootBox.getHeight());
-		}
+		final Rectangle rect = g.getClipBounds();
+		final int oldHeight = rootBox.getHeight();
+		rootBox.layout(context, rect.getY(), rect.getY() + rect.getHeight());
+		if (rootBox.getHeight() != oldHeight)
+			hostComponent.setPreferredSize(rootBox.getWidth(), rootBox.getHeight());
 
-		this.rootBox.paint(context, 0, 0);
-		if (this.caretVisible) {
-			this.caret.draw(g, this.caretColor);
-		}
+		rootBox.paint(context, 0, 0);
+		if (caretVisible)
+			caret.draw(g, caretColor);
 
 		// Debug hash marks
 		/*
@@ -1025,39 +943,35 @@
 	}
 
 	public void paste() throws DocumentValidationException {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public void pasteText() throws DocumentValidationException {
-		throw new UnsupportedOperationException(
-				"Must be implemented in tookit-specific widget.");
+		throw new UnsupportedOperationException("Must be implemented in tookit-specific widget.");
 	}
 
 	public void redo() throws CannotRedoException {
-		if (redoList.isEmpty()) {
+		if (redoList.isEmpty())
 			throw new CannotRedoException();
-		}
-		UndoableAndOffset event = redoList.removeLast();
+		final UndoableAndOffset event = redoList.removeLast();
 		this.moveTo(event.caretOffset, false);
 		event.edit.redo();
-		this.undoList.add(event);
+		undoList.add(event);
 		undoDepth++;
 	}
 
-	public void removeAttribute(String attributeName) {
+	public void removeAttribute(final String attributeName) {
 		try {
-			Element element = this.getCurrentElement();
-			if (element.getAttribute(attributeName) != null) {
+			final Element element = getCurrentElement();
+			if (element.getAttribute(attributeName) != null)
 				element.removeAttribute(attributeName);
-			}
-		} catch (DocumentValidationException ex) {
+		} catch (final DocumentValidationException ex) {
 			ex.printStackTrace(); // TODO: when can this happen?
 		}
 	}
 
-	public void savePosition(Runnable runnable) {
-		Position pos = this.getDocument().createPosition(this.getCaretOffset());
+	public void savePosition(final Runnable runnable) {
+		final Position pos = getDocument().createPosition(getCaretOffset());
 		try {
 			runnable.run();
 		} finally {
@@ -1067,23 +981,18 @@
 
 	public void selectAll() {
 		this.moveTo(1);
-		this.moveTo(this.getDocument().getLength() - 1, true);
+		this.moveTo(getDocument().getLength() - 1, true);
 	}
 
 	public void selectWord() {
-		Document doc = this.getDocument();
-		int startOffset = this.getCaretOffset();
-		int endOffset = this.getCaretOffset();
-		while (startOffset > 1
-				&& Character.isLetterOrDigit(doc
-						.getCharacterAt(startOffset - 1))) {
+		final Document doc = getDocument();
+		int startOffset = getCaretOffset();
+		int endOffset = getCaretOffset();
+		while (startOffset > 1 && Character.isLetterOrDigit(doc.getCharacterAt(startOffset - 1)))
 			startOffset--;
-		}
-		int n = doc.getLength() - 1;
-		while (endOffset < n
-				&& Character.isLetterOrDigit(doc.getCharacterAt(endOffset))) {
+		final int n = doc.getLength() - 1;
+		while (endOffset < n && Character.isLetterOrDigit(doc.getCharacterAt(endOffset)))
 			endOffset++;
-		}
 
 		if (startOffset < endOffset) {
 			this.moveTo(startOffset, false);
@@ -1097,70 +1006,67 @@
 	 * @param antiAliased
 	 *            if true, text is rendered using antialiasing.
 	 */
-	public void setAntiAliased(boolean antiAliased) {
+	public void setAntiAliased(final boolean antiAliased) {
 		this.antiAliased = antiAliased;
 	}
 
-	public void setAttribute(String attributeName, String value) {
+	public void setAttribute(final String attributeName, final String value) {
 		try {
-			Element element = this.getCurrentElement();
-			if (value == null) {
-				this.removeAttribute(attributeName);
-			} else if (!value.equals(element.getAttribute(attributeName))) {
+			final Element element = getCurrentElement();
+			if (value == null)
+				removeAttribute(attributeName);
+			else if (!value.equals(element.getAttribute(attributeName)))
 				element.setAttribute(attributeName, value);
-			}
-		} catch (DocumentValidationException ex) {
+		} catch (final DocumentValidationException ex) {
 			ex.printStackTrace(); // TODO: mebbe throw the exception instead
 		}
 	}
 
-	public void setBoxFactory(BoxFactory boxFactory) {
+	public void setBoxFactory(final BoxFactory boxFactory) {
 		this.boxFactory = boxFactory;
-		if (this.document != null) {
-			this.relayout();
-		}
+		if (document != null)
+			relayout();
 	}
 
-	public void setDebugging(boolean debugging) {
+	public void setDebugging(final boolean debugging) {
 		this.debugging = debugging;
 	}
 
-	public void setDocument(Document document, StyleSheet styleSheet) {
+	public void setDocument(final Document document, final StyleSheet styleSheet) {
 		if (this.document != null) {
-			Document doc = (Document)document;
-			doc.removeDocumentListener(this.documentListener);
+			final Document doc = document;
+			doc.removeDocumentListener(documentListener);
 		}
 
 		this.document = document;
 		this.styleSheet = styleSheet;
 
-		this.undoList = new LinkedList<UndoableAndOffset>();
-		this.undoDepth = 0;
-		this.redoList = new LinkedList<UndoableAndOffset>();
-		this.beginWorkCount = 0;
-		this.compoundEdit = null;
+		undoList = new LinkedList<UndoableAndOffset>();
+		undoDepth = 0;
+		redoList = new LinkedList<UndoableAndOffset>();
+		beginWorkCount = 0;
+		compoundEdit = null;
 
-		this.createRootBox();
+		createRootBox();
 
 		this.moveTo(1);
-		((Document)this.document).addDocumentListener(this.documentListener);
+		this.document.addDocumentListener(documentListener);
 	}
 
-	public void setDocument(URL docUrl, URL ssURL) throws IOException,
-			ParserConfigurationException, SAXException {
+	public void setDocument(final URL docUrl, final URL ssURL) throws IOException, ParserConfigurationException, SAXException {
 
-		StyleSheetReader ssReader = new StyleSheetReader();
+		final StyleSheetReader ssReader = new StyleSheetReader();
 		final StyleSheet ss = ssReader.read(ssURL);
 
-		DocumentReader reader = new DocumentReader();
+		final DocumentReader reader = new DocumentReader();
 
 		reader.setWhitespacePolicyFactory(new IWhitespacePolicyFactory() {
-			public IWhitespacePolicy getPolicy(String publicId) {
+			public IWhitespacePolicy getPolicy(final String publicId) {
 				return new CssWhitespacePolicy(ss);
 			}
 		});
 
-		Document doc = reader.read(docUrl);
+		final Document doc = reader.read(docUrl);
 		this.setDocument(doc, ss);
 	}
 
@@ -1170,85 +1076,83 @@
 	 * @param focus
 	 *            true if the host component has focus
 	 */
-	public void setFocus(boolean focus) {
-		this.caretVisible = true;
-		this.repaintCaret();
+	public void setFocus(final boolean focus) {
+		caretVisible = true;
+		repaintCaret();
 	}
 
 	public void setLayoutWidth(int width) {
 		width = Math.max(width, MIN_LAYOUT_WIDTH);
-		if (this.getDocument() != null && width != this.getLayoutWidth()) {
+		if (getDocument() != null && width != getLayoutWidth())
 			// this.layoutWidth is set by relayoutAll
-			this.relayoutAll(width, this.styleSheet);
-		} else {
+			relayoutAll(width, styleSheet);
+		else
 			// maybe doc is null. Let's store layoutWidth so it's right
 			// when we set a doc
-			this.layoutWidth = width;
-		}
+			layoutWidth = width;
 	}
 
-	public void setStyleSheet(StyleSheet styleSheet) {
-		if (this.getDocument() != null) {
-			this.relayoutAll(this.layoutWidth, styleSheet);
-		}
+	public void setStyleSheet(final StyleSheet styleSheet) {
+		if (getDocument() != null)
+			relayoutAll(layoutWidth, styleSheet);
 	}
 
-	public void setStyleSheet(URL ssUrl) throws IOException {
-		StyleSheetReader reader = new StyleSheetReader();
-		StyleSheet ss = reader.read(ssUrl);
+	public void setStyleSheet(final URL ssUrl) throws IOException {
+		final StyleSheetReader reader = new StyleSheetReader();
+		final StyleSheet ss = reader.read(ssUrl);
 		this.setStyleSheet(ss);
 	}
 
 	public void split() throws DocumentValidationException {
 
-		long start = System.currentTimeMillis();
+		final long start = System.currentTimeMillis();
 
-		Document doc = this.getDocument();
-		Element element = doc.getElementAt(this.getCaretOffset());
-		Styles styles = this.getStyleSheet().getStyles(element);
+		final Document doc = getDocument();
+		Element element = doc.getElementAt(getCaretOffset());
+		Styles styles = getStyleSheet().getStyles(element);
 		while (!styles.isBlock()) {
 			element = element.getParent();
-			styles = this.getStyleSheet().getStyles(element);
+			styles = getStyleSheet().getStyles(element);
 		}
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 			if (styles.getWhiteSpace().equals(CSS.PRE)) {
 				// can't call this.insertText() or we'll get an infinite loop
-				int offset = this.getCaretOffset();
+				final int offset = getCaretOffset();
 				doc.insertText(offset, "\n");
 				this.moveTo(offset + 1);
 			} else {
 				DocumentFragment frag = null;
-				int offset = this.getCaretOffset();
-				boolean atEnd = (offset == element.getEndOffset());
+				int offset = getCaretOffset();
+				final boolean atEnd = offset == element.getEndOffset();
 				if (!atEnd) {
 					this.moveTo(element.getEndOffset(), true);
-					frag = this.getSelectedFragment();
-					this.deleteSelection();
+					frag = getSelectedFragment();
+					deleteSelection();
 				}
 
 				// either way, we are now at the end offset for the element
 				// let's move just outside
-				this.moveTo(this.getCaretOffset() + 1);
+				this.moveTo(getCaretOffset() + 1);
 
-				this.insertElement(new Element(element.getName()));
+				insertElement(new Element(element.getName()));
 				// TODO: clone attributes
 
 				if (!atEnd) {
-					offset = this.getCaretOffset();
-					this.insertFragment(frag);
+					offset = getCaretOffset();
+					insertFragment(frag);
 					this.moveTo(offset, false);
 				}
 			}
 			success = true;
 		} finally {
-			this.endWork(success);
+			endWork(success);
 		}
 
-		if (this.isDebugging()) {
-			long end = System.currentTimeMillis();
+		if (isDebugging()) {
+			final long end = System.currentTimeMillis();
 			System.out.println("split() took " + (end - start) + "ms");
 		}
 	}
@@ -1258,25 +1162,24 @@
 	 * be called from the GUI event thread at regular intervals.
 	 */
 	public void toggleCaret() {
-		this.caretVisible = !this.caretVisible;
-		this.repaintCaret();
+		caretVisible = !caretVisible;
+		repaintCaret();
 	}
 
 	public void undo() throws CannotUndoException {
-		if (undoList.isEmpty()) {
+		if (undoList.isEmpty())
 			throw new CannotUndoException();
-		}
-		UndoableAndOffset event = undoList.removeLast();
-		this.undoDepth--;
+		final UndoableAndOffset event = undoList.removeLast();
+		undoDepth--;
 		event.edit.undo();
 		this.moveTo(event.caretOffset, false);
-		this.redoList.add(event);
+		redoList.add(event);
 	}
 
-	public int viewToModel(int x, int y) {
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		LayoutContext context = this.createLayoutContext(g);
-		int offset = this.rootBox.viewToModel(context, x, y);
+	public int viewToModel(final int x, final int y) {
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final LayoutContext context = createLayoutContext(g);
+		final int offset = rootBox.viewToModel(context, x, y);
 		g.dispose();
 		return offset;
 	}
@@ -1290,7 +1193,7 @@
 		public IUndoableEdit edit;
 		public int caretOffset;
 
-		public UndoableAndOffset(IUndoableEdit edit, int caretOffset) {
+		public UndoableAndOffset(final IUndoableEdit edit, final int caretOffset) {
 			this.edit = edit;
 			this.caretOffset = caretOffset;
 		}
@@ -1305,26 +1208,21 @@
 	 *            Offset of the caret before the edit occurred. If the edit is
 	 *            undone, the caret is returned to this offset.
 	 */
-	private void addEdit(IUndoableEdit edit, int caretOffset) {
+	private void addEdit(final IUndoableEdit edit, final int caretOffset) {
 
-		if (edit == null) {
+		if (edit == null)
 			return;
-		}
 
-		if (compoundEdit != null) {
+		if (compoundEdit != null)
 			compoundEdit.addEdit(edit);
-		} else {
-			if (   !undoList.isEmpty()
-				&& undoList.getLast().edit.combine(edit)) {
-				return;
-			} else {
-				undoList.add(new UndoableAndOffset(edit, caretOffset));
-				undoDepth++;
-				if (undoList.size() > MAX_UNDO_STACK_SIZE) {
-					undoList.removeFirst();
-				}
-				redoList.clear();
-			}
+		else if (!undoList.isEmpty() && undoList.getLast().edit.combine(edit))
+			return;
+		else {
+			undoList.add(new UndoableAndOffset(edit, caretOffset));
+			undoDepth++;
+			if (undoList.size() > MAX_UNDO_STACK_SIZE)
+				undoList.removeFirst();
+			redoList.clear();
 		}
 	}
 
@@ -1335,29 +1233,28 @@
 	 *            The graphics context to use for the layout context.
 	 * @return the new layout context
 	 */
-	private LayoutContext createLayoutContext(Graphics g) {
-		LayoutContext context = new LayoutContext();
-		context.setBoxFactory(this.getBoxFactory());
-		context.setDocument(this.getDocument());
+	private LayoutContext createLayoutContext(final Graphics g) {
+		final LayoutContext context = new LayoutContext();
+		context.setBoxFactory(getBoxFactory());
+		context.setDocument(getDocument());
 		context.setGraphics(g);
-		context.setStyleSheet(this.getStyleSheet());
+		context.setStyleSheet(getStyleSheet());
 
-		if (this.hasSelection()) {
-			context.setSelectionStart(this.getSelectionStart());
-			context.setSelectionEnd(this.getSelectionEnd());
+		if (hasSelection()) {
+			context.setSelectionStart(getSelectionStart());
+			context.setSelectionEnd(getSelectionEnd());
 		} else {
-			context.setSelectionStart(this.getCaretOffset());
-			context.setSelectionEnd(this.getCaretOffset());
+			context.setSelectionStart(getCaretOffset());
+			context.setSelectionEnd(getCaretOffset());
 		}
 
 		return context;
 	}
 
 	private void createRootBox() {
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		LayoutContext context = this.createLayoutContext(g);
-		this.rootBox = new RootBox(context, this.document.getRootElement(),
-				this.getLayoutWidth());
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final LayoutContext context = createLayoutContext(g);
+		rootBox = new RootBox(context, document.getRootElement(), getLayoutWidth());
 		g.dispose();
 	}
 
@@ -1370,20 +1267,15 @@
 	 */
 	private void invalidateElementBox(final Element element) {
 
-		BlockBox elementBox = (BlockBox) this
-				.findInnermostBox(new IBoxFilter() {
-					public boolean matches(Box box) {
-						return box instanceof BlockBox
-								&& box.getElement() != null
-								&& box.getStartOffset() <= element
-										.getStartOffset() + 1
-								&& box.getEndOffset() >= element.getEndOffset();
-					}
-				});
+		final BlockBox elementBox = (BlockBox) this.findInnermostBox(new IBoxFilter() {
+			public boolean matches(final Box box) {
+				return box instanceof BlockBox && box.getElement() != null && box.getStartOffset() <= element.getStartOffset() + 1
+						&& box.getEndOffset() >= element.getEndOffset();
+			}
+		});
 
-		if (elementBox != null) {
+		if (elementBox != null)
 			elementBox.invalidate(true);
-		}
 	}
 
 	/**
@@ -1393,14 +1285,12 @@
 	 * 
 	 * @param int offset The offset to check.
 	 */
-	private boolean isBetweenMatchingElements(int offset) {
-		if (offset <= 1 || offset >= this.getDocument().getLength() - 1) {
+	private boolean isBetweenMatchingElements(final int offset) {
+		if (offset <= 1 || offset >= getDocument().getLength() - 1)
 			return false;
-		}
-		Element e1 = this.getDocument().getElementAt(offset - 1);
-		Element e2 = this.getDocument().getElementAt(offset + 1);
-		return e1 != e2 && e1.getParent() == e2.getParent()
-				&& e1.getName().equals(e2.getName());
+		final Element e1 = getDocument().getElementAt(offset - 1);
+		final Element e2 = getDocument().getElementAt(offset + 1);
+		return e1 != e2 && e1.getParent() == e2.getParent() && e1.getName().equals(e2.getName());
 	}
 
 	/**
@@ -1411,40 +1301,35 @@
 	 * @param offset
 	 *            Offset around which we should lay out boxes.
 	 */
-	private void iterateLayout(int offset) {
+	private void iterateLayout(final int offset) {
 
 		int repaintStart = Integer.MAX_VALUE;
 		int repaintEnd = 0;
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		LayoutContext context = this.createLayoutContext(g);
-		int layoutY = this.rootBox.getCaret(context, offset).getY();
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final LayoutContext context = createLayoutContext(g);
+		int layoutY = rootBox.getCaret(context, offset).getY();
 
 		while (true) {
 
-			int oldLayoutY = layoutY;
-			IntRange repaintRange = this.rootBox.layout(context, layoutY
-					- LAYOUT_WINDOW / 2, layoutY + LAYOUT_WINDOW / 2);
+			final int oldLayoutY = layoutY;
+			final IntRange repaintRange = rootBox.layout(context, layoutY - LAYOUT_WINDOW / 2, layoutY + LAYOUT_WINDOW / 2);
 			if (repaintRange != null) {
 				repaintStart = Math.min(repaintStart, repaintRange.getStart());
 				repaintEnd = Math.max(repaintEnd, repaintRange.getEnd());
 			}
 
-			layoutY = this.rootBox.getCaret(context, offset).getY();
-			if (Math.abs(layoutY - oldLayoutY) < LAYOUT_TOLERANCE) {
+			layoutY = rootBox.getCaret(context, offset).getY();
+			if (Math.abs(layoutY - oldLayoutY) < LAYOUT_TOLERANCE)
 				break;
-			}
 		}
 		g.dispose();
 
 		if (repaintStart < repaintEnd) {
-			Rectangle viewport = this.hostComponent.getViewport();
-			if (repaintStart < viewport.getY() + viewport.getHeight()
-					&& repaintEnd > viewport.getY()) {
-				int start = Math.max(repaintStart, viewport.getY());
-				int end = Math.min(repaintEnd, viewport.getY()
-						+ viewport.getHeight());
-				this.hostComponent.repaint(viewport.getX(), start, viewport
-						.getWidth(), end - start);
+			final Rectangle viewport = hostComponent.getViewport();
+			if (repaintStart < viewport.getY() + viewport.getHeight() && repaintEnd > viewport.getY()) {
+				final int start = Math.max(repaintStart, viewport.getY());
+				final int end = Math.min(repaintEnd, viewport.getY() + viewport.getHeight());
+				hostComponent.repaint(viewport.getX(), start, viewport.getWidth(), end - start);
 			}
 		}
 	}
@@ -1457,37 +1342,35 @@
 	 * @param offset
 	 *            Offset where the two elements meet.
 	 */
-	private void joinElementsAt(int offset) throws DocumentValidationException {
+	private void joinElementsAt(final int offset) throws DocumentValidationException {
 
-		if (!isBetweenMatchingElements(offset)) {
-			throw new DocumentValidationException(
-					"Cannot join elements at offset " + offset);
-		}
+		if (!isBetweenMatchingElements(offset))
+			throw new DocumentValidationException("Cannot join elements at offset " + offset);
 
 		boolean success = false;
 		try {
-			this.beginWork();
+			beginWork();
 			this.moveTo(offset + 1);
-			Element element = this.getCurrentElement();
-			boolean moveContent = !element.isEmpty();
+			final Element element = getCurrentElement();
+			final boolean moveContent = !element.isEmpty();
 			DocumentFragment frag = null;
 			if (moveContent) {
 				this.moveTo(element.getEndOffset(), true);
-				frag = this.getSelectedFragment();
-				this.deleteSelection();
+				frag = getSelectedFragment();
+				deleteSelection();
 			}
 			this.moveBy(-1);
 			this.moveBy(2, true);
-			this.deleteSelection();
+			deleteSelection();
 			this.moveBy(-1);
 			if (moveContent) {
-				int savedOffset = this.getCaretOffset();
-				this.insertFragment(frag);
+				final int savedOffset = getCaretOffset();
+				insertFragment(frag);
 				this.moveTo(savedOffset, false);
 			}
 			success = true;
 		} finally {
-			this.endWork(success);
+			endWork(success);
 		}
 	}
 
@@ -1496,24 +1379,22 @@
 	 */
 	private void relayout() {
 
-		long start = System.currentTimeMillis();
+		final long start = System.currentTimeMillis();
 
-		int oldHeight = this.rootBox.getHeight();
+		final int oldHeight = rootBox.getHeight();
 
-		this.iterateLayout(this.getCaretOffset());
+		iterateLayout(getCaretOffset());
 
-		if (this.rootBox.getHeight() != oldHeight) {
-			this.hostComponent.setPreferredSize(this.rootBox.getWidth(),
-					this.rootBox.getHeight());
-		}
+		if (rootBox.getHeight() != oldHeight)
+			hostComponent.setPreferredSize(rootBox.getWidth(), rootBox.getHeight());
 
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		LayoutContext context = this.createLayoutContext(g);
-		this.caret = this.rootBox.getCaret(context, this.getCaretOffset());
+		final Graphics g = hostComponent.createDefaultGraphics();
+		final LayoutContext context = createLayoutContext(g);
+		caret = rootBox.getCaret(context, getCaretOffset());
 		g.dispose();
 
-		if (this.isDebugging()) {
-			long end = System.currentTimeMillis();
+		if (isDebugging()) {
+			final long end = System.currentTimeMillis();
 			System.out.println("VexWidget layout took " + (end - start) + "ms");
 		}
 	}
@@ -1530,12 +1411,12 @@
 	 * @param newStyleSheet
 	 *            New stylesheet for the widget.
 	 */
-	private void relayoutAll(int newWidth, StyleSheet newStyleSheet) {
+	private void relayoutAll(final int newWidth, final StyleSheet newStyleSheet) {
 
-		Graphics g = this.hostComponent.createDefaultGraphics();
-		LayoutContext context = this.createLayoutContext(g);
+		final Graphics g = hostComponent.createDefaultGraphics();
+		LayoutContext context = createLayoutContext(g);
 
-		Rectangle viewport = this.hostComponent.getViewport();
+		final Rectangle viewport = hostComponent.getViewport();
 
 		// true if the caret is within the viewport
 		//
@@ -1543,7 +1424,7 @@
 		// shrinking
 		// To fix, we probably need to save the viewport height, just like
 		// we now store viewport width (as layout width).
-		boolean caretVisible = viewport.intersects(this.caret.getBounds());
+		final boolean caretVisible = viewport.intersects(caret.getBounds());
 
 		// distance from the top of the viewport to the top of the caret
 		// use this if the caret is visible in the viewport
@@ -1555,43 +1436,39 @@
 		int offset;
 
 		if (caretVisible) {
-			relCaretY = this.caret.getY() - viewport.getY();
-			offset = this.getCaretOffset();
-		} else {
-			offset = this.rootBox.viewToModel(context, 0, viewport.getY());
-		}
+			relCaretY = caret.getY() - viewport.getY();
+			offset = getCaretOffset();
+		} else
+			offset = rootBox.viewToModel(context, 0, viewport.getY());
 
-		this.layoutWidth = newWidth;
-		this.styleSheet = newStyleSheet;
+		layoutWidth = newWidth;
+		styleSheet = newStyleSheet;
 
 		// Re-create the context, since it holds the old stylesheet
-		context = this.createLayoutContext(g);
+		context = createLayoutContext(g);
 
-		this.createRootBox();
+		createRootBox();
 
-		this.iterateLayout(offset);
+		iterateLayout(offset);
 
-		this.hostComponent.setPreferredSize(this.rootBox.getWidth(),
-				this.rootBox.getHeight());
+		hostComponent.setPreferredSize(rootBox.getWidth(), rootBox.getHeight());
 
-		this.caret = this.rootBox.getCaret(context, this.getCaretOffset());
+		caret = rootBox.getCaret(context, getCaretOffset());
 
 		if (caretVisible) {
-			int viewportY = this.caret.getY()
-					- Math.min(relCaretY, viewport.getHeight());
-			viewportY = Math.min(this.rootBox.getHeight()
-					- viewport.getHeight(), viewportY);
+			int viewportY = caret.getY() - Math.min(relCaretY, viewport.getHeight());
+			viewportY = Math.min(rootBox.getHeight() - viewport.getHeight(), viewportY);
 			viewportY = Math.max(0, viewportY); // this must appear after the
 												// above line, since
 			// that line might set viewportY negative
-			this.hostComponent.scrollTo(viewport.getX(), viewportY);
-			this.scrollCaretVisible();
+			hostComponent.scrollTo(viewport.getX(), viewportY);
+			scrollCaretVisible();
 		} else {
-			int viewportY = this.rootBox.getCaret(context, offset).getY();
-			this.hostComponent.scrollTo(viewport.getX(), viewportY);
+			final int viewportY = rootBox.getCaret(context, offset).getY();
+			hostComponent.scrollTo(viewport.getX(), viewportY);
 		}
 
-		this.hostComponent.repaint();
+		hostComponent.repaint();
 
 		g.dispose();
 
@@ -1601,11 +1478,10 @@
 	 * Repaints the area of the caret.
 	 */
 	private void repaintCaret() {
-		if (this.caret != null) {
+		if (caret != null) {
 			// caret may be null when document is first set
-			Rectangle bounds = this.caret.getBounds();
-			this.hostComponent.repaint(bounds.getX(), bounds.getY(), bounds
-					.getWidth(), bounds.getHeight());
+			final Rectangle bounds = caret.getBounds();
+			hostComponent.repaint(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
 		}
 	}
 
@@ -1618,64 +1494,54 @@
 	 * @param endOffset
 	 *            Ending offset of the range.
 	 */
-	private void repaintRange(int startOffset, int endOffset) {
+	private void repaintRange(final int startOffset, final int endOffset) {
 
-		Graphics g = this.hostComponent.createDefaultGraphics();
+		final Graphics g = hostComponent.createDefaultGraphics();
 
-		LayoutContext context = this.createLayoutContext(g);
+		final LayoutContext context = createLayoutContext(g);
 
-		Rectangle startBounds = this.rootBox.getCaret(context, startOffset)
-				.getBounds();
-		int top1 = startBounds.getY();
-		int bottom1 = top1 + startBounds.getHeight();
+		final Rectangle startBounds = rootBox.getCaret(context, startOffset).getBounds();
+		final int top1 = startBounds.getY();
+		final int bottom1 = top1 + startBounds.getHeight();
 
-		Rectangle endBounds = this.rootBox.getCaret(context, endOffset)
-				.getBounds();
-		int top2 = endBounds.getY();
-		int bottom2 = top2 + endBounds.getHeight();
+		final Rectangle endBounds = rootBox.getCaret(context, endOffset).getBounds();
+		final int top2 = endBounds.getY();
+		final int bottom2 = top2 + endBounds.getHeight();
 
-		int top = Math.min(top1, top2);
-		int bottom = Math.max(bottom1, bottom2);
-		if (top == bottom) {
+		final int top = Math.min(top1, top2);
+		final int bottom = Math.max(bottom1, bottom2);
+		if (top == bottom)
 			// Account for zero-height horizontal carets
-			this.hostComponent.repaint(0, top - 1, this.getLayoutWidth(),
-					bottom - top + 1);
-		} else {
-			this.hostComponent.repaint(0, top, this.getLayoutWidth(), bottom
-					- top);
-		}
+			hostComponent.repaint(0, top - 1, getLayoutWidth(), bottom - top + 1);
+		else
+			hostComponent.repaint(0, top, getLayoutWidth(), bottom - top);
 
 		g.dispose();
 	}
 
 	private void scrollCaretVisible() {
 
-		Rectangle caretBounds = this.caret.getBounds();
-		Rectangle viewport = this.hostComponent.getViewport();
+		final Rectangle caretBounds = caret.getBounds();
+		final Rectangle viewport = hostComponent.getViewport();
 
-		int x = viewport.getX();
+		final int x = viewport.getX();
 		int y = 0;
-		int offset = getCaretOffset();
-		if (offset == 1) {
+		final int offset = getCaretOffset();
+		if (offset == 1)
 			y = 0;
-		} else if (offset == getDocument().getLength() - 1) {
-			if (this.rootBox.getHeight() < viewport.getHeight()) {
+		else if (offset == getDocument().getLength() - 1) {
+			if (rootBox.getHeight() < viewport.getHeight())
 				y = 0;
-			} else {
-				y = this.rootBox.getHeight() - viewport.getHeight();
-			}
-		} else if (caretBounds.getY() < viewport.getY()) {
+			else
+				y = rootBox.getHeight() - viewport.getHeight();
+		} else if (caretBounds.getY() < viewport.getY())
 			y = caretBounds.getY();
-		} else if (caretBounds.getY() + caretBounds.getHeight() > viewport
-				.getY()
-				+ viewport.getHeight()) {
-			y = caretBounds.getY() + caretBounds.getHeight()
-					- viewport.getHeight();
-		} else {
+		else if (caretBounds.getY() + caretBounds.getHeight() > viewport.getY() + viewport.getHeight())
+			y = caretBounds.getY() + caretBounds.getHeight() - viewport.getHeight();
+		else
 			// no scrolling required
 			return;
-		}
-		this.hostComponent.scrollTo(x, y);
+		hostComponent.scrollTo(x, y);
 	}
 
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
index d52c557..9793b4d 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
@@ -15,6 +15,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -22,6 +23,7 @@
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
@@ -196,14 +198,20 @@
 			final Set<String> selectedRootElements = new TreeSet<String>(list);
 
 			rootElementsTable.removeAll();
-			final List<String> l = new ArrayList<String>(validator.getValidRootElements());
-			Collections.sort(l);
-			for (int i = 0; i < l.size(); i++) {
-				final TableItem item1 = new TableItem(rootElementsTable, SWT.NONE);
-				item1.setText(l.get(i));
+			final List<QualifiedName> rootElements = new ArrayList<QualifiedName>(validator.getValidRootElements());
+			Collections.sort(rootElements, new Comparator<QualifiedName>() {
+				public int compare(QualifiedName name1, QualifiedName name2) {
+					return name1.getLocalName().compareTo(name2.getLocalName());
+				}
+			});
+			for (QualifiedName rootElementName : rootElements) {
+				final TableItem item = new TableItem(rootElementsTable, SWT.NONE);
+				
+				setRootElementItemText(item, rootElementName);
+				item.setData(rootElementName);
 
-				if (selectedRootElements.contains(l.get(i)))
-					item1.setChecked(true);
+				if (selectedRootElements.contains(rootElementName.getLocalName()))
+					item.setChecked(true);
 			}
 		} else
 			try {
@@ -214,6 +222,13 @@
 				VexPlugin.getInstance().log(IStatus.ERROR, message, ex);
 			}
 	}
+
+	private void setRootElementItemText(final TableItem item, final QualifiedName rootElementName) {
+		if (rootElementName.getQualifier() == null)
+			item.setText(rootElementName.getLocalName());
+		else
+			item.setText(rootElementName.getLocalName() + " (" + rootElementName.getQualifier() + ")");
+	}
 	
 	@Override
 	public boolean performOk() {
@@ -231,7 +246,7 @@
 		final ArrayList<String> selectedRootElements = new ArrayList<String>();
 		for (final TableItem item : rootElementsTable.getItems())
 			if (item.getChecked())
-				selectedRootElements.add(item.getText());
+				selectedRootElements.add(((QualifiedName) item.getData()).getLocalName());
 		doctype.setRootElements(selectedRootElements.toArray(new String[selectedRootElements.size()]));
 
 		try {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
index c898137..a222bb7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
@@ -14,6 +14,7 @@
 import java.util.Arrays;
 import java.util.Set;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
@@ -44,8 +45,7 @@
 		super(Messages.getString("DocumentTypeSelectionPage.pageName")); //$NON-NLS-1$
 		this.setPageComplete(false);
 
-		IDialogSettings rootSettings = VexPlugin.getInstance()
-				.getDialogSettings();
+		IDialogSettings rootSettings = VexPlugin.getInstance().getDialogSettings();
 		this.settings = rootSettings.getSection("newDocument"); //$NON-NLS-1$
 		if (this.settings == null) {
 			this.settings = rootSettings.addNewSection("newDocument"); //$NON-NLS-1$
@@ -74,8 +74,7 @@
 		this.typeCombo.addSelectionListener(typeComboSelectionListener);
 
 		label = new Label(pane, SWT.NONE);
-		label.setText(Messages
-				.getString("DocumentTypeSelectionPage.rootElement")); //$NON-NLS-1$
+		label.setText(Messages.getString("DocumentTypeSelectionPage.rootElement")); //$NON-NLS-1$
 		this.setControl(pane);
 
 		this.elementCombo = new Combo(pane, SWT.DROP_DOWN | SWT.READ_ONLY);
@@ -101,12 +100,11 @@
 			this.typeCombo.select(initSelection);
 			// calling select() does not fire the selection listener,
 			// so we update it manually
-			this.updateElementCombo();
+			this.updateRootElementCombo();
 		}
 
 		this.setTitle(Messages.getString("DocumentTypeSelectionPage.title")); //$NON-NLS-1$
-		this.setDescription(Messages
-				.getString("DocumentTypeSelectionPage.desc")); //$NON-NLS-1$
+		this.setDescription(Messages.getString("DocumentTypeSelectionPage.desc")); //$NON-NLS-1$
 	}
 
 	/**
@@ -152,37 +150,22 @@
 	 * Update the elementCombo to reflect elements in the currently selected
 	 * type.
 	 */
-	private void updateElementCombo() {
-		int index = this.typeCombo.getSelectionIndex();
-		DocumentType dt = this.doctypes[index];
+	private void updateRootElementCombo() {
+		final DocumentType documentType = getDocumentType();
+		final String[] rootElements = getRootElements(documentType);
+		Arrays.sort(rootElements);
+		
 		this.elementCombo.removeAll();
+		this.elementCombo.setItems(rootElements);
 
-		String[] roots = getDocumentType().getRootElements();
-		String selectedRoot = null;
-
-		if (roots.length == 0) {
-			Validator validator = dt.getValidator();
-			if (validator != null) {
-				Set<String> set = validator.getValidRootElements();
-				roots = set.toArray(new String[set.size()]);
-			}
-		} else {
-			selectedRoot = roots[0];
-		}
-
-		Arrays.sort(roots);
-		this.elementCombo.setItems(roots);
-
-		if (selectedRoot == null) {
-			// Restore the last used root element
-			String key = SETTINGS_ROOT_ELEMENT_PREFIX + dt.getPublicId();
-			selectedRoot = this.settings.get(key);
-		}
+		// Restore the last used root element
+		final String key = SETTINGS_ROOT_ELEMENT_PREFIX + documentType.getPublicId();
+		final String selectedRoot = this.settings.get(key);
 
 		this.setPageComplete(false);
 		if (selectedRoot != null) {
-			for (int i = 0; i < roots.length; i++) {
-				if (roots[i].equals(selectedRoot)) {
+			for (int i = 0; i < rootElements.length; i++) {
+				if (rootElements[i].equals(selectedRoot)) {
 					this.elementCombo.select(i);
 					this.setPageComplete(true);
 					break;
@@ -191,13 +174,33 @@
 		}
 	}
 
+	private static String[] getRootElements(final DocumentType documentType) {
+		final String[] selectedRootElements = documentType.getRootElements();
+		if (selectedRootElements != null)
+			return selectedRootElements;
+		return getPossibleRootElements(documentType);
+	}
+	
+	private static String[] getPossibleRootElements(final DocumentType documentType) {
+		final Validator validator = documentType.getValidator();
+		if (validator == null)
+			return new String[0];
+		
+		final Set<QualifiedName> validRootElements = validator.getValidRootElements();
+		final String[] result = new String[validRootElements.size()];
+		int i = 0;
+		for (QualifiedName validRootElementName : validRootElements)
+			result[i++] = validRootElementName.getLocalName();
+		return result;
+	}
+
 	/**
 	 * Sets the root element combo box when the document type combo box is
 	 * selected.
 	 */
 	private SelectionListener typeComboSelectionListener = new SelectionListener() {
 		public void widgetSelected(SelectionEvent e) {
-			updateElementCombo();
+			updateRootElementCombo();
 		}
 
 		public void widgetDefaultSelected(SelectionEvent e) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/property/ElementPropertySource.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/property/ElementPropertySource.java
index 44ab473..f8c3cb7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/property/ElementPropertySource.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/property/ElementPropertySource.java
@@ -17,6 +17,7 @@
 import org.eclipse.ui.views.properties.IPropertySource2;
 import org.eclipse.ui.views.properties.PropertyDescriptor;
 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.eclipse.wst.xml.vex.core.internal.dom.Attribute;
 import org.eclipse.wst.xml.vex.core.internal.dom.DocumentValidationException;
 import org.eclipse.wst.xml.vex.core.internal.dom.Element;
 import org.eclipse.wst.xml.vex.core.internal.dom.Validator;
@@ -39,8 +40,7 @@
 	 *            True if multiple elements are selected. In this case the "id"
 	 *            attribute will not be editable.
 	 */
-	public ElementPropertySource(Element element, Validator validator,
-			boolean multi) {
+	public ElementPropertySource(final Element element, final Validator validator, final boolean multi) {
 		this.element = element;
 		this.validator = validator;
 		this.multi = multi;
@@ -52,101 +52,94 @@
 	}
 
 	public IPropertyDescriptor[] getPropertyDescriptors() {
-
 		// note that elements from DocumentFragments don't have access
 		// to their original document, so we get it from the VexWidget
-		List<AttributeDefinition> attrDefs = validator
-				.getAttributeDefinitions(element.getName());
-		IPropertyDescriptor[] pds = new IPropertyDescriptor[attrDefs.size()];
+		final List<AttributeDefinition> attrDefs = validator.getAttributeDefinitions(element.getQualifiedName());
+		final IPropertyDescriptor[] pds = new IPropertyDescriptor[attrDefs.size()];
 		for (int i = 0; i < attrDefs.size(); i++) {
-			AttributeDefinition def = attrDefs.get(i);
-			if (this.multi && def.getName().equals(ATTR_ID)) {
-				pds[i] = new PropertyDescriptor(def.getName(), def.getName());
-			} else if (def.isFixed()) {
-				pds[i] = new PropertyDescriptor(def.getName(), def.getName());
-			} else if (def.getType() == AttributeDefinition.Type.ENUMERATION) {
-				pds[i] = new ComboBoxPropertyDescriptor(def.getName(), def
-						.getName(), this.getEnumValues(def));
-			} else {
-				pds[i] = new TextPropertyDescriptor(def.getName(), def
-						.getName());
-			}
+			final AttributeDefinition def = attrDefs.get(i);
+			if (multi && def.getName().equals(ATTR_ID))
+				pds[i] = new PropertyDescriptor(def, def.getName());
+			else if (def.isFixed())
+				pds[i] = new PropertyDescriptor(def, def.getName());
+			else if (def.getType() == AttributeDefinition.Type.ENUMERATION)
+				pds[i] = new ComboBoxPropertyDescriptor(def, def.getName(), getEnumValues(def));
+			else
+				pds[i] = new TextPropertyDescriptor(def, def.getName());
 		}
 		return pds;
 	}
 
-	public Object getPropertyValue(Object id) {
-
-		if (this.multi && id.equals(ATTR_ID)) {
+	public Object getPropertyValue(final Object id) {
+		if (!(id instanceof AttributeDefinition))
+			return "";
+		final AttributeDefinition attributeDefinition = (AttributeDefinition) id;
+		if (multi && id.equals(ATTR_ID))
 			return Messages.getString("ElementPropertySource.multiple"); //$NON-NLS-1$
-		}
 
-		// note that elements from DocumentFragments don't have access
-		// to their original document, so we get it from the VexWidget
-		AttributeDefinition def = this.validator.getAttributeDefinition(
-				this.element.getName(), (String) id);
-		String value = this.element.getAttribute((String) id);
-		if (value == null) {
-			value = def.getDefaultValue();
-			if (value == null) {
-				value = ""; //$NON-NLS-1$
-			}
-		}
+		final Attribute attribute = element.getAttribute(attributeDefinition.getName());
+		final String value;
+		if (attribute != null)
+			value = attribute.getValue();
+		else
+			value = nullToEmpty(attributeDefinition.getDefaultValue());
 
-		if (def.getType() == AttributeDefinition.Type.ENUMERATION) {
-			String[] values = this.getEnumValues(def);
-			for (int i = 0; i < values.length; i++) {
-				if (values[i].equals(value)) {
+		if (attributeDefinition.getType() == AttributeDefinition.Type.ENUMERATION) {
+			final String[] values = getEnumValues(attributeDefinition);
+			for (int i = 0; i < values.length; i++)
+				if (values[i].equals(value))
 					return Integer.valueOf(i);
-				}
-			}
-			return Integer.valueOf(0); // TODO: if the actual value is not
-			// in the list, we should probably
-			// add it
-		} else {
-			return value;
+			return Integer.valueOf(0);
+			// TODO: If the actual value is not in the list, we should probably add it.
 		}
+		return value;
 	}
 
-	public boolean isPropertySet(Object id) {
+	private static String nullToEmpty(final String string) {
+		if (string == null)
+			return "";
+		return string;
+	}
+
+	public boolean isPropertySet(final Object id) {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
-	public void resetPropertyValue(Object id) {
+	public void resetPropertyValue(final Object id) {
 		// TODO Auto-generated method stub
 
 	}
 
-	public void setPropertyValue(Object id, Object value) {
-
+	public void setPropertyValue(final Object id, final Object value) {
+		if (!(id instanceof AttributeDefinition))
+			return;
+		/*
+		 * Note that elements from DocumentFragments don't have access to
+		 * their original document, so we get it from the VexWidget.
+		 */
+		final AttributeDefinition attributeDefinition = (AttributeDefinition) id;
+		
 		try {
-			// note that elements from DocumentFragments don't have access
-			// to their original document, so we get it from the VexWidget
-			AttributeDefinition def = this.validator.getAttributeDefinition(
-					this.element.getName(), (String) id);
-
-			if (def.getType() == AttributeDefinition.Type.ENUMERATION) {
-				int i = ((Integer) value).intValue();
-				String s = this.getEnumValues(def)[i];
-				if (!def.isRequired() && s.equals("")) { //$NON-NLS-1$
-					this.element.removeAttribute(def.getName());
-				} else {
-					this.element.setAttribute(def.getName(), s);
-				}
+			if (attributeDefinition.getType() == AttributeDefinition.Type.ENUMERATION) {
+				final int i = ((Integer) value).intValue();
+				final String enumValue = getEnumValues(attributeDefinition)[i];
+				if (!attributeDefinition.isRequired() && enumValue.equals(""))
+					element.removeAttribute(attributeDefinition.getName());
+				else
+					element.setAttribute(attributeDefinition.getName(), enumValue);
 			} else {
-				String s = (String) value;
-				if (s.equals("")) { //$NON-NLS-1$
-					this.element.removeAttribute(def.getName());
-				} else {
-					this.element.setAttribute(def.getName(), s);
-				}
+				final String s = (String) value;
+				if (s.equals(""))
+					element.removeAttribute(attributeDefinition.getName());
+				else
+					element.setAttribute(attributeDefinition.getName(), s);
 			}
-		} catch (DocumentValidationException e) {
+		} catch (final DocumentValidationException e) {
 		}
 	}
 
-	public boolean isPropertyResettable(Object id) {
+	public boolean isPropertyResettable(final Object id) {
 		// TODO Auto-generated method stub
 		return true;
 	}
@@ -155,20 +148,20 @@
 
 	private static final String ATTR_ID = "id"; //$NON-NLS-1$
 
-	private Element element;
-	private Validator validator;
-	private boolean multi;
+	private final Element element;
+	private final Validator validator;
+	private final boolean multi;
 
-	private String[] getEnumValues(AttributeDefinition def) {
+	private String[] getEnumValues(final AttributeDefinition def) {
 		String[] values = def.getValues();
-		if (def.isRequired()) {
+		if (def.isRequired())
 			return values;
-		} else {
+		else {
 			if (values == null) {
 				values = new String[1];
 				values[0] = "";
 			}
-			String[] values2 = new String[values.length + 1];
+			final String[] values2 = new String[values.length + 1];
 			values2[0] = ""; //$NON-NLS-1$
 			System.arraycopy(values, 0, values2, 1, values.length);
 			return values2;
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyTest.java
index 774990f..938849d 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyTest.java
@@ -121,7 +121,7 @@
 
 		assertNull(property.calculate(attrSrc, parentStyles, styles, noAttribute));
 		assertEquals("image.jpg", property.calculate(attrSrc, parentStyles, styles, setAttribute));
-		assertEquals("", property.calculate(attrSrc, parentStyles, styles, emptyAttribute));
+		assertNull(property.calculate(attrSrc, parentStyles, styles, emptyAttribute));
 	}
 
 	public void testParsePropertyValue() throws Exception {
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
index e6d0d73..52589a4 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
@@ -18,12 +18,14 @@
 import java.io.ObjectOutputStream;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import junit.framework.TestCase;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.validator.AttributeDefinition;
 import org.eclipse.wst.xml.vex.core.internal.validator.WTPVEXValidator;
 
@@ -43,7 +45,8 @@
 	}
 
 	public void testAttributeDefinition() throws Exception {
-		final AttributeDefinition.Type adType = validator.getAttributeDefinitions("section").get(0).getType();
+		QualifiedName sectionName = new QualifiedName(null, "section");
+		final AttributeDefinition.Type adType = validator.getAttributeDefinitions(sectionName).get(0).getType();
 
 		// Test serialization while we're at it
 		final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -54,7 +57,7 @@
 		final ObjectInputStream ois = new ObjectInputStream(bais);
 		validator = (Validator) ois.readObject();
 
-		final AttributeDefinition.Type adType2 = validator.getAttributeDefinitions("section").get(0).getType();
+		final AttributeDefinition.Type adType2 = validator.getAttributeDefinitions(sectionName).get(0).getType();
 
 		assertSame(adType, adType2);
 
@@ -112,12 +115,12 @@
 	}
 
 	private static void assertValidItemsAt(final Document doc, final int offset, final String... expectedItems) {
-		final Set<String> expected = new HashSet<String>(expectedItems.length);
+		final Set<QualifiedName> expected = new HashSet<QualifiedName>(expectedItems.length);
 		for (final String expectedItem : expectedItems)
-			expected.add(expectedItem);
+			expected.add(new QualifiedName(null, expectedItem));
 
-		final String elementName = doc.getElementAt(offset).getName();
-		final Set<String> validItems = doc.getValidator().getValidItems(elementName);
+		final QualifiedName elementName = doc.getElementAt(offset).getQualifiedName();
+		final Set<QualifiedName> validItems = doc.getValidator().getValidItems(elementName);
 		assertEquals(expected, validItems);
 	}
 
@@ -175,32 +178,30 @@
 
 	private void assertValidSequence(final boolean expected, final String element, final boolean validateFully, final boolean validatePartially,
 			final String... sequence) {
+		final QualifiedName elementName = new QualifiedName(null, element);
 		for (int i = 0; i < sequence.length; i++) {
-			final List<String> prefix = createPrefix(i, sequence);
-
-			final List<String> toInsert = new ArrayList<String>(1);
-			toInsert.add(sequence[i]);
-
-			final List<String> suffix = createSuffix(i, sequence);
+			final List<QualifiedName> prefix = createPrefix(i, sequence);
+			final List<QualifiedName> toInsert = Collections.singletonList(new QualifiedName(null, sequence[i]));
+			final List<QualifiedName> suffix = createSuffix(i, sequence);
 
 			if (validateFully)
-				assertEquals(expected, validator.isValidSequence(element, prefix, toInsert, suffix, false));
+				assertEquals(expected, validator.isValidSequence(elementName, prefix, toInsert, suffix, false));
 			if (validatePartially)
-				assertEquals(expected, validator.isValidSequence(element, prefix, toInsert, suffix, true));
+				assertEquals(expected, validator.isValidSequence(elementName, prefix, toInsert, suffix, true));
 		}
 	}
 
-	private static List<String> createPrefix(final int index, final String... sequence) {
-		final List<String> prefix = new ArrayList<String>();
+	private static List<QualifiedName> createPrefix(final int index, final String... sequence) {
+		final List<QualifiedName> prefix = new ArrayList<QualifiedName>();
 		for (int i = 0; i < index; i++)
-			prefix.add(sequence[i]);
+			prefix.add(new QualifiedName(null, sequence[i]));
 		return prefix;
 	}
 
-	private static List<String> createSuffix(final int index, final String... sequence) {
-		final List<String> suffix = new ArrayList<String>();
+	private static List<QualifiedName> createSuffix(final int index, final String... sequence) {
+		final List<QualifiedName> suffix = new ArrayList<QualifiedName>();
 		for (int i = index + 1; i < sequence.length; i++)
-			suffix.add(sequence[i]);
+			suffix.add(new QualifiedName(null, sequence[i]));
 		return suffix;
 	}
 }
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriterTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriterTest.java
index 3ec1a40..42ed5c1 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriterTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriterTest.java
@@ -16,7 +16,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.Collections;
 import java.util.List;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -24,6 +23,7 @@
 
 import junit.framework.TestCase;
 
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.wst.xml.vex.core.internal.core.DisplayDevice;
 import org.eclipse.wst.xml.vex.core.internal.css.MockDisplayDevice;
 import org.eclipse.wst.xml.vex.core.internal.css.StyleSheet;
@@ -41,19 +41,19 @@
 
 	public void testWriteDocument() throws Exception {
 		DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
-		StyleSheetReader reader = new StyleSheetReader();
-		StyleSheet ss = reader.read(this.getClass().getResource("test.css"));
+		final StyleSheetReader reader = new StyleSheetReader();
+		final StyleSheet ss = reader.read(this.getClass().getResource("test.css"));
 
-		URL docUrl = this.getClass().getResource("DocumentWriterTest1.xml");
+		final URL docUrl = this.getClass().getResource("DocumentWriterTest1.xml");
 
-		Document docOrig = readDocument(new InputSource(docUrl.toString()), ss);
+		final Document docOrig = readDocument(new InputSource(docUrl.toString()), ss);
 
-		DocumentWriter dw = new DocumentWriter();
+		final DocumentWriter dw = new DocumentWriter();
 		dw.setWhitespacePolicy(new CssWhitespacePolicy(ss));
-		ByteArrayOutputStream os = new ByteArrayOutputStream();
+		final ByteArrayOutputStream os = new ByteArrayOutputStream();
 		dw.write(docOrig, os);
 
-		InputStream is = new ByteArrayInputStream(os.toByteArray());
+		final InputStream is = new ByteArrayInputStream(os.toByteArray());
 
 		// Dump document to console
 		// BufferedReader br = new BufferedReader(new InputStreamReader(is));
@@ -65,67 +65,55 @@
 		// }
 		// is.reset();
 
-		Document docNew = readDocument(new InputSource(is), ss);
+		final Document docNew = readDocument(new InputSource(is), ss);
 
 		assertEquals(docOrig, docNew);
 	}
 
-	private void assertEquals(Document expected, Document actual)
-			throws Exception {
+	private void assertEquals(final Document expected, final Document actual) throws Exception {
 
 		assertEquals(expected.getRootElement(), actual.getRootElement());
 	}
 
-	private void assertEquals(Element expected, Element actual)
-			throws Exception {
+	private void assertEquals(final Element expected, final Element actual) throws Exception {
 
 		System.out.println("Checking " + actual.getName());
 		assertEquals(expected.getName(), actual.getName());
 
-		List<String> expectedAttrs = expected.getAttributeNames();
-		Collections.sort(expectedAttrs);
-
-		List<String> actualAttrs = actual.getAttributeNames();
-		Collections.sort(actualAttrs);
+		final List<QualifiedName> expectedAttrs = expected.getAttributeNames();
+		final List<QualifiedName> actualAttrs = actual.getAttributeNames();
 
 		assertEquals(expectedAttrs.size(), actualAttrs.size());
-		for (int i = 0; i < expectedAttrs.size(); i++) {
+		for (int i = 0; i < expectedAttrs.size(); i++)
 			assertEquals(expectedAttrs.get(i), actualAttrs.get(i));
-		}
 
-		List<Node> expectedContent = expected.getChildNodes();
-		List<Node> actualContent = actual.getChildNodes();
+		final List<Node> expectedContent = expected.getChildNodes();
+		final List<Node> actualContent = actual.getChildNodes();
 		assertEquals(expectedContent.size(), actualContent.size());
 		for (int i = 0; i < expectedContent.size(); i++) {
-			assertEquals(expectedContent.get(i).getClass(), actualContent.get(i)
-					.getClass());
-			if (expectedContent.get(i) instanceof Element) {
-				assertEquals((Element) expectedContent.get(i),
-						(Element) actualContent.get(i));
-			} else {
-				assertEquals(expectedContent.get(i).getText(), actualContent.get(i)
-						.getText());
-			}
+			assertEquals(expectedContent.get(i).getClass(), actualContent.get(i).getClass());
+			if (expectedContent.get(i) instanceof Element)
+				assertEquals((Element) expectedContent.get(i), (Element) actualContent.get(i));
+			else
+				assertEquals(expectedContent.get(i).getText(), actualContent.get(i).getText());
 		}
 	}
 
-	private static Document readDocument(InputSource is, StyleSheet ss)
-			throws ParserConfigurationException, SAXException, IOException {
+	private static Document readDocument(final InputSource is, final StyleSheet ss) throws ParserConfigurationException, SAXException, IOException {
 
-		SAXParserFactory factory = SAXParserFactory.newInstance();
-		XMLReader xmlReader = factory.newSAXParser().getXMLReader();
-		DefaultHandler defaultHandler = new DefaultHandler();
+		final SAXParserFactory factory = SAXParserFactory.newInstance();
+		final XMLReader xmlReader = factory.newSAXParser().getXMLReader();
+		final DefaultHandler defaultHandler = new DefaultHandler();
 
 		final IWhitespacePolicy policy = new CssWhitespacePolicy(ss);
 
-		IWhitespacePolicyFactory wsFactory = new IWhitespacePolicyFactory() {
-			public IWhitespacePolicy getPolicy(String publicId) {
+		final IWhitespacePolicyFactory wsFactory = new IWhitespacePolicyFactory() {
+			public IWhitespacePolicy getPolicy(final String publicId) {
 				return policy;
 			}
 		};
 
-		org.eclipse.wst.xml.vex.core.internal.dom.DocumentBuilder builder = new org.eclipse.wst.xml.vex.core.internal.dom.DocumentBuilder(
-				wsFactory);
+		final org.eclipse.wst.xml.vex.core.internal.dom.DocumentBuilder builder = new org.eclipse.wst.xml.vex.core.internal.dom.DocumentBuilder(wsFactory);
 
 		xmlReader.setContentHandler(builder);
 		xmlReader.setDTDHandler(defaultHandler);
@@ -147,7 +135,7 @@
 	 * Parse the given document and pass them through to stdout to confirm their
 	 * goodness.
 	 */
-	public static void main(String[] args) {
+	public static void main(final String[] args) {
 		if (args.length < 2) {
 			System.out.println("Usage: java DocumentWriterTest filename width");
 			System.exit(1);
@@ -156,25 +144,24 @@
 		FileInputStream fis = null;
 		try {
 			fis = new FileInputStream(args[0]);
-			int width = Integer.parseInt(args[1]);
-			StyleSheetReader reader = new StyleSheetReader();
-			StyleSheet ss = reader.read(DocumentWriterTest.class
-					.getResource("test.css"));
-			Document doc = readDocument(new InputSource(fis), ss);
+			final int width = Integer.parseInt(args[1]);
+			final StyleSheetReader reader = new StyleSheetReader();
+			final StyleSheet ss = reader.read(DocumentWriterTest.class.getResource("test.css"));
+			final Document doc = readDocument(new InputSource(fis), ss);
 
-			DocumentWriter writer = new DocumentWriter();
+			final DocumentWriter writer = new DocumentWriter();
 			writer.setWhitespacePolicy(new CssWhitespacePolicy(ss));
 			writer.setWrapColumn(width);
 
 			writer.write(doc, System.out);
-		} catch (Exception ex) {
+		} catch (final Exception ex) {
 			ex.printStackTrace();
 			System.exit(1);
 		} finally {
 			if (fis != null) {
 				try {
 					fis.close();
-				} catch (IOException ex) {
+				} catch (final IOException ex) {
 				}
 				fis = null;
 			}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/MockBoxFactory.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/MockBoxFactory.java
index 8fb68d4..a25abc4 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/MockBoxFactory.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/MockBoxFactory.java
@@ -11,11 +11,6 @@
 package org.eclipse.wst.xml.vex.core.internal.layout;
 
 import org.eclipse.wst.xml.vex.core.internal.dom.Element;
-import org.eclipse.wst.xml.vex.core.internal.layout.BlockElementBox;
-import org.eclipse.wst.xml.vex.core.internal.layout.Box;
-import org.eclipse.wst.xml.vex.core.internal.layout.CssBoxFactory;
-import org.eclipse.wst.xml.vex.core.internal.layout.LayoutContext;
-import org.eclipse.wst.xml.vex.core.internal.layout.SpaceBox;
 
 /**
  * A box factory that, for an element named &lt;space&gt;, returns a SpaceBox
@@ -24,23 +19,22 @@
  */
 public class MockBoxFactory extends CssBoxFactory {
 
-	public Box createBox(LayoutContext context, Element element,
-			BlockElementBox parent, int width) {
+	private static final long serialVersionUID = 1L;
 
+	public Box createBox(final LayoutContext context, final Element element, final BlockElementBox parent, final int width) {
 		if (element.getName().equals("space")) {
 			int w = 0;
 			int h = 0;
 			try {
-				w = Integer.parseInt(element.getAttribute("width"));
-			} catch (NumberFormatException ex) {
+				w = Integer.parseInt(element.getAttributeValue("width"));
+			} catch (final NumberFormatException ex) {
 			}
 			try {
-				h = Integer.parseInt(element.getAttribute("height"));
-			} catch (NumberFormatException ex) {
+				h = Integer.parseInt(element.getAttributeValue("height"));
+			} catch (final NumberFormatException ex) {
 			}
 			return new SpaceBox(w, h);
 		}
-		// TODO Auto-generated method stub
 		return super.createBox(context, element, parent, width);
 	}
 }