예제 #1
0
      public void Length_should_equal_original_length() {
        var attributes = new Attributes();
        attributes.AddAttribute(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
        attributes.AddAttribute(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

        var copy = new Attributes(attributes);

        Assert.Equal(copy.Length, attributes.Length);
      }
예제 #2
0
    private readonly Schema _schema; // schema to which this belongs

    /// <summary>
    ///     Construct an ElementType:
    ///     but it's better to use Schema.element() instead.
    ///     The content model, member-of, and flags vectors are specified as ints.
    /// </summary>
    /// <param name="name">
    ///     The element type name
    /// </param>
    /// <param name="model">
    ///     ORed-together bits representing the content models
    ///     allowed in the content of this element type
    /// </param>
    /// <param name="memberOf">
    ///     ORed-together bits representing the content models
    ///     to which this element type belongs
    /// </param>
    /// <param name="flags">
    ///     ORed-together bits representing the flags associated
    ///     with this element type
    /// </param>
    /// <param name="schema">
    ///     The schema with which this element type will be
    ///     associated
    /// </param>
    public ElementType(string name, int model, int memberOf, int flags, Schema schema) {
      _name = name;
      Model = model;
      MemberOf = memberOf;
      Flags = flags;
      _atts = new Attributes();
      _schema = schema;
      _namespace = GetNamespace(name, false);
      _localName = GetLocalName(name);
    }
예제 #3
0
    private bool _preclosed; // this element has been preclosed

    /// <summary>
    ///     Return an Element from a specified ElementType.
    /// </summary>
    /// <param name="type">
    ///     The element type of the newly constructed element
    /// </param>
    /// <param name="defaultAttributes">
    ///     True if default attributes are wanted
    /// </param>
    public Element(ElementType type, bool defaultAttributes) {
      _type = type;
      if (defaultAttributes) {
        _atts = new Attributes(type.Attributes);
      } else {
        _atts = new Attributes();
      }
      Next = null;
      _preclosed = false;
    }
예제 #4
0
    ////
    /// <summary>
    ///     Sets an attribute and its value into an Attributes object.
    ///     Attempts to set a namespace declaration are ignored.
    /// </summary>
    /// <param name="atts">
    ///     The AttributesImpl object
    /// </param>
    /// <param name="name">
    ///     The name (Qname) of the attribute
    /// </param>
    /// <param name="type">
    ///     The type of the attribute
    /// </param>
    /// <param name="value">
    ///     The value of the attribute
    /// </param>
    public void SetAttribute(Attributes atts, string name, string type, string value) {
      if (name.Equals("xmlns") || name.StartsWith("xmlns:")) {
        return;
      }

      string ns = GetNamespace(name, true);
      string localName = GetLocalName(name);
      int i = atts.GetIndex(name);
      if (i == -1) {
        name = string.Intern(name);
        if (type == null) {
          type = "CDATA";
        }
        if (!type.Equals("CDATA")) {
          value = Normalize(value);
        }
        atts.AddAttribute(ns, localName, name, type, value);
      } else {
        if (type == null) {
          type = atts.GetType(i);
        }
        if (!type.Equals("CDATA")) {
          value = Normalize(value);
        }
        atts.SetAttribute(i, ns, localName, name, type, value);
      }
    }