[155790] Missing HTML-ish functions on IDOMModel created from XHTML text/xml JSP file
diff --git a/bundles/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex b/bundles/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex
index 89f8ee6..c47ae1c 100644
--- a/bundles/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex
+++ b/bundles/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex
@@ -33,6 +33,8 @@
         // state stack for easier state handling
         private IntStack fStateStack = new IntStack();
         private String valueText = null;
+        private boolean isXHTML;
+        private boolean isWML;
 
 
         public JSPHeadTokenizer() {
@@ -72,7 +74,7 @@
                 zzEndRead = 0;
 
                 /* number of newlines encountered up to the start of the matched text */
-                yyline = 0;
+                //yyline = 0;
 
                 /* the number of characters up to the start of the matched text */
                 yychar = 0;
@@ -81,7 +83,7 @@
                  * the number of characters from the last newline up to the start
                  * of the matched text
                  */
-                yycolumn = 0;
+                //yycolumn = 0;
 
                 /**
                  * yy_atBOL == true <=> the scanner is currently at the beginning
@@ -99,6 +101,8 @@
                 fStateStack.clear();
 
                 hasMore = true;
+                isXHTML=false;
+                isWML=false;
 
 
         }
@@ -131,7 +135,13 @@
         private HeadParserToken createToken(String context, int start, String text) {
                 return new HeadParserToken(context, start, text);
         }
-
+        
+        public boolean isXHTML() {
+            return isXHTML;
+        }
+        public boolean isWML() {
+            return isWML;
+        }        
 
 %}
 
@@ -178,13 +188,21 @@
 
 <YYINITIAL>
 {
-	 	// force to start at beginning of line (^) and at beginning of file (yychar == 0)
-		^ {UTF16BE}   		{if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16BE;}}
-		^ {UTF16LE}   		{if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16LE;}}
-		^ {UTF83ByteBOM}   	{if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF83ByteBOM;}}
-		
-		// force to be started on first line, but we do allow preceeding spaces
-		^ {S}* "<\?xml" {S}+ {if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;}}
+         // force to start at beginning of line (^) and at beginning of file (yychar == 0)
+        ^ {UTF16BE}           {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16BE;}}
+        ^ {UTF16LE}           {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16LE;}}
+        ^ {UTF83ByteBOM}       {if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF83ByteBOM;}}
+        
+        // force to be started on first line, but we do allow preceeding spaces
+        ^ {S}* "<\?xml" {S}+ {if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;}}
+
+
+        // following are some simply rules to identify JSP content as "XHTML"
+        // see http://www.rfc-editor.org/rfc/rfc3236.txt
+        "<!DOCTYPE" {S}* "html" {S}* "PUBLIC" .* "//DTD XHTML"                {isXHTML = true;}
+        "<html" {S}* "xmlns" {S}* "=" {S}* (\" | \') "http://www.w3.org/1999/xhtml"     {isXHTML = true;}
+         // another case that's part of the "HTML family" is WML 1.0 (WML 2.0 is part of XHTML)
+         "<!DOCTYPE" {S}* "wml" {S}* "PUBLIC" .* "//DTD WML"                   {isWML = true;}
 
         "<%" {S}* "@" {S}* "page" {S}+   {yybegin(ST_PAGE_DIRECTIVE); return JSPHeadTokenizerConstants.PageDirectiveStart;}
         "<jsp:directive.page" {S}+           {yybegin(ST_PAGE_DIRECTIVE); return JSPHeadTokenizerConstants.PageDirectiveStart;}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/ContentDescriberForJSP.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/ContentDescriberForJSP.java
index d2e2023..47ec7b9 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/ContentDescriberForJSP.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/ContentDescriberForJSP.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004-2006 IBM Corporation 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
@@ -19,12 +19,13 @@
 import org.eclipse.core.runtime.content.IContentDescription;
 import org.eclipse.core.runtime.content.ITextContentDescriber;
 import org.eclipse.jst.jsp.core.internal.provisional.contenttype.IContentDescriptionForJSP;
+import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeFamilyForHTML;
 import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
 import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended;
 import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
 
 public final class ContentDescriberForJSP implements ITextContentDescriber {
-	private final static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT, IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE, IContentDescriptionForJSP.LANGUAGE_ATTRIBUTE};
+	private final static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT, IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE, IContentDescriptionForJSP.LANGUAGE_ATTRIBUTE, IContentDescriptionForJSP.CONTENT_FAMILY_ATTRIBUTE};
 
 	/*
 	 * (non-Javadoc)
@@ -129,10 +130,24 @@
 			if (language != null && language.length() > 0) {
 				description.setProperty(IContentDescriptionForJSP.LANGUAGE_ATTRIBUTE, language);
 			}
+			/*
+			 * content type is literally the content type that's in the page
+			 * directive
+			 */
 			String contentTypeAttribute = jspDetector.getContentType();
 			if (contentTypeAttribute != null && contentTypeAttribute.length() > 0) {
 				description.setProperty(IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE, contentTypeAttribute);
 			}
+			/*
+			 * content family is the general class of content, when its
+			 * different from what's defined by content type
+			 */
+			if (jspDetector.isXHTML() || jspDetector.isWML()) {
+				// ISSUE: long term this logic and value should be contributed by extension point
+				description.setProperty(IContentDescriptionForJSP.CONTENT_FAMILY_ATTRIBUTE, ContentTypeFamilyForHTML.HTML_FAMILY);
+			}
+
+
 		}
 	}
 
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPHeadTokenizer.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPHeadTokenizer.java
index ed646e1..7ec777b 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPHeadTokenizer.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPHeadTokenizer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4 on 7/5/05 12:27 AM */
+/* The following code was generated by JFlex 1.4 on 9/18/06 2:12 PM */
 
 /*******************************************************************************
  * Copyright (c) 2005 IBM Corporation and others.
@@ -26,8 +26,8 @@
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/">JFlex</a> 1.4
- * on 7/5/05 12:27 AM from the specification file
- * <tt>D:/builds/Workspaces/PureHeadWTP_M7/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex</tt>
+ * on 9/18/06 2:12 PM from the specification file
+ * <tt>D:/builds/Workspaces/WTP15maintenance/org.eclipse.jst.jsp.core/DevTimeSupport/HeadParsers/JSPHeadTokenizer.jFlex</tt>
  */
 public class JSPHeadTokenizer {
 
@@ -60,16 +60,16 @@
    * Translates characters to character classes
    */
   private static final String ZZ_CMAP_PACKED = 
-    "\11\0\1\6\1\11\2\0\1\10\22\0\1\6\1\0\1\45\2\0"+
-    "\1\17\1\0\1\46\6\0\1\36\1\44\12\0\1\27\1\0\1\12"+
-    "\1\7\1\41\1\13\1\20\1\22\1\0\1\33\1\30\1\24\1\0"+
-    "\1\23\1\0\1\31\1\25\1\0\1\16\1\15\1\40\1\37\1\21"+
-    "\1\0\1\32\1\26\1\34\1\42\1\35\1\0\1\14\1\43\7\0"+
-    "\1\22\1\0\1\33\1\30\1\24\1\0\1\23\1\0\1\31\1\25"+
-    "\1\0\1\16\1\15\1\40\1\37\1\21\1\0\1\32\1\26\1\34"+
-    "\1\42\1\35\1\0\1\14\1\43\101\0\1\4\3\0\1\5\17\0"+
-    "\1\3\16\0\1\1\20\0\1\3\16\0\1\1\1\2\170\0\1\2"+
-    "\ufe87\0";
+    "\11\0\1\6\1\11\2\0\1\10\22\0\1\34\1\17\1\37\2\0"+
+    "\1\51\1\0\1\40\6\0\1\43\1\33\1\0\1\47\1\0\1\44"+
+    "\5\0\1\50\1\41\1\0\1\12\1\7\1\56\1\13\1\52\1\53"+
+    "\1\31\1\22\1\20\1\26\1\0\1\46\1\27\1\32\1\54\1\0"+
+    "\1\16\1\15\1\35\1\21\1\25\1\0\1\45\1\36\1\23\1\30"+
+    "\1\55\1\42\1\14\1\24\7\0\1\53\1\31\1\22\1\20\1\26"+
+    "\1\0\1\46\1\27\1\32\1\54\1\0\1\16\1\15\1\35\1\21"+
+    "\1\25\1\0\1\45\1\36\1\23\1\30\1\55\1\42\1\14\1\24"+
+    "\101\0\1\4\3\0\1\5\17\0\1\3\16\0\1\1\20\0\1\3"+
+    "\16\0\1\1\1\2\170\0\1\2\ufe87\0";
 
   /** 
    * Translates characters to character classes
@@ -83,14 +83,14 @@
 
   private static final String ZZ_ACTION_PACKED_0 =
     "\10\0\20\1\2\2\1\1\1\3\1\4\1\5\1\6"+
-    "\2\5\1\7\1\5\1\7\1\10\2\11\2\0\1\12"+
-    "\1\13\6\0\1\14\3\0\1\15\2\0\1\16\1\0"+
-    "\1\17\1\20\3\0\1\21\30\0\1\22\14\0\1\23"+
-    "\2\0\1\24\4\0\1\25\1\26\12\0\1\27\1\0"+
-    "\1\30\2\0";
+    "\1\5\1\7\2\5\1\7\1\10\2\11\4\0\1\12"+
+    "\1\13\6\0\1\14\5\0\1\15\1\16\1\0\1\17"+
+    "\1\0\1\20\4\0\1\21\36\0\1\22\20\0\1\23"+
+    "\2\0\1\24\6\0\1\25\1\26\22\0\1\27\5\0"+
+    "\1\30\52\0\1\31\5\0\1\32\12\0\1\32";
 
   private static int [] zzUnpackAction() {
-    int [] result = new int[126];
+    int [] result = new int[212];
     int offset = 0;
     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
     return result;
@@ -151,7 +151,7 @@
   private int zzEndRead;
 
   /** number of newlines encountered up to the start of the matched text */
-//  private int yyline;
+  //private int yyline;
 
   /** the number of characters up to the start of the matched text */
   private int yychar;
@@ -160,7 +160,7 @@
    * the number of characters from the last newline up to the start of the 
    * matched text
    */
-//  private int yycolumn;
+  //private int yycolumn;
 
   /** 
    * zzAtBOL == true <=> the scanner is currently at the beginning of a line
@@ -184,6 +184,8 @@
         // state stack for easier state handling
         private IntStack fStateStack = new IntStack();
         private String valueText = null;
+        private boolean isXHTML;
+        private boolean isWML;
 
 
         public JSPHeadTokenizer() {
@@ -223,7 +225,7 @@
                 zzEndRead = 0;
 
                 /* number of newlines encountered up to the start of the matched text */
-//                yyline = 0;
+                //yyline = 0;
 
                 /* the number of characters up to the start of the matched text */
                 yychar = 0;
@@ -232,7 +234,7 @@
                  * the number of characters from the last newline up to the start
                  * of the matched text
                  */
-//                yycolumn = 0;
+                //yycolumn = 0;
 
                 /**
                  * yy_atBOL == true <=> the scanner is currently at the beginning
@@ -250,6 +252,8 @@
                 fStateStack.clear();
 
                 hasMore = true;
+                isXHTML=false;
+                isWML=false;
 
 
         }
@@ -282,7 +286,13 @@
         private HeadParserToken createToken(String context, int start, String text) {
                 return new HeadParserToken(context, start, text);
         }
-
+        
+        public boolean isXHTML() {
+            return isXHTML;
+        }
+        public boolean isWML() {
+            return isWML;
+        }        
 
 
 
@@ -316,7 +326,7 @@
     char [] map = new char[0x10000];
     int i = 0;  /* index in packed string  */
     int j = 0;  /* index in unpacked array */
-    while (i < 182) {
+    while (i < 192) {
       int  count = packed.charAt(i++);
       char value = packed.charAt(i++);
       do map[j++] = value; while (--count > 0);
@@ -399,7 +409,6 @@
     zzEndRead = zzStartRead = 0;
     zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
     //yyline = yychar = yycolumn = 0;
-    yychar = 0;
     zzLexicalState = YYINITIAL;
   }
 
@@ -619,7 +628,8 @@
                 case 3: zzIsFinal = true; zzState = 12; break zzForNext;
                 case 6: 
                 case 8: 
-                case 9: zzIsFinal = true; zzState = 13; break zzForNext;
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 13; break zzForNext;
                 case 10: zzIsFinal = true; zzState = 14; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 8; break zzForNext;
               }
@@ -628,30 +638,32 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzIsFinal = true; zzState = 15; break zzForNext;
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 15; break zzForNext;
                 case 11: zzIsFinal = true; zzState = 16; break zzForNext;
-                case 20: zzIsFinal = true; zzState = 17; break zzForNext;
-                case 29: zzIsFinal = true; zzState = 18; break zzForNext;
+                case 22: zzIsFinal = true; zzState = 17; break zzForNext;
+                case 45: zzIsFinal = true; zzState = 18; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 8; break zzForNext;
               }
 
             case 3:
               switch (zzInput) {
                 case 14: zzIsFinal = true; zzState = 19; break zzForNext;
-                case 15: zzIsFinal = true; zzState = 20; break zzForNext;
-                case 17: zzIsFinal = true; zzState = 21; break zzForNext;
+                case 18: zzIsFinal = true; zzState = 20; break zzForNext;
+                case 21: zzIsFinal = true; zzState = 21; break zzForNext;
                 case 27: zzIsFinal = true; zzState = 22; break zzForNext;
-                case 36: zzIsFinal = true; zzState = 23; break zzForNext;
+                case 41: zzIsFinal = true; zzState = 23; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 8; break zzForNext;
               }
 
             case 4:
               switch (zzInput) {
                 case 6: 
-                case 8: zzIsFinal = true; zzState = 25; break zzForNext;
+                case 8: 
+                case 28: zzIsFinal = true; zzState = 25; break zzForNext;
                 case 9: zzIsFinal = true; zzState = 26; break zzForNext;
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 27; break zzForNext;
-                case 38: zzIsFinal = true; zzNoLookAhead = true; zzState = 28; break zzForNext;
+                case 31: zzIsFinal = true; zzNoLookAhead = true; zzState = 27; break zzForNext;
+                case 32: zzIsFinal = true; zzNoLookAhead = true; zzState = 28; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
               }
 
