Example #1
0
        private RelaxngData ReadDataPattern()
        {
            RelaxngData data = new RelaxngData();

            FillLocation(data);

            expect("data");
            data.Type = GetSpaceStrippedAttribute("type", String.Empty);
            if (data.Type == null)
            {
                throw new RelaxngException("Attribute type is required.");
            }
            data.DatatypeLibrary = DatatypeLibrary;

            if (MoveToFirstAttribute())
            {
                do
                {
                    if (NamespaceURI != String.Empty)
                    {
                        continue;
                    }
                    switch (LocalName)
                    {
                    case "datatypeLibrary":
                    case "type":
                        break;

                    default:
                        throw new RelaxngException("Invalid attribute.");
                    }
                } while (MoveToNextAttribute());
                MoveToElement();
            }

            if (!IsEmptyElement)
            {
                Read();
                while (Name == "param")
                {
                    data.ParamList.Add(ReadParam());
                }
                if (LocalName == "except")
                {
                    data.Except = ReadPatternExcept();
                }
                expectEnd("data");
            }
            else
            {
                Read();
            }

            return(data);
        }
Example #2
0
		private RelaxngData ReadDataPattern ()
		{
			RelaxngData data = new RelaxngData ();
			FillLocation (data);

			expect ("data");
			data.Type = GetSpaceStrippedAttribute ("type", String.Empty);
			if (data.Type == null)
				throw new RelaxngException ("Attribute type is required.");
			data.DatatypeLibrary = DatatypeLibrary;

			if (MoveToFirstAttribute ()) {
				do {
					if (NamespaceURI != String.Empty)
						continue;
					switch (LocalName) {
					case "datatypeLibrary":
					case "type":
						break;
					default:
						throw new RelaxngException ("Invalid attribute.");
					}
				} while (MoveToNextAttribute ());
				MoveToElement ();
			}

			if (!IsEmptyElement) {
				Read ();
				while (LocalName == "param")
					data.ParamList.Add (ReadParam ());
				if (LocalName == "except")
					data.Except = ReadPatternExcept ();
				expectEnd ("data");
			} else
				Read ();

			return data;
		}
Example #3
0
		public void WriteData (RelaxngData data)
		{
			WriteQName (data.Type, data.DatatypeLibrary, datansmgr);
			if (data.ParamList.Count > 0) {
				w.Write (" { ");
				foreach (RelaxngParam p in data.ParamList)
					p.WriteRnc (this);
				w.Write (" }");
			}
			if (data.Except != null)
				data.Except.WriteRnc (this);
		}
Example #4
0
		RelaxngPattern CreatePatternFromTypeName (XmlQualifiedName name)
		{
			if (name == XmlQualifiedName.Empty)
				return new RelaxngText ();
			RelaxngData data = new RelaxngData ();
			data.Type = name.Name;
			data.DatatypeLibrary = RemapDatatypeLibrary (
				name.Namespace);
			return data;
		}
		private RelaxngPattern CreateSimplePattern (QName typeName)
		{
			if (typeName == QNameString)
				return new RelaxngText ();

			RelaxngData data = new RelaxngData ();
			data.Type = typeName.Name;
			data.DatatypeLibrary =
				typeName.Namespace == NamespaceXmlSchema ?
				NamespaceXmlSchemaDatatypes :
				typeName.Namespace;
			return data;
		}