[gxml] Added XSD implemention as GomElement



commit a638cdd18bdc2d2ae421da389f0bee17c0c61e7c
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Jan 22 20:32:40 2017 -0600

    Added XSD implemention as GomElement

 gxml/GomSchema.vala |  190 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gxml/Makefile.am    |    1 +
 gxml/Schema.vala    |   20 +++---
 3 files changed, 202 insertions(+), 9 deletions(-)
---
diff --git a/gxml/GomSchema.vala b/gxml/GomSchema.vala
new file mode 100644
index 0000000..9d173b2
--- /dev/null
+++ b/gxml/GomSchema.vala
@@ -0,0 +1,190 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ *
+ * Copyright (C) 2016  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+using GXml;
+
+public class GXml.GomXsdSchema : GomElement, XsdSchema {
+  public XsdList elements { get; set; }
+  public XsdList simple_types { get; set; }
+  construct {
+    initialize (XsdSchema.SCHEMA_NODE_NAME);
+    set_attribute_ns ("http://www.w3.org/2000/xmlns/";,
+                      "xmlns:"+XsdSchema.SCHEMA_NAMESPACE_PREFIX,
+                      XsdSchema.SCHEMA_NAMESPACE_URI);
+  }
+}
+
+public class GXml.GomXsdSimpleType : GomElement,
+                DomElement, XsdSimpleType, XsdBaseType
+{
+  /**
+   * (#all | List of (list | union | restriction | extension))
+   */
+  public string final { get; set; }
+  public string name { get; set; }
+  public XsdAnnotation annotation { get; set; }
+  public XsdSimpleTypeDefinition definition { get; set; }
+  construct { initialize (GXml.XsdSimpleType.SCHEMA_NODE_NAME); }
+}
+public class GXml.GomXsdTypeRestriction : GomElement, XsdTypeRestriction, XsdSimpleTypeDefinition {
+  public string base { get; set; }
+  public string id { get; set; }
+  public XsdAnnotation annotation { get; set; }
+  public XsdSimpleType simple_type { get; set; }
+  /**
+   * List of {link XsdTypeRestrictionDefinition} objects
+   */
+  public XsdList definition { get; set; }
+}
+
+public class GXml.GomXsdTypeRestrictionDefinition : GomElement,
+              XsdTypeRestrictionDefinition {
+  public XsdAnnotation annotation { get; set; }
+}
+public class GXml.GomXsdTypeRestrictionMinExclusive : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionMinInclusive : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionMaxExclusive : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionMaxInclusive : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionTotalDigits : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionFractionDigits : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionLength : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionMinLength : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionMaxLength : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionEnumeration : GomXsdTypeRestrictionDefinition {
+  public string id { get; set; }
+  public string value { get; set; }
+  construct { initialize (GXml.XsdTypeRestrictionEnumeration.SCHEMA_NODE_NAME); }
+}
+public class GXml.GomXsdTypeRestrictionWhiteSpace: GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionPattern : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionAssertion : GomXsdTypeRestrictionDefinition {}
+public class GXml.GomXsdTypeRestrictionExplicitTimezone : GomXsdTypeRestrictionDefinition {}
+
+public class GXml.GomXsdComplexType : GomElement, DomElement, XsdBaseType {
+  protected XsdList _type_attributes = null;
+  protected XsdList _group_attributes = null;
+  /**
+  * attribute name = abstract
+  */
+  public bool abstract { get; set; default = false; }
+  /**
+  * (#all | List of (extension | restriction))
+  */
+  public string block { get; set; }
+  /**
+  * (#all | List of (extension | restriction))
+  */
+  public string final { get; set; }
+  public bool mixed { get; set; }
+  public string name { get; set; }
+  /**
+   * defaultAttributesApply
+   */
+  public bool default_attributes_apply { get; set; default = true; }
+  public XsdList anotations { get; set; }
+  /**
+   * A {@link XsdComplexType} or {@link XsdSimpleType}
+   */
+  public XsdBaseContent content_type { get; set; }
+  /**
+   * List of type {@link XsdAttribute} definitions
+   */
+  public XsdList type_attributes { get { return _type_attributes; } }
+  /**
+   * List of type {@link XsdGroupAttribute} definitions
+   */
+  public XsdList group_attributes { get { return _group_attributes; } }
+  construct { initialize (GXml.XsdComplexType.SCHEMA_NODE_NAME); }
+}
+
+public class GXml.GomXsdExtension : GomElement, DomElement {
+  public string base { get; set; }
+  construct { initialize (GXml.XsdExtension.SCHEMA_NODE_NAME); }
+}
+
+public class GXml.GomXsdElement : GomElement, DomElement {
+  /**
+  * attribute name = abstract
+  */
+  public bool abstract { get; set; }
+  /**
+   * (#all | List of (extension | restriction | substitution))
+  */
+  public string block { get; set; }
+  public string default { get; set; }
+  /**
+   * (#all | List of (extension | restriction))
+   */
+  public string final { get; set; }
+  public string fixed { get; set; }
+  /**
+   * (qualified | unqualified)
+   */
+  public string form { get; set; }
+  /**
+   * (nonNegativeInteger | unbounded)  : 1
+   */
+  public string maxOccurs { get; set; }
+  /**
+   * nonNegativeInteger : 1
+   */
+  public string minOccurs { get; set; }
+  public string name { get; set; }
+  public bool nillable { get; set; default = false; }
+  public string ref { get; set; }
+  /**
+   * substitutionGroup
+   */
+  public DomTokenList substitution_group { get; set; }
+  /**
+   * targetNamespace
+   */
+  public string target_namespace { get; set; }
+  /**
+   * attribute name = 'type'
+   */
+  public string object_type { get; set; }
+  public XsdAnnotation anotation { get; set; }
+  /**
+   * A {@link XsdComplexType} or {@link XsdSimpleType} list of elements
+   */
+  public XsdList type_definition { get; set; }
+  construct { initialize (GXml.XsdElement.SCHEMA_NODE_NAME); }
+}
+
+public class GXml.GomXsdList : GomArrayList, XsdList {
+  public new int length {
+    get { return (this as GomArrayList).length; }
+  }
+  public void remove (int index) {
+    element.remove_child (element.child_nodes.item (index));
+  }
+  public int index_of (DomElement element) {
+    if (element.parent_node != this.element) return -1;
+    for (int i = 0; i < this.length; i++) {
+      if (get_item (i) == element) return i;
+    }
+    return -1;
+  }
+  public DomElement? XsdList.get_item (int index) {
+    return (this as GomArrayList).get_item (index);
+  }
+}
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 11e46df..031ce0e 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -93,6 +93,7 @@ sources = \
        Parser.vala \
        XParser.vala \
        Schema.vala \