@@ -660,9 +672,9 @@
                 case 8: 
                 case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 30; break zzForNext;
                 case 11: zzIsFinal = true; zzState = 31; break zzForNext;
-                case 15: zzIsFinal = true; zzState = 32; break zzForNext;
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 33; break zzForNext;
-                case 38: zzIsFinal = true; zzState = 34; break zzForNext;
+                case 31: zzIsFinal = true; zzNoLookAhead = true; zzState = 32; break zzForNext;
+                case 32: zzIsFinal = true; zzState = 33; break zzForNext;
+                case 41: zzIsFinal = true; zzState = 34; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 29; break zzForNext;
               }
 
@@ -670,45 +682,48 @@
               switch (zzInput) {
                 case 8: 
                 case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 30; break zzForNext;
-                case 15: zzIsFinal = true; zzState = 32; break zzForNext;
-                case 38: zzIsFinal = true; zzState = 35; break zzForNext;
+                case 41: zzIsFinal = true; zzState = 34; break zzForNext;
+                case 32: zzIsFinal = true; zzState = 35; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 29; break zzForNext;
               }
 
             case 7:
               switch (zzInput) {
                 case 11: 
-                case 15: zzIsFinal = true; zzState = 32; break zzForNext;
+                case 41: zzIsFinal = true; zzState = 34; break zzForNext;
                 case 6: 
                 case 8: 
-                case 9: zzIsFinal = true; zzNoLookAhead = true; zzState = 36; break zzForNext;
-                case 37: zzIsFinal = true; zzNoLookAhead = true; zzState = 37; break zzForNext;
-                case 38: zzIsFinal = true; zzState = 38; break zzForNext;
+                case 9: 
+                case 28: zzIsFinal = true; zzNoLookAhead = true; zzState = 36; break zzForNext;
+                case 31: zzIsFinal = true; zzNoLookAhead = true; zzState = 37; break zzForNext;
+                case 32: zzIsFinal = true; zzState = 38; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 29; break zzForNext;
               }
 
             case 9:
               switch (zzInput) {
                 case 15: zzState = 39; break zzForNext;
-                case 21: zzState = 40; break zzForNext;
+                case 23: zzState = 40; break zzForNext;
+                case 41: zzState = 41; break zzForNext;
+                case 44: zzState = 42; break zzForNext;
                 default: break zzForAction;
               }
 
             case 10:
               switch (zzInput) {
-                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 41; break zzForNext;
+                case 2: zzIsFinal = true; zzNoLookAhead = true; zzState = 43; break zzForNext;
                 default: break zzForAction;
               }
 
             case 11:
               switch (zzInput) {
-                case 1: zzIsFinal = true; zzNoLookAhead = true; zzState = 42; break zzForNext;
+                case 1: zzIsFinal = true; zzNoLookAhead = true; zzState = 44; break zzForNext;
                 default: break zzForAction;
               }
 
             case 12:
               switch (zzInput) {
-                case 4: zzState = 43; break zzForNext;
+                case 4: zzState = 45; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -716,16 +731,19 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzState = 44; break zzForNext;
-                case 10: zzState = 45; break zzForNext;
+                case 9: 
+                case 28: zzState = 46; break zzForNext;
+                case 10: zzState = 47; break zzForNext;
                 default: break zzForAction;
               }
 
             case 14:
               switch (zzInput) {
                 case 15: zzState = 39; break zzForNext;
-                case 21: zzState = 40; break zzForNext;
-                case 11: zzState = 46; break zzForNext;
+                case 23: zzState = 40; break zzForNext;
+                case 41: zzState = 41; break zzForNext;
+                case 44: zzState = 42; break zzForNext;
+                case 11: zzState = 48; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -733,364 +751,374 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzState = 47; break zzForNext;
-                case 11: zzState = 48; break zzForNext;
+                case 9: 
+                case 28: zzState = 49; break zzForNext;
+                case 11: zzState = 50; break zzForNext;
                 default: break zzForAction;
               }
 
             case 16:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 49; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 51; break zzForNext;
                 default: break zzForAction;
               }
 
             case 17:
               switch (zzInput) {
-                case 32: zzState = 50; break zzForNext;
+                case 29: zzState = 52; break zzForNext;
                 default: break zzForAction;
               }
 
             case 18:
               switch (zzInput) {
-                case 20: zzState = 51; break zzForNext;
+                case 22: zzState = 53; break zzForNext;
                 default: break zzForAction;
               }
 
             case 19:
               switch (zzInput) {
-                case 18: zzState = 52; break zzForNext;
+                case 43: zzState = 54; break zzForNext;
                 default: break zzForAction;
               }
 
             case 20:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 53; break zzForNext;
