Nikolay Sivov : xmllite: Complete content parsing with implemented parts and stubs.

Alexandre Julliard julliard at winehq.org
Wed Jan 23 16:40:18 CST 2013


Module: wine
Branch: master
Commit: 6ab47275aadd937cb91f07732a5b56475f1301fc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6ab47275aadd937cb91f07732a5b56475f1301fc

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Jan 23 12:12:55 2013 +0400

xmllite: Complete content parsing with implemented parts and stubs.

---

 dlls/xmllite/reader.c       |   56 ++++++++++++++++++++++++++++++++++++++----
 dlls/xmllite/tests/reader.c |    6 ++++-
 2 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 647af24..d3452d6 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -69,7 +69,10 @@ static const WCHAR utf8W[] = {'U','T','F','-','8',0};
 
 static const WCHAR dblquoteW[] = {'\"',0};
 static const WCHAR quoteW[] = {'\'',0};
+static const WCHAR ltW[] = {'<',0};
 static const WCHAR gtW[] = {'>',0};
+static const WCHAR commentW[] = {'<','!','-','-',0};
+static const WCHAR piW[] = {'<','?',0};
 
 struct xml_encoding_data
 {
@@ -1264,8 +1267,6 @@ static HRESULT reader_parse_misc(xmlreader *reader)
 
     while (1)
     {
-        static const WCHAR commentW[] = {'<','!','-','-',0};
-        static const WCHAR piW[] = {'<','?',0};
         const WCHAR *cur = reader_get_cur(reader);
 
         if (is_wchar_space(*cur))
@@ -1519,7 +1520,6 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca
 /* [39] element ::= EmptyElemTag | STag content ETag */
 static HRESULT reader_parse_element(xmlreader *reader)
 {
-    static const WCHAR ltW[] = {'<',0};
     strval qname, prefix, local;
     HRESULT hr;
     int empty;
@@ -1584,18 +1584,62 @@ static HRESULT reader_parse_endtag(xmlreader *reader)
     return S_OK;
 }
 
+/* [18] CDSect ::= CDStart CData CDEnd
+   [19] CDStart ::= '<![CDATA['
+   [20] CData ::= (Char* - (Char* ']]>' Char*))
+   [21] CDEnd ::= ']]>' */
+static HRESULT reader_parse_cdata(xmlreader *reader)
+{
+    FIXME("CDATA sections are not supported\n");
+    return E_NOTIMPL;
+}
+
+/* [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
+   [67]	Reference ::= EntityRef | CharRef
+   [68]	EntityRef ::= '&' Name ';' */
+static HRESULT reader_parse_reference(xmlreader *reader)
+{
+    FIXME("References not supported\n");
+    return E_NOTIMPL;
+}
+
+/* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) */
+static HRESULT reader_parse_chardata(xmlreader *reader)
+{
+    FIXME("CharData not supported\n");
+    return E_NOTIMPL;
+}
+
 /* [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* */
 static HRESULT reader_parse_content(xmlreader *reader)
 {
+    static const WCHAR cdstartW[] = {'<','!','[','C','D','A','T','A','[',0};
     static const WCHAR etagW[] = {'<','/',0};
+    static const WCHAR ampW[] = {'&',0};
+
     reader_shrink(reader);
 
-    /* handle end tag */
+    /* handle end tag here, it indicates end of content as well */
     if (!reader_cmp(reader, etagW))
         return reader_parse_endtag(reader);
 
-    /* FIXME: handle the rest of possible content nodes */
-    return reader_parse_element(reader);
+    if (!reader_cmp(reader, commentW))
+        return reader_parse_comment(reader);
+
+    if (!reader_cmp(reader, piW))
+        return reader_parse_pi(reader);
+
+    if (!reader_cmp(reader, cdstartW))
+        return reader_parse_cdata(reader);
+
+    if (!reader_cmp(reader, ampW))
+        return reader_parse_reference(reader);
+
+    if (!reader_cmp(reader, ltW))
+        return reader_parse_element(reader);
+
+    /* what's left must be CharData */
+    return reader_parse_chardata(reader);
 }
 
 static HRESULT reader_parse_nextnode(xmlreader *reader)
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c
index babb1c9..5e6531b 100644
--- a/dlls/xmllite/tests/reader.c
+++ b/dlls/xmllite/tests/reader.c
@@ -877,7 +877,7 @@ static void test_read_pi(void)
 
 struct nodes_test {
     const char *xml;
-    XmlNodeType types[10];
+    XmlNodeType types[20];
 };
 
 static const char misc_test_xml[] =
@@ -889,6 +889,8 @@ static const char misc_test_xml[] =
     "<!-- comment4 -->"
     "<a>"
     "<b/>"
+    "<!-- comment -->"
+    "<?pi pibody ?>"
     "</a>"
 ;
 
@@ -903,6 +905,8 @@ static struct nodes_test misc_test = {
         XmlNodeType_Comment,
         XmlNodeType_Element,
         XmlNodeType_Element,
+        XmlNodeType_Comment,
+        XmlNodeType_ProcessingInstruction,
         XmlNodeType_EndElement,
         XmlNodeType_None
     }




More information about the wine-cvs mailing list