From 1b90fe29c40bcc350c337f15a6c1878091145947 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Fri, 10 May 2002 14:11:01 +0000
Subject: [PATCH] [Bug 8967] Default element behaviour is incorrect (schema
 only).

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173661 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/XMLScanner.cpp | 64 +++++++++++++++++------------
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp
index ef88fb3e4..866107139 100644
--- a/src/xercesc/internal/XMLScanner.cpp
+++ b/src/xercesc/internal/XMLScanner.cpp
@@ -1797,17 +1797,6 @@ void XMLScanner::scanEndTag(bool& gotData)
         );
     }
 
-    // If we have a doc handler, tell it about the end tag
-    if (fDocHandler)
-    {
-        fDocHandler->endElement
-        (
-            *topElem->fThisElement
-            , uriId
-            , isRoot
-        );
-    }
-
     //
     //  If validation is enabled, then lets pass him the list of children and
     //  this element and let him validate it.
@@ -1918,6 +1907,17 @@ void XMLScanner::scanEndTag(bool& gotData)
         }
     }
 
+    // If we have a doc handler, tell it about the end tag
+    if (fDocHandler)
+    {
+        fDocHandler->endElement
+        (
+            *topElem->fThisElement
+            , uriId
+            , isRoot
+        );
+    }
+
     // If this was the root, then done with content
     gotData = !isRoot;
 
@@ -3401,6 +3401,22 @@ bool XMLScanner::scanStartTagNS(bool& gotData)
         }
     }
 
+    // Since the element may have default values, call start tag now regardless if it is empty or not
+    // If we have a document handler, then tell it about this start tag
+    if (fDocHandler)
+    {
+        fDocHandler->startElement
+        (
+            *elemDecl
+            , uriId
+            , fPrefixBuf.getRawBuffer()
+            , *fAttrList
+            , attCount
+            , false
+            , isRoot
+        );
+    }
+
     //
     //  If empty, validate content right now if we are validating and then
     //  pop the element stack top. Else, we have to update the current stack
@@ -3486,6 +3502,17 @@ bool XMLScanner::scanStartTagNS(bool& gotData)
             }
         }
 
+        // If we have a doc handler, tell it about the end tag
+        if (fDocHandler)
+        {
+            fDocHandler->endElement
+            (
+                *elemDecl
+                , uriId
+                , isRoot
+            );
+        }
+
         // If the elem stack is empty, then it was an empty root
         if (isRoot)
             gotData = false;
@@ -3516,21 +3543,6 @@ bool XMLScanner::scanStartTagNS(bool& gotData)
         }
     }
 
-    // If we have a document handler, then tell it about this start tag
-    if (fDocHandler)
-    {
-        fDocHandler->startElement
-        (
-            *elemDecl
-            , uriId
-            , fPrefixBuf.getRawBuffer()
-            , *fAttrList
-            , attCount
-            , isEmpty
-            , isRoot
-        );
-    }
-
     return true;
 }
 
-- 
GitLab