+                case 17: zzState = 55; break zzForNext;
                 default: break zzForAction;
               }
 
             case 21:
               switch (zzInput) {
-                case 18: zzState = 54; break zzForNext;
+                case 43: zzState = 56; break zzForNext;
                 default: break zzForAction;
               }
 
             case 22:
               switch (zzInput) {
-                case 31: zzState = 55; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 57; break zzForNext;
                 default: break zzForAction;
               }
 
             case 23:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 56; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 58; break zzForNext;
                 default: break zzForAction;
               }
 
             case 25:
               switch (zzInput) {
                 case 6: 
-                case 8: zzIsFinal = true; zzState = 25; break zzForNext;
-                case 9: zzState = 57; break zzForNext;
+                case 8: 
+                case 28: zzIsFinal = true; zzState = 25; break zzForNext;
+                case 9: zzState = 59; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
               }
 
             case 26:
               switch (zzInput) {
                 case 6: 
-                case 8: zzIsFinal = true; zzState = 25; break zzForNext;
-                case 9: zzState = 57; break zzForNext;
+                case 8: 
+                case 28: zzIsFinal = true; zzState = 25; break zzForNext;
+                case 9: zzState = 59; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
               }
 
             case 31:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 58; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 60; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 32:
+            case 33:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 59; break zzForNext;
+                case 10: zzState = 61; break zzForNext;
                 default: break zzForAction;
               }
 
             case 34:
               switch (zzInput) {
-                case 10: zzState = 60; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 62; break zzForNext;
                 default: break zzForAction;
               }
 
             case 35:
               switch (zzInput) {
-                case 10: zzState = 60; break zzForNext;
+                case 10: zzState = 61; break zzForNext;
                 default: break zzForAction;
               }
 
             case 38:
               switch (zzInput) {
-                case 10: zzState = 60; break zzForNext;
+                case 10: zzState = 61; break zzForNext;
                 default: break zzForAction;
               }
 
             case 39:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 39; break zzForNext;
