[gxml/gxml-0.8] Fixed xDocument.from_string() no root element
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/gxml-0.8] Fixed xDocument.from_string() no root element
- Date: Wed, 13 Jan 2016 04:43:03 +0000 (UTC)
commit e51be5680ed44f6f637d139a0aa52791c2a9b1d9
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Jan 12 10:16:31 2016 -0600
Fixed xDocument.from_string() no root element
configure.ac | 4 ++--
gxml/libxml-Document.vala | 2 ++
test/DocumentTest.vala | 11 +++++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ac3443a..9c0fbb6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@
# Release Version
m4_define([project_major_version], [0])
m4_define([project_minor_version], [8])
-m4_define([project_micro_version], [0])
+m4_define([project_micro_version], [1])
m4_define([project_nano_version], [0])
# LT_VERSION
@@ -22,7 +22,7 @@ m4_define([project_nano_version], [0])
# If public symbols have been added since last release, increment age
# If public symbols have been removed since last release, set age to 0
m4_define([project_lt_current], [8])
-m4_define([project_lt_revision], [0])
+m4_define([project_lt_revision], [1])
m4_define([project_lt_age], [0])
# Combine numbers to various version variables (different uses)
diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala
index a160599..dfe2790 100644
--- a/gxml/libxml-Document.vala
+++ b/gxml/libxml-Document.vala
@@ -475,6 +475,8 @@ namespace GXml {
public xDocument.from_string (string xml) {
Xml.Doc *doc;
doc = Xml.Parser.parse_memory (xml, (int)xml.length);
+ if (doc == null)
+ doc = new Xml.Doc ();
this.from_libxml2 (doc);
}
/**
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index afb8391..4829fe1 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -143,6 +143,17 @@ class DocumentTest : GXmlTest {
assert (root.first_child.node_name == "Apple");
assert (root.last_child.node_name == "Orange");
});
+ Test.add_func ("/gxml/document/construct_from_string_no_root", () => {
+ string xml;
+ xDocument doc;
+ GXml.xNode root;
+
+ xml = """<?xml version="1.0"?>""";
+ doc = new xDocument.from_string (xml);
+
+ root = doc.document_element;
+ assert (root == null);
+ });
Test.add_func ("/gxml/document/save", () => {
xDocument doc;
int exit_status;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]