[gxml/gsoc2013: 91/150] Document.vala: some small error handling changes; return on invalid chars for create_element
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/gsoc2013: 91/150] Document.vala: some small error handling changes; return on invalid chars for create_element
- Date: Sat, 24 Aug 2013 17:36:54 +0000 (UTC)
commit 627a4527465dcc9b60ce894ed30ba517687289a0
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 27 00:01:54 2013 -0400
Document.vala: some small error handling changes; return on invalid chars for create_element
gxml/Document.vala | 15 ++++++++++-----
gxml/{DomError.vala => DomException.vala} | 0
2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 3f6529f..3f4a731 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -506,12 +506,14 @@ namespace GXml {
* URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-createElement]]
*/
public Element create_element (string tag_name) {
- check_invalid_characters (tag_name, "element");
-
// TODO: what should we be passing for ns other than old_ns? Figure it out; needed
for level 2+ support
Xml.Node *xmlelem;
Element new_elem;
+ if (!check_invalid_characters (tag_name, "element")) {
+ return null;
+ }
+
xmlelem = this.xmldoc->new_node (null, tag_name, null);
this.new_nodes.append (xmlelem);
new_elem = new Element (xmlelem, this);
@@ -643,18 +645,21 @@ namespace GXml {
*/
private void check_not_supported_html (string feature) {
if (this.doctype != null && (this.doctype.name.casefold () == "html".casefold ())) {
- GLib.warning ("NOT_SUPPORTED_ERR: HTML documents do not support '%s'".printf
(feature)); // TODO: i18n
+ GLib.warning ("NOT_SUPPORTED_ERR: HTML documents do not support '%s'",
feature); // TODO: i18n
}
}
/**
* Subject should be something like "element" or "processing instruction"
*/
- internal static void check_invalid_characters (string name, string subject) {
+ internal static bool check_invalid_characters (string name, string subject) {
/* TODO: use Xml.validate_name instead */
if (Xml.validate_name (name, 0) != 0) { // TODO: define validity
- GLib.warning ("INVALID_CHARACTER_ERR: Provided name '%s' for %s is not a
valid XML name", name, subject);
+ GLib.warning ("INVALID_CHARACTER_ERR: Provided name '%s' for '%s' is not a
valid XML name", name, subject);
+ return false;
}
+
+ return true;
}
/**
diff --git a/gxml/DomError.vala b/gxml/DomException.vala
similarity index 100%
rename from gxml/DomError.vala
rename to gxml/DomException.vala
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]