-                case 16: zzState = 61; break zzForNext;
+                case 16: zzState = 63; break zzForNext;
                 default: break zzForAction;
               }
 
             case 40:
               switch (zzInput) {
-                case 22: zzState = 62; break zzForNext;
+                case 19: zzState = 64; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 43:
-              switch (zzInput) {
-                case 5: zzIsFinal = true; zzNoLookAhead = true; zzState = 63; break zzForNext;
-                default: break zzForAction;
-              }
-
-            case 44:
+            case 41:
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzState = 44; break zzForNext;
-                case 10: zzState = 45; break zzForNext;
+                case 9: 
+                case 28: zzState = 41; break zzForNext;
+                case 42: zzState = 65; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 42:
+              switch (zzInput) {
+                case 30: zzState = 66; break zzForNext;
                 default: break zzForAction;
               }
 
             case 45:
               switch (zzInput) {
-                case 11: zzState = 46; break zzForNext;
+                case 5: zzIsFinal = true; zzNoLookAhead = true; zzState = 67; break zzForNext;
                 default: break zzForAction;
               }
 
             case 46:
               switch (zzInput) {
-                case 12: zzState = 64; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 46; break zzForNext;
+                case 10: zzState = 47; break zzForNext;
                 default: break zzForAction;
               }
 
             case 47:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 47; break zzForNext;
                 case 11: zzState = 48; break zzForNext;
                 default: break zzForAction;
               }
 
             case 48:
               switch (zzInput) {
-                case 33: zzIsFinal = true; zzNoLookAhead = true; zzState = 49; break zzForNext;
+                case 12: zzState = 68; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 49:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 49; break zzForNext;
+                case 11: zzState = 50; break zzForNext;
                 default: break zzForAction;
               }
 
             case 50:
               switch (zzInput) {
-                case 27: zzState = 65; break zzForNext;
-                default: break zzForAction;
-              }
-
-            case 51:
-              switch (zzInput) {
-                case 26: zzState = 66; break zzForNext;
+                case 46: zzIsFinal = true; zzNoLookAhead = true; zzState = 51; break zzForNext;
                 default: break zzForAction;
               }
 
             case 52:
               switch (zzInput) {
-                case 32: zzState = 67; break zzForNext;
+                case 18: zzState = 69; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 53:
+              switch (zzInput) {
+                case 37: zzState = 70; break zzForNext;
                 default: break zzForAction;
               }
 
             case 54:
               switch (zzInput) {
-                case 19: zzState = 68; break zzForNext;
+                case 29: zzState = 71; break zzForNext;
                 default: break zzForAction;
               }
 
             case 55:
               switch (zzInput) {
-                case 32: zzState = 69; break zzForNext;
+                case 29: zzState = 72; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 57:
+            case 56:
+              switch (zzInput) {
+                case 38: zzState = 73; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 59:
               switch (zzInput) {
                 case 6: 
-                case 8: zzIsFinal = true; zzState = 25; break zzForNext;
-                case 9: zzState = 57; break zzForNext;
+                case 8: 
+                case 28: zzIsFinal = true; zzState = 25; break zzForNext;
+                case 9: zzState = 59; break zzForNext;
                 default: zzIsFinal = true; zzNoLookAhead = true; zzState = 24; break zzForNext;
               }
 
-            case 60:
-              switch (zzInput) {
-                case 38: zzIsFinal = true; zzNoLookAhead = true; zzState = 30; break zzForNext;
-                default: break zzForAction;
-              }
-
             case 61:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 61; break zzForNext;
-                case 17: zzState = 70; break zzForNext;
+                case 32: zzIsFinal = true; zzNoLookAhead = true; zzState = 30; break zzForNext;
                 default: break zzForAction;
               }
 
-            case 62:
+            case 63:
               switch (zzInput) {
-                case 17: zzState = 71; break zzForNext;
+                case 17: zzState = 74; break zzForNext;
                 default: break zzForAction;
               }
 
             case 64:
               switch (zzInput) {
-                case 13: zzState = 72; break zzForNext;
+                case 13: zzState = 75; break zzForNext;
                 default: break zzForAction;
               }
 
             case 65:
               switch (zzInput) {
-                case 31: zzState = 73; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 65; break zzForNext;
+                case 21: zzState = 76; break zzForNext;
                 default: break zzForAction;
               }
 
             case 66:
               switch (zzInput) {
-                case 22: zzState = 74; break zzForNext;
-                default: break zzForAction;
-              }
-
-            case 67:
-              switch (zzInput) {
-                case 19: zzState = 75; break zzForNext;
+                case 21: zzState = 77; break zzForNext;
                 default: break zzForAction;
               }
 
             case 68:
               switch (zzInput) {
-                case 20: zzState = 76; break zzForNext;
+                case 13: zzState = 78; break zzForNext;
                 default: break zzForAction;
               }
 
             case 69:
               switch (zzInput) {
-                case 28: zzState = 77; break zzForNext;
+                case 17: zzState = 79; break zzForNext;
                 default: break zzForAction;
               }
 
             case 70:
               switch (zzInput) {
-                case 18: zzState = 78; break zzForNext;
+                case 30: zzState = 80; break zzForNext;
                 default: break zzForAction;
               }
 
             case 71:
               switch (zzInput) {
-                case 23: zzState = 79; break zzForNext;
+                case 38: zzState = 81; break zzForNext;
                 default: break zzForAction;
               }
 
             case 72:
               switch (zzInput) {
-                case 14: zzState = 80; break zzForNext;
+                case 19: zzState = 82; break zzForNext;
                 default: break zzForAction;
               }
 
             case 73:
               switch (zzInput) {
-                case 24: zzState = 81; break zzForNext;
+                case 22: zzState = 83; break zzForNext;
                 default: break zzForAction;
               }
 
             case 74:
               switch (zzInput) {
-                case 25: zzState = 82; break zzForNext;
+                case 18: zzState = 84; break zzForNext;
                 default: break zzForAction;
               }
 
             case 75:
               switch (zzInput) {
-                case 34: zzState = 83; break zzForNext;
+                case 14: zzState = 85; break zzForNext;
                 default: break zzForAction;
               }
 
             case 76:
               switch (zzInput) {
-                case 20: zzState = 84; break zzForNext;
+                case 43: zzState = 86; break zzForNext;
                 default: break zzForAction;
               }
 
             case 77:
               switch (zzInput) {
-                case 20: zzState = 85; break zzForNext;
+                case 33: zzState = 87; break zzForNext;
                 default: break zzForAction;
               }
 
             case 78:
               switch (zzInput) {
-                case 19: zzState = 86; break zzForNext;
+                case 14: zzState = 88; break zzForNext;
                 default: break zzForAction;
               }
 
             case 79:
               switch (zzInput) {
-                case 24: zzState = 87; break zzForNext;
+                case 16: zzState = 89; break zzForNext;
                 default: break zzForAction;
               }
 
             case 80:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 88; break zzForNext;
+                case 26: zzState = 90; break zzForNext;
                 default: break zzForAction;
               }
 
             case 81:
               switch (zzInput) {
-                case 25: zzState = 89; break zzForNext;
+                case 24: zzState = 91; break zzForNext;
                 default: break zzForAction;
               }
 
             case 82:
               switch (zzInput) {
-                case 31: zzState = 90; break zzForNext;
+                case 22: zzState = 92; break zzForNext;
                 default: break zzForAction;
               }
 
             case 83:
               switch (zzInput) {
-                case 18: zzState = 91; break zzForNext;
+                case 22: zzState = 93; break zzForNext;
                 default: break zzForAction;
               }
 
             case 84:
               switch (zzInput) {
-                case 32: zzState = 92; break zzForNext;
+                case 19: zzState = 94; break zzForNext;
                 default: break zzForAction;
               }
 
             case 85:
               switch (zzInput) {
-                case 32: zzState = 93; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 85; break zzForNext;
+                case 12: zzState = 95; break zzForNext;
                 default: break zzForAction;
               }
 
             case 86:
               switch (zzInput) {
-                case 20: zzState = 94; break zzForNext;
+                case 38: zzState = 96; break zzForNext;
                 default: break zzForAction;
               }
 
             case 87:
               switch (zzInput) {
-                case 25: zzState = 95; break zzForNext;
+                case 16: zzState = 97; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1098,142 +1126,134 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzIsFinal = true; zzState = 88; break zzForNext;
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 98; break zzForNext;
                 default: break zzForAction;
               }
 
             case 89:
               switch (zzInput) {
-                case 32: zzState = 96; break zzForNext;
+                case 26: zzState = 99; break zzForNext;
                 default: break zzForAction;
               }
 
             case 90:
               switch (zzInput) {
-                case 32: zzState = 97; break zzForNext;
+                case 17: zzState = 100; break zzForNext;
                 default: break zzForAction;
               }
 
             case 91:
               switch (zzInput) {
-                case 19: zzState = 98; break zzForNext;
+                case 43: zzState = 101; break zzForNext;
                 default: break zzForAction;
               }
 
             case 92:
               switch (zzInput) {
-                case 27: zzState = 99; break zzForNext;
+                case 29: zzState = 102; break zzForNext;
                 default: break zzForAction;
               }
 
             case 93:
               switch (zzInput) {
-                case 28: zzState = 100; break zzForNext;
+                case 29: zzState = 103; break zzForNext;
                 default: break zzForAction;
               }
 
             case 94:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 101; break zzForNext;
+                case 20: zzState = 104; break zzForNext;
                 default: break zzForAction;
               }
 
             case 95:
               switch (zzInput) {
-                case 26: zzState = 102; break zzForNext;
+                case 13: zzState = 105; break zzForNext;
                 default: break zzForAction;
               }
 
             case 96:
               switch (zzInput) {
-                case 19: zzState = 103; break zzForNext;
+                case 22: zzState = 106; break zzForNext;
                 default: break zzForAction;
               }
 
             case 97:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 97; break zzForNext;
-                case 7: zzIsFinal = true; zzState = 104; break zzForNext;
+                case 26: zzState = 107; break zzForNext;
                 default: break zzForAction;
               }
 
             case 98:
               switch (zzInput) {
-                case 20: zzState = 105; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 98; break zzForNext;
                 default: break zzForAction;
               }
 
             case 99:
               switch (zzInput) {
-                case 31: zzState = 106; break zzForNext;
+                case 29: zzState = 108; break zzForNext;
                 default: break zzForAction;
               }
 
             case 100:
               switch (zzInput) {
-                case 28: zzState = 107; break zzForNext;
+                case 29: zzState = 109; break zzForNext;
                 default: break zzForAction;
               }
 
             case 101:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 101; break zzForNext;
+                case 38: zzState = 110; break zzForNext;
                 default: break zzForAction;
               }
 
             case 102:
               switch (zzInput) {
-                case 20: zzState = 108; break zzForNext;
+                case 19: zzState = 111; break zzForNext;
                 default: break zzForAction;
               }
 
             case 103:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 103; break zzForNext;
-                case 7: zzIsFinal = true; zzState = 109; break zzForNext;
+                case 18: zzState = 112; break zzForNext;
                 default: break zzForAction;
               }
 
             case 104:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 104; break zzForNext;
+                case 21: zzState = 113; break zzForNext;
                 default: break zzForAction;
               }
 
             case 105:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 105; break zzForNext;
-                case 7: zzIsFinal = true; zzState = 110; break zzForNext;
+                case 14: zzState = 114; break zzForNext;
                 default: break zzForAction;
               }
 
             case 106:
               switch (zzInput) {
-                case 24: zzState = 111; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 115; break zzForNext;
                 default: break zzForAction;
               }
 
             case 107:
               switch (zzInput) {
-                case 35: zzState = 112; break zzForNext;
+                case 37: zzState = 116; break zzForNext;
                 default: break zzForAction;
               }
 
             case 108:
               switch (zzInput) {
-                case 27: zzState = 113; break zzForNext;
+                case 38: zzState = 117; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1241,57 +1261,64 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzIsFinal = true; zzState = 109; break zzForNext;
+                case 9: 
+                case 28: zzState = 109; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 118; break zzForNext;
                 default: break zzForAction;
               }
 
             case 110:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 110; break zzForNext;
