Add tag for parsing

key, keyref, unique, selector, and field tags are added for parsing. But
they will use when validating xml files via xsd file. So we don't need
to generate java or cpp code.
In case of document tag, other tag is not recognized until the end of
tag.

Bug: 80453829
Test: m -j

Change-Id: I8c579debb5f21a019b4bd7bbf1440c6cbecc63c3
diff --git a/src/com/android/xsdc/XsdHandler.java b/src/com/android/xsdc/XsdHandler.java
index f13db37..d0cd5b9 100644
--- a/src/com/android/xsdc/XsdHandler.java
+++ b/src/com/android/xsdc/XsdHandler.java
@@ -51,10 +51,12 @@
     private final Stack<State> stateStack;
     private final Map<String, String> namespaces;
     private Locator locator;
+    private boolean documentationFlag;
 
     public XsdHandler() {
         stateStack = new Stack<>();
         namespaces = new HashMap<>();
+        documentationFlag = false;
     }
 
     public XmlSchema getSchema() {
@@ -105,11 +107,19 @@
         for (int i = 0; i < attributes.getLength(); ++i) {
             attributeMap.put(attributes.getLocalName(i), attributes.getValue(i));
         }
-        stateStack.push(new State(localName, attributeMap));
+        if (!documentationFlag) {
+            stateStack.push(new State(localName, attributeMap));
+        }
+        if (localName == "documentation") {
+            documentationFlag = true;
+        }
     }
 
     @Override
     public void endElement(String uri, String localName, String qName) throws SAXException {
+        if (documentationFlag && localName != "documentation") {
+            return;
+        }
         try {
             State state = stateStack.pop();
             switch (state.name) {
@@ -166,10 +176,21 @@
                     // Tags under simpleType <restriction>. They are ignored.
                     break;
                 case "annotation":
-                case "documentation":
                 case "appinfo":
                     // They function like comments, so are ignored.
                     break;
+                case "documentation":
+                    documentationFlag = false;
+                    break;
+                case "key":
+                case "keyref":
+                case "selector":
+                case "field":
+                case "unique":
+                    // These tags are not related to xml parsing.
+                    // They are using when validating xml files via xsd file.
+                    // So they are ignored.
+                    break;
                 default:
                     throw new XsdParserException(String.format("unsupported tag : %s", state.name));
             }
@@ -247,10 +268,6 @@
         String defVal = attributeMap.get("default");
         String use = attributeMap.get("use");
 
-        if (defVal != null) {
-            throw new XsdParserException("default value of an attribute is not supported.");
-        }
-
         if (use != null && use.equals("prohibited")) return null;
 
         XsdType type = null;