+       GomSchema.vala \
        $(NULL)
 
 
diff --git a/gxml/Schema.vala b/gxml/Schema.vala
index e17174e..3bd7f49 100644
--- a/gxml/Schema.vala
+++ b/gxml/Schema.vala
@@ -41,6 +41,7 @@ public interface GXml.XsdSimpleType: Object, DomElement, XsdBaseType {
   public abstract string id { get; set; }
   public abstract string name { get; set; }
   public abstract XsdAnnotation annotation { get; set; }
+  public abstract XsdSimpleTypeDefinition definition { get; set; }
 }
 public interface GXml.XsdSimpleTypeDefinition : Object {}
 public interface GXml.XsdTypeRestriction : Object, XsdSimpleTypeDefinition {
@@ -92,7 +93,7 @@ public interface GXml.XsdComplexType : Object, DomElement, XsdBaseType {
   * (#all | List of (extension | restriction))
   */
   public abstract string final { get; set; }
-  public abstract string id { get; set; }
+  public abstract string? id { get; set; }
   public abstract bool mixed { get; set; }
   public abstract string name { get; set; }
   /**
@@ -107,11 +108,11 @@ public interface GXml.XsdComplexType : Object, DomElement, XsdBaseType {
   /**
    * List of type {@link XsdAttribute} definitions
    */
-  public abstract XsdList attributes { get; set; }
+  public abstract XsdList type_attributes { get; }
   /**
    * List of type {@link XsdGroupAttribute} definitions
    */
-  public abstract XsdList group_attributes { get; set; }
+  public abstract XsdList group_attributes { get; }
 }
 
 public interface GXml.XsdExtension : Object, DomElement {
@@ -139,7 +140,7 @@ public interface GXml.XsdElement : Object, DomElement {
    * (qualified | unqualified)
    */
   public abstract string form { get; set; }
-  public abstract string id { get; set; }
+  public abstract string? id { get; set; }
   /**
    * (nonNegativeInteger | unbounded)  : 1
    */
@@ -188,12 +189,13 @@ public interface GXml.XsdBaseAttribute : Object {}
 public interface GXml.XsdAttribute : Object {}
 public interface GXml.XsdAttributeGroup : Object {}
 
-public interface GXml.XsdList : Object {
-  public abstract Type item_type { get; construct set; }
-  public abstract Type item_node_name { get; construct set; }
+public interface GXml.XsdList : Object, GomCollection {
+  public abstract DomElement element { get; construct set; }
+  public abstract Type items_type { get; construct set; }
+  public abstract Type items_name { get; construct set; }
   public abstract int length { get; }
-  public abstract DomElement? index (int index);
-  public abstract void add (DomElement element);
+  public abstract DomElement? get_item (int index);
+  public abstract void append (DomElement element);
   public abstract void remove (int index);
   public abstract int index_of (DomElement element);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]