+                case 22: zzState = 119; break zzForNext;
                 default: break zzForAction;
               }
 
             case 111:
               switch (zzInput) {
-                case 25: zzState = 114; break zzForNext;
+                case 19: zzState = 120; break zzForNext;
                 default: break zzForAction;
               }
 
             case 112:
               switch (zzInput) {
-                case 17: zzState = 115; break zzForNext;
+                case 17: zzState = 121; break zzForNext;
                 default: break zzForAction;
               }
 
             case 113:
               switch (zzInput) {
-                case 28: zzState = 116; break zzForNext;
+                case 22: zzState = 122; break zzForNext;
                 default: break zzForAction;
               }
 
             case 114:
               switch (zzInput) {
-                case 32: zzState = 117; break zzForNext;
+                case 29: zzState = 123; break zzForNext;
                 default: break zzForAction;
               }
 
             case 115:
               switch (zzInput) {
-                case 20: zzState = 118; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 115; break zzForNext;
                 default: break zzForAction;
               }
 
             case 116:
               switch (zzInput) {
-                case 25: zzState = 119; break zzForNext;
+                case 22: zzState = 124; break zzForNext;
                 default: break zzForAction;
               }
 
             case 117:
               switch (zzInput) {
-                case 19: zzState = 120; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 117; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 125; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1299,57 +1326,644 @@
               switch (zzInput) {
                 case 6: 
                 case 8: 
-                case 9: zzState = 118; break zzForNext;
-                case 7: zzIsFinal = true; zzState = 121; break zzForNext;
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 118; break zzForNext;
                 default: break zzForAction;
               }
 
             case 119:
               switch (zzInput) {
-                case 29: zzState = 122; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 119; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 126; break zzForNext;
                 default: break zzForAction;
               }
 
             case 120:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzState = 120; break zzForNext;
-                case 7: zzIsFinal = true; zzState = 123; break zzForNext;
+                case 20: zzState = 127; break zzForNext;
                 default: break zzForAction;
               }
 
             case 121:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 121; break zzForNext;
