[203291] XSD Editor Source State not updated in Outline/Graph
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDTabbedPropertySheetPage.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDTabbedPropertySheetPage.java
index 4c10635..1776dc0 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDTabbedPropertySheetPage.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/XSDTabbedPropertySheetPage.java
@@ -28,6 +28,7 @@
 import org.eclipse.xsd.XSDAttributeUse;
 import org.eclipse.xsd.XSDConcreteComponent;
 import org.eclipse.xsd.XSDElementDeclaration;
+import org.w3c.dom.Element;
 
 public class XSDTabbedPropertySheetPage extends TabbedPropertySheetPage implements IADTObjectListener
 {
@@ -99,7 +100,10 @@
           xsdModelAdapter.getModelReconcileAdapter().removeListener(internalNodeAdapter);
         }
         
-        xsdModelAdapter = XSDModelAdapter.lookupOrCreateModelAdapter(((XSDConcreteComponent)adapter.getTarget()).getElement().getOwnerDocument());
+        Element element = ((XSDConcreteComponent)adapter.getTarget()).getElement();
+        if (element != null) {
+          xsdModelAdapter = XSDModelAdapter.lookupOrCreateModelAdapter(element.getOwnerDocument());
+        }
         if (xsdModelAdapter != null && xsdModelAdapter.getModelReconcileAdapter() != null)
         {
           xsdModelAdapter.getModelReconcileAdapter().addListener(internalNodeAdapter);
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
index b1ead35..1ee276e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
@@ -78,7 +78,19 @@
       {
         // if there's no root element clear out the schema
         //
-        schema.getContents().clear();
+        
+        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203291
+        // Add try-catch to work-around problem at 
+        // XSDConcreteComponentImpl.forceNiceRemoveChild(XSDConcreteComponentImpl.java:1696)
+        // otherwise the statements below don't get run
+        try
+        {
+          schema.getContents().clear();
+        }
+        catch (NullPointerException e)
+        {
+          // workaround
+        }
         // TODO (cs) I'm not sure why the above isn't enough
         // to clear out all of the component lists
         // for now I've just added a few more lines to do additional clearing
@@ -106,6 +118,12 @@
     // No need to reconcile if the node is in a different namespace as it is the
     // case for nodes deeply nested in appinfo or documentation elements.
 
+    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203291
+    if (changedNode instanceof Document)
+    {
+      return true;
+    }
+
     String nodeNamespace = changedNode.getNamespaceURI();
     String schemaNamespace = schema.getSchemaForSchemaNamespace();
     // If the document node changes, then the nodeNamespace is null