+                case 16: zzState = 128; break zzForNext;
                 default: break zzForAction;
               }
 
             case 122:
               switch (zzInput) {
-                case 20: zzState = 124; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 122; break zzForNext;
+                case 23: zzState = 129; break zzForNext;
+                case 34: zzState = 130; break zzForNext;
                 default: break zzForAction;
               }
 
             case 123:
               switch (zzInput) {
-                case 6: 
-                case 8: 
-                case 9: zzIsFinal = true; zzState = 123; break zzForNext;
+                case 30: zzState = 131; break zzForNext;
                 default: break zzForAction;
               }
 
             case 124:
               switch (zzInput) {
-                case 30: zzState = 125; break zzForNext;
+                case 18: zzState = 132; break zzForNext;
                 default: break zzForAction;
               }
 
             case 125:
               switch (zzInput) {
-                case 17: zzState = 70; break zzForNext;
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 125; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 126:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 126; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 127:
+              switch (zzInput) {
+                case 21: zzState = 133; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 128:
+              switch (zzInput) {
+                case 26: zzState = 134; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 129:
+              switch (zzInput) {
+                case 19: zzState = 135; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 130:
+              switch (zzInput) {
+                case 13: zzState = 136; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 131:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 131; break zzForNext;
+                case 7: zzState = 137; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 132:
+              switch (zzInput) {
+                case 19: zzState = 138; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 133:
+              switch (zzInput) {
+                case 22: zzState = 139; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 134:
+              switch (zzInput) {
+                case 29: zzState = 140; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 135:
+              switch (zzInput) {
+                case 13: zzState = 141; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 136:
+              switch (zzInput) {
+                case 14: zzState = 142; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 137:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 137; break zzForNext;
+                case 31: 
+                case 32: zzState = 143; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 138:
+              switch (zzInput) {
+                case 26: zzState = 144; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 139:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 139; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 145; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 140:
+              switch (zzInput) {
+                case 38: zzState = 146; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 141:
+              switch (zzInput) {
+                case 14: zzState = 147; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 142:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 142; break zzForNext;
+                case 21: zzState = 148; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 143:
+              switch (zzInput) {
+                case 23: zzState = 149; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 144:
+              switch (zzInput) {
+                case 45: zzState = 150; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 145:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 145; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 146:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 146; break zzForNext;
+                case 7: zzIsFinal = true; zzState = 151; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 147:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzState = 147; break zzForNext;
+                case 21: zzState = 152; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 148:
+              switch (zzInput) {
+                case 24: zzState = 153; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 149:
+              switch (zzInput) {
+                case 19: zzState = 154; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 150:
+              switch (zzInput) {
+                case 22: zzState = 155; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 151:
+              switch (zzInput) {
+                case 6: 
+                case 8: 
+                case 9: 
+                case 28: zzIsFinal = true; zzState = 151; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 152:
+              switch (zzInput) {
+                case 24: zzState = 156; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 153:
+              switch (zzInput) {
+                case 25: zzState = 157; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 154:
+              switch (zzInput) {
+                case 19: zzState = 158; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 155:
+              switch (zzInput) {
+                case 35: zzState = 159; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 156:
+              switch (zzInput) {
+                case 25: zzState = 160; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 157:
+              switch (zzInput) {
+                case 14: zzState = 161; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 158:
+              switch (zzInput) {
+                case 21: zzState = 162; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 159:
+              switch (zzInput) {
+                case 21: zzState = 76; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 160:
+              switch (zzInput) {
+                case 14: zzState = 163; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 161:
+              switch (zzInput) {
+                case 26: zzState = 164; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 162:
+              switch (zzInput) {
+                case 33: zzState = 165; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 163:
+              switch (zzInput) {
+                case 26: zzState = 166; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 164:
+              switch (zzInput) {
+                case 18: zzState = 167; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 165:
+              switch (zzInput) {
+                case 27: zzState = 168; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 166:
+              switch (zzInput) {
+                case 18: zzState = 169; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 167:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 168:
+              switch (zzInput) {
+                case 27: zzState = 171; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 169:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 170:
+              switch (zzInput) {
+                case 27: zzState = 173; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 171:
+              switch (zzInput) {
+                case 34: zzState = 174; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 172:
+              switch (zzInput) {
+                case 27: zzState = 175; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 173:
+              switch (zzInput) {
+                case 27: zzState = 173; break zzForNext;
+                case 16: zzState = 176; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 174:
+              switch (zzInput) {
+                case 34: zzState = 177; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 175:
+              switch (zzInput) {
+                case 27: zzState = 175; break zzForNext;
+                case 16: zzState = 178; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 176:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 19: zzState = 179; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 177:
+              switch (zzInput) {
+                case 34: zzState = 180; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 178:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 19: zzState = 181; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 179:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 16: zzState = 182; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 180:
+              switch (zzInput) {
+                case 35: zzState = 183; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 181:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 16: zzState = 184; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 182:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 28: zzState = 185; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 183:
+              switch (zzInput) {
+                case 34: zzState = 186; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 184:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 28: zzState = 187; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 185:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 34: zzState = 188; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 186:
+              switch (zzInput) {
+                case 36: zzState = 189; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 187:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 12: zzState = 190; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 188:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 13: zzState = 191; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 189:
+              switch (zzInput) {
+                case 35: zzState = 192; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 190:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 23: zzState = 193; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 191:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 14: zzIsFinal = true; zzState = 194; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 192:
+              switch (zzInput) {
+                case 17: zzState = 195; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 193:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 19: zzState = 196; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 194:
+              switch (zzInput) {
+                case 27: zzState = 170; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 167; break zzForNext;
+              }
+
+            case 195:
+              switch (zzInput) {
+                case 37: zzState = 197; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 196:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 13: zzState = 198; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 197:
+              switch (zzInput) {
+                case 38: zzState = 199; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 198:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 14: zzIsFinal = true; zzState = 200; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 199:
+              switch (zzInput) {
+                case 27: zzState = 201; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 200:
+              switch (zzInput) {
+                case 27: zzState = 172; break zzForNext;
+                case 9: break zzForAction;
+                default: zzState = 169; break zzForNext;
+              }
+
+            case 201:
+              switch (zzInput) {
+                case 39: zzState = 202; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 202:
+              switch (zzInput) {
+                case 40: zzState = 203; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 203:
+              switch (zzInput) {
+                case 40: zzState = 204; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 204:
+              switch (zzInput) {
+                case 40: zzState = 205; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 205:
+              switch (zzInput) {
+                case 27: zzState = 206; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 206:
+              switch (zzInput) {
+                case 12: zzState = 207; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 207:
+              switch (zzInput) {
+                case 23: zzState = 208; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 208:
+              switch (zzInput) {
+                case 19: zzState = 209; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 209:
+              switch (zzInput) {
+                case 13: zzState = 210; break zzForNext;
+                default: break zzForAction;
+              }
+
+            case 210:
+              switch (zzInput) {
+                case 14: zzIsFinal = true; zzNoLookAhead = true; zzState = 211; break zzForNext;
                 default: break zzForAction;
               }
 
@@ -1375,99 +1989,107 @@
         case 10: 
           { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16BE;}
           }
-        case 25: break;
+        case 27: break;
         case 17: 
           { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF83ByteBOM;}
           }
-        case 26: break;
+        case 28: break;
         case 4: 
           { yybegin(SQ_STRING); string.setLength(0);
           }
-        case 27: break;
+        case 29: break;
         case 5: 
           { string.append( yytext() );
           }
-        case 28: break;
+        case 30: break;
         case 22: 
           { pushCurrentState(); yybegin(QuotedAttributeValue); return JSPHeadTokenizerConstants.PageLanguage;
           }
-        case 29: break;
+        case 31: break;
+        case 26: 
+          { isXHTML = true;
+          }
+        case 32: break;
         case 24: 
           { pushCurrentState(); yybegin(QuotedAttributeValue); return JSPHeadTokenizerConstants.PageEncoding;
           }
-        case 30: break;
+        case 33: break;
         case 1: 
           { if (yychar > MAX_TO_SCAN) {hasMore=false; return EncodingParserConstants.MAX_CHARS_REACHED;}
           }
-        case 31: break;
+        case 34: break;
         case 11: 
           { if (yychar == 0 ) {hasMore = false; return EncodingParserConstants.UTF16LE;}
           }
-        case 32: break;
+        case 35: break;
         case 6: 
           { yypushback(1);popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;
           }
-        case 33: break;
+        case 36: break;
         case 8: 
           { yypushback(1);popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue;
           }
-        case 34: break;
+        case 37: break;
         case 9: 
           { yypushback(1);popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;
           }
-        case 35: break;
+        case 38: break;
         case 7: 
           { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue;
           }
-        case 36: break;
-        case 13: 
+        case 39: break;
+        case 14: 
           { yybegin(YYINITIAL);  return JSPHeadTokenizerConstants.PageDirectiveEnd;
           }
-        case 37: break;
+        case 40: break;
         case 23: 
           { pushCurrentState(); yybegin(QuotedAttributeValue); return JSPHeadTokenizerConstants.PageContentType;
           }
-        case 38: break;
+        case 41: break;
         case 18: 
           { if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;}
           }
-        case 39: break;
+        case 42: break;
         case 15: 
           { yypushback(2); popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;
           }
-        case 40: break;
+        case 43: break;
         case 2: 
           { yypushback(1); yybegin(UnDelimitedString); string.setLength(0);
           }
-        case 41: break;
+        case 44: break;
         case 12: 
           { yybegin(YYINITIAL); return XMLHeadTokenizerConstants.XMLDeclEnd;
           }
-        case 42: break;
-        case 14: 
+        case 45: break;
+        case 13: 
           { yybegin(YYINITIAL); return JSPHeadTokenizerConstants.PageDirectiveEnd;
           }
-        case 43: break;
+        case 46: break;
+        case 25: 
+          { isWML = true;
+          }
+        case 47: break;
         case 19: 
           { yybegin(ST_PAGE_DIRECTIVE); return JSPHeadTokenizerConstants.PageDirectiveStart;
           }
-        case 44: break;
+        case 48: break;
         case 21: 
           { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDelEncoding;
           }
-        case 45: break;
+        case 49: break;
         case 20: 
           { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDeclVersion;
           }
-        case 46: break;
+        case 50: break;
         case 16: 
           { yypushback(2);popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue;
           }
-        case 47: break;
+        case 51: break;
         case 3: 
           { yybegin(DQ_STRING); string.setLength(0);
           }
-        case 48: break;
+        case 52: break;
         default: 
           if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
             zzAtEOF = true;
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPResourceEncodingDetector.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPResourceEncodingDetector.java
index 41127ad..521af02 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPResourceEncodingDetector.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contenttype/JSPResourceEncodingDetector.java
@@ -53,6 +53,10 @@
 
 	private Reader fReader;
 
+	private boolean fXHTML;
+
+	private boolean fWML;
+
 
 	/**
 	 * No Arg constructor.
@@ -428,6 +432,13 @@
 		if (fContentTypeValue != null) {
 			parseContentTypeValue(fContentTypeValue);
 		}
+		if (tokenizer.isXHTML()) {
+			fXHTML = true;
+		}
+		if (tokenizer.isWML() ) {
+			fWML = true;
+		}
+		
 
 	}
 
@@ -457,6 +468,8 @@
 		fPageEncodingValue = null;
 		fXMLDecEncodingName = null;
 		unicodeCase = false;
+		fXHTML=false;
+		fWML=false;
 	}
 
 
@@ -479,4 +492,30 @@
 			throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$
 		}
 	}
+
+	public boolean isWML() throws IOException {
+		ensureInputSet();
+		if (!fHeaderParsed) {
+			parseInput();
+			// we keep track of if header's already been parse, so can make
+			// multiple 'get' calls, without causing reparsing.
+			fHeaderParsed = true;
+			// Note: there is a "hidden assumption" here that an empty
+			// string in content should be treated same as not present.
+		}
+		return fWML;
+	}
+
+	public boolean isXHTML() throws IOException {
+		ensureInputSet();
+		if (!fHeaderParsed) {
+			parseInput();
+			// we keep track of if header's already been parse, so can make
+			// multiple 'get' calls, without causing reparsing.
+			fHeaderParsed = true;
+			// Note: there is a "hidden assumption" here that an empty
+			// string in content should be treated same as not present.
+		}
+		return fXHTML;
+	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/document/PageDirectiveAdapterImpl.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/document/PageDirectiveAdapterImpl.java
index cd49952..5a383f8 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/document/PageDirectiveAdapterImpl.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/document/PageDirectiveAdapterImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004-2006 IBM Corporation 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
@@ -10,20 +10,28 @@
  *******************************************************************************/
 package org.eclipse.jst.jsp.core.internal.document;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import com.ibm.icu.util.StringTokenizer;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IDocumentExtension3;
 import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jst.jsp.core.internal.Logger;
 import org.eclipse.jst.jsp.core.internal.contentproperties.JSPFContentProperties;
 import org.eclipse.jst.jsp.core.internal.modelhandler.EmbeddedTypeStateData;
+import org.eclipse.jst.jsp.core.internal.provisional.contenttype.ContentTypeIdForJSP;
+import org.eclipse.jst.jsp.core.internal.provisional.contenttype.IContentDescriptionForJSP;
 import org.eclipse.jst.jsp.core.internal.text.StructuredTextPartitionerForJSP;
+import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeFamilyForHTML;
 import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
 import org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry;
 import org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistryImpl;
@@ -33,9 +41,12 @@
 import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
 import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitioning;
 import org.eclipse.wst.sse.core.internal.util.Debug;
+import org.eclipse.wst.sse.core.internal.util.DocumentInputStream;
 import org.eclipse.wst.sse.core.utils.StringUtils;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
 
+import com.ibm.icu.util.StringTokenizer;
+
 /**
  * This class has the responsibility to provide an embedded factory registry
  * for JSP Aware INodeAdapter Factories to use.
@@ -369,7 +380,7 @@
 		}
 		// BUG136468
 		if (type == null)
-            type = "text/html"; //$NON-NLS-1$
+			type = "text/html"; //$NON-NLS-1$
 		return type;
 	}
 
@@ -408,53 +419,79 @@
 	 *            The cachedContentType to set
 	 */
 	public void setCachedContentType(String newContentType) {
-		// if the passed in value is the same as existing, there's nothing to
-		// do.
-		// if its different, then we need to change the contentHandler as well
-		// and, more to the point, signal a re-initializtation is needed.
-		// Note: if the value we're getting set to does not have a handler in
-		// the registry,
-		// we'll actually not set it to null or anything, we'll just continue
-		// on with the one
-		// we have. This is pretty important to avoid re-initializing on every
-		// key stroke if someone
-		// is typing in a new content type, but haven't yet finished the whole
-		// "word".
-		// However, if an contentType is not recognized, the registry returns
-		// the one
-		// for XML.
-		// if (this.cachedContentType != null &&
-		// this.cachedContentType.equalsIgnoreCase(newContentType)) { // then
-		// do nothing
-		// } else {
+		/*
+		 * if the passed in value is the same as existing, there's nothing to
+		 * do. if its different, then we need to change the contentHandler as
+		 * well and, more to the point, signal a re-initializtation is needed.
+		 * 
+		 * Note: if the value we're getting set to does not have a handler in
+		 * the registry, we'll actually not set it to null or anything, we'll
+		 * just continue on with the one we have. This is pretty important to
+		 * avoid re-initializing on every key stroke if someone is typing in a
+		 * new content type, but haven't yet finished the whole "word".
+		 * However, if an contentType is not recognized, the registry returns
+		 * the one for XML.
+		 */
+		
+		/* set the actual value first, the rest is "side effect" */
 		this.cachedContentType = newContentType;
-		// see if we can update embedded handler
-		// if (this.cachedContentType == null ||
-		// this.cachedContentType.length() == 0) { // do nothing, don't can't
-		// get a new handler, so we'll keep what we have
-		// } else {
 
-		// getHandler should always return something (never null), based
-		// on the rules in the factory.
-		EmbeddedTypeHandler handler = getHandlerFor(this.cachedContentType);
-		// we do this check for re-init here, instead of in setEmbeddedType,
-		// since setEmbeddedType is called during the normal initializtion
-		// process, when re-init is not needed (since there is no content)
-		if (embeddedTypeHandler != null && handler != null && embeddedTypeHandler != handler) {
-			// changing this embedded handler here may
-			// be in the middle of anotify loop, not sure
-			// if that'll cause problems.
+		/* see if we need to update embedded handler */
 
-			// be sure to hold oldHandler in temp var
-			// or else setEmbeddedType will "reset" it
-			// before modelReinitNeeded(oldHandler, handler) is called
-			EmbeddedTypeHandler oldHandler = embeddedTypeHandler;
-			setEmbeddedType(handler);
-			modelReinitNeeded(oldHandler, handler);
+		/*
+		 * If the document is a type of XHTML, we do not use the page
+		 * directive's contentType to determine the embedded type ... its
+		 * XHTML! ... and, eventually, the DOCTYPE adapter should determine
+		 * if/when it needs to change.
+		 */
+
+		/* just safety check, can be removed later, early in release cycle */
+		if (model == null) {
+			// throw IllegalStateException("model should never be null in
+			// PageDirective Adapter");
+			Logger.log(Logger.ERROR, "model should never be null in PageDirective Adapter");
+			return;
 		}
-		// }
 
-		// }
+		EmbeddedTypeHandler potentialNewandler = null;
+		IContentDescription contentDescription = getContentDescription(model.getStructuredDocument());
+		Object prop = contentDescription.getProperty(IContentDescriptionForJSP.CONTENT_FAMILY_ATTRIBUTE);
+		if (prop != null) {
+			if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(prop)) {
+				potentialNewandler = EmbeddedTypeRegistryImpl.getInstance().getTypeFor("text/html");
+			}
+		}
+
+		if (potentialNewandler == null) {
+			/*
+			 * getHandler should always return something (never null), based
+			 * on the rules in the factory.
+			 */
+			potentialNewandler = getHandlerFor(this.cachedContentType);
+		}
+		/*
+		 * we do this check for re-init here, instead of in setEmbeddedType,
+		 * since setEmbeddedType is called during the normal initializtion
+		 * process, when re-init is not needed (since there is no content)
+		 */
+		if (embeddedTypeHandler == null) {
+			setEmbeddedType(potentialNewandler);
+		}
+		else if (potentialNewandler != null && embeddedTypeHandler != potentialNewandler) {
+			/*
+			 * changing this embedded handler here may be in the middle of a
+			 * notify loop. That's why we set that "it's needed". Then the
+			 * model decides when its "safe" to actually do the re-init.
+			 * 
+			 * be sure to hold oldHandler in temp var or else setEmbeddedType
+			 * will "reset" it before modelReinitNeeded(oldHandler, handler)
+			 * is called
+			 * 
+			 */
+			EmbeddedTypeHandler oldHandler = embeddedTypeHandler;
+			setEmbeddedType(potentialNewandler);
+			modelReinitNeeded(oldHandler, potentialNewandler);
+		}
 
 	}
 
@@ -505,30 +542,18 @@
 	}
 
 	public void setCachedLanguage(String newLanguage) {
-		if (cachedLanguage != null && languageStateChanged(cachedLanguage, newLanguage)) { // a
-			// complete
-			// re-init
-			// overkill
-			// in
-			// current
-			// system,
-			// since
-			// really
-			// just
-			// need
-			// for
-			// the line style providers,
-			// BUT, a change in language could effect other things,
-			// and we don't expect to happen often so a little overkill isn't
-			// too bad.
-			// The deep problem is that there is no way to get at the "edit
-			// side" adpapters
-			// specifically here in model class.
-			// we have to do the model changed sequence to get the
-			// screen to update.
-			// do not signal again, if signaled once (the reinit state data
-			// will be wrong.
-			// (this needs to be improved in future)
+		if (cachedLanguage != null && languageStateChanged(cachedLanguage, newLanguage)) {
+			/*
+			 * a complete re-init overkill in current system, since really
+			 * just need for the line style providers, BUT, a change in
+			 * language could effect other things, and we don't expect to
+			 * happen often so a little overkill isn't too bad. The deep
+			 * problem is that there is no way to get at the "edit side"
+			 * adpapters specifically here in model class. we have to do the
+			 * model changed sequence to get the screen to update. do not
+			 * signal again, if signaled once (the reinit state data will be
+			 * wrong. (this needs to be improved in future)
+			 */
 			if (!model.isReinitializationNeeded()) {
 				modelReinitNeeded(cachedLanguage, newLanguage);
 			}
@@ -635,4 +660,45 @@
 			embeddedTypeHandler = null;
 		}
 	}
+
+	private IContentDescription getContentDescription(IDocument doc) {
+		if (doc == null)
+			return null;
+		DocumentInputStream in = new DocumentInputStream(doc);
+		return getContentDescription(in);
+	}
+
+	/**
+	 * Returns content description for an input stream Assumes it's JSP
+	 * content. Closes the input stream when finished.
+	 * 
+	 * @param in
+	 * @return the IContentDescription for in, or null if in is null
+	 */
+	private IContentDescription getContentDescription(DocumentInputStream in) {
+
+		if (in == null)
+			return null;
+
+		IContentDescription desc = null;
+		try {
+
+			IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSP);
+			desc = contentTypeJSP.getDescriptionFor(in, IContentDescription.ALL);
+		}
+		catch (IOException e) {
+			Logger.logException(e);
+		}
+		finally {
+			if (in != null) {
+				try {
+					in.close();
+				}
+				catch (IOException e) {
+					Logger.logException(e);
+				}
+			}
+		}
+		return desc;
+	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelhandler/JSPModelLoader.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelhandler/JSPModelLoader.java
index b8a0765..104344f 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelhandler/JSPModelLoader.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelhandler/JSPModelLoader.java
@@ -43,6 +43,7 @@
 import org.eclipse.jst.jsp.core.internal.provisional.contenttype.ContentTypeIdForJSP;
 import org.eclipse.jst.jsp.core.internal.provisional.contenttype.IContentDescriptionForJSP;
 import org.eclipse.jst.jsp.core.internal.text.StructuredTextPartitionerForJSP;
+import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeFamilyForHTML;
 import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
 import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML;
 import org.eclipse.wst.sse.core.internal.PropagatingAdapter;
@@ -242,7 +243,12 @@
 		if (buf != null) {
 			doc = buf.getDocument();
 		}
-		return (doc != null) ? getContentDescription(doc) : null;
+
+		IContentDescription contentDescription = null;
+		if (doc != null) {
+			contentDescription = getContentDescription(doc);
+		}
+		return contentDescription;
 	}
 
 	/**
@@ -494,12 +500,26 @@
 		IDOMModel domModel = (IDOMModel) model;
 
 		String possibleFileBaseLocation = model.getBaseLocation();
-		IContentDescription desc = getContentDescription(possibleFileBaseLocation);
-		if (desc != null) {
-			Object prop = null;
-			prop = desc.getProperty(IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE);
-			if (prop != null) {
-				embeddedContentType = EmbeddedTypeRegistryImpl.getInstance().getTypeFor((String) prop);
+
+		if (embeddedContentType == null) {
+			IContentDescription desc = getContentDescription(possibleFileBaseLocation);
+			if (desc != null) {
+				Object prop = null;
+
+				prop = desc.getProperty(IContentDescriptionForJSP.CONTENT_FAMILY_ATTRIBUTE);
+				if (prop != null) {
+					if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(prop)) {
+						embeddedContentType = EmbeddedTypeRegistryImpl.getInstance().getTypeFor("text/html");
+					}
+				}
+
+				if (embeddedContentType == null) {
+
+					prop = desc.getProperty(IContentDescriptionForJSP.CONTENT_TYPE_ATTRIBUTE);
+					if (prop != null) {
+						embeddedContentType = EmbeddedTypeRegistryImpl.getInstance().getTypeFor((String) prop);
+					}
+				}
 			}
 		}
 
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelquery/JSPModelQueryImpl.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelquery/JSPModelQueryImpl.java
index d3f29d7..1f9dacf 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelquery/JSPModelQueryImpl.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/modelquery/JSPModelQueryImpl.java
@@ -16,6 +16,7 @@
 
 import org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter;
 import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
+import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeFamilyForHTML;
 import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
 import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
 import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
@@ -31,8 +32,10 @@
 
 public class JSPModelQueryImpl extends ModelQueryImpl {
 
+	// ISSUE: jspModel doesn't seem used?
 	protected IStructuredModel jspModel = null;
 	private HashMap embeddedModelQueries = new HashMap();
+
 	public JSPModelQueryImpl(IStructuredModel model, URIResolver resolver) {
 		super(new JSPModelQueryAssociationProvider());
 		jspModel = model;
@@ -88,37 +91,51 @@
 			return super.getAvailableContent(element, ed, includeOptions);
 	}
 
+	// ISSUE: shouldn't this be private?
 	protected ModelQuery getEmbeddedModelQuery(Node node) {
-	    ModelQuery emq = null;
-		   
-			if (node instanceof INodeNotifier) {
-				Node ownerNode = node.getOwnerDocument();
-				if (ownerNode == null) {
-					// then must be the document itself
-					ownerNode = node;
+		ModelQuery embeddedModelQuery = null;
+
+		if (node instanceof INodeNotifier) { 
+			Node ownerNode = node.getOwnerDocument();
+			if (ownerNode == null) {
+				// then must be the document itself
+				ownerNode = node; 
+			}
+			PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
+			if (pageDirectiveAdapter != null) {
+
+				String effectiveContentType = null;
+				ModelQuery potentialModelQueryObject = null;
+
+				String familyId = pageDirectiveAdapter.getEmbeddedType().getFamilyId();
+				if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(familyId)) {
+					effectiveContentType = "text/html";
 				}
-				PageDirectiveAdapter typeadapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
-				if (typeadapter != null) {
-				    
-				    String contentType = typeadapter.getContentType();
-				    Object o = embeddedModelQueries.get(contentType);
-				    if(o == null) {
-						ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) typeadapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
-						if (embeddedAdapter != null) {
-						    // we will cache one model query per content type
-						    emq = embeddedAdapter.getModelQuery();
-						    embeddedModelQueries.put(contentType, emq);
-						}
-				    }
-					else {
-					    emq = (ModelQuery)o;
+				else {
+					effectiveContentType = pageDirectiveAdapter.getContentType();
+				}
+				
+				potentialModelQueryObject = (ModelQuery) embeddedModelQueries.get(effectiveContentType);
+				
+				if (potentialModelQueryObject == null) {
+					ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
+					if (embeddedAdapter != null) {
+						// we will cache one model query per content type
+						embeddedModelQuery = embeddedAdapter.getModelQuery();
+						embeddedModelQueries.put(effectiveContentType, embeddedModelQuery);
 					}
 				}
+				else {
+					embeddedModelQuery = potentialModelQueryObject;
+				}
 			}
-			return emq;
+		}
+		return embeddedModelQuery;
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery#getCMAttributeDeclaration(org.w3c.dom.Attr)
 	 */
 	public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr) {
@@ -131,4 +148,15 @@
 		}
 		return result;
 	}
+	
+	/**
+	 * NOT API -- this is provided, and is public, only to make some JUnit testing 
+	 * more straightforward. It will be changed in future, and from release to release.
+	 * 
+	 * @param node
+	 * @return
+	 */
+	public ModelQuery internalTestOnly_getEmbeddedModelQuery(Node node) {
+		return getEmbeddedModelQuery(node);
+	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/provisional/contenttype/IContentDescriptionForJSP.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/provisional/contenttype/IContentDescriptionForJSP.java
index 6caee22..4eb89e3 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/provisional/contenttype/IContentDescriptionForJSP.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/provisional/contenttype/IContentDescriptionForJSP.java
@@ -20,5 +20,6 @@
 	 */
 	public final static QualifiedName CONTENT_TYPE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentTypeAttribute"); //$NON-NLS-1$
 	public final static QualifiedName LANGUAGE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "languageAttribute"); //$NON-NLS-1$
+	public final static QualifiedName CONTENT_FAMILY_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentFamilyAttribute"); //$NON-NLS-1$;
 
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/text/StructuredTextPartitionerForJSP.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/text/StructuredTextPartitionerForJSP.java
index 672addf..8f5433f 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/text/StructuredTextPartitionerForJSP.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/text/StructuredTextPartitionerForJSP.java
@@ -109,17 +109,23 @@
 
 	private IStructuredTextPartitioner createStructuredTextPartitioner(IStructuredDocument structuredDocument) {
 		IStructuredTextPartitioner result = null;
+		// this same detector should underly content describer, to have consistent results
 		JSPDocumentHeadContentDetector jspHeadContentDetector = new JSPDocumentHeadContentDetector();
 		jspHeadContentDetector.set(structuredDocument);
-		String contentType;
+		String contentType = null;
 		try {
 			contentType = jspHeadContentDetector.getContentType();
+			// if XHTML or WML, that trumps what is in the page directive
+			if (jspHeadContentDetector.isXHTML() || jspHeadContentDetector.isWML()) {
+				contentType = "text/html";
+		}
 		}
 		catch (IOException e) {
-			// should be impossible in this context
+			// impossible in this context, since working with document stream
 			throw new Error(e);
 		}
-		if (contentType == null) {
+		// null or empty, treat as "default"
+		if (contentType == null || contentType.length() == 0) {
 			contentType = "text/html"; //$NON-NLS-1$
 		}
 		// we currently only have two ... eventually should
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelhandler/EmbeddedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelhandler/EmbeddedHTML.java
index e000a05..1d17f1e 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelhandler/EmbeddedHTML.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelhandler/EmbeddedHTML.java
@@ -82,7 +82,6 @@
 			supportedMimeTypes.add("text/html"); //$NON-NLS-1$
 			supportedMimeTypes.add("text/xhtml"); //$NON-NLS-1$
 			supportedMimeTypes.add("application/xhtml+xml"); //$NON-NLS-1$
-			supportedMimeTypes.add("application/xml"); //$NON-NLS-1$
 			supportedMimeTypes.add("text/vnd.wap.wml"); //$NON-NLS-1$
 		}
 		return supportedMimeTypes;
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/contenttype/ContentTypeFamilyForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/contenttype/ContentTypeFamilyForHTML.java
new file mode 100644
index 0000000..35f17ff
--- /dev/null
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/provisional/contenttype/ContentTypeFamilyForHTML.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+
+package org.eclipse.wst.html.core.internal.provisional.contenttype;
+
+/**
+ * The value of the contenttype id field must match what is specified in
+ * plugin.xml file. Note: this value is intentially set with default protected
+ * method so it will not be inlined.
+ */
+
+public class ContentTypeFamilyForHTML {
+	/**
+	 * The value of the contenttype id field must match what is specified in
+	 * plugin.xml file. Note: this value is intentially not declared as final,
+	 * so it will not be inlined.
+	 */
+	public final static String HTML_FAMILY = getConstantString();
+
+	/**
+	 * Don't allow instantiation.
+	 */
+	private ContentTypeFamilyForHTML() {
+		super();
+	}
+
+	static String getConstantString() {
+		return "org.eclipse.wst.html.core.contentfamily.html"; //$NON-NLS-1$
+	}
+
+}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java
index d4216e7..93004a6 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelhandler/EmbeddedXML.java
@@ -53,6 +53,7 @@
 	public List getSupportedMimeTypes() {
 		if (supportedMimeTypes == null) {
 			supportedMimeTypes = new ArrayList();
+			supportedMimeTypes.add("application/xml"); //$NON-NLS-1$
 			supportedMimeTypes.add("text/xml"); //$NON-NLS-1$
 		}
 		return supportedMimeTypes;