Esempio n. 1
0
        private RelaxngValue ReadValuePattern()
        {
            RelaxngValue v = new RelaxngValue();

            FillLocation(v);
            expect("value");

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

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

            if (MoveToAttribute("type"))
            {
                v.Type            = Value.Trim();
                v.DatatypeLibrary = DatatypeLibrary;
            }
            else
            {
                v.Type            = "token";
                v.DatatypeLibrary = "";
            }
//			v.Namespace = GetSpaceStrippedAttribute ("ns", String.Empty);
            MoveToElement();
            if (IsEmptyElement)
            {
                v.Value = String.Empty;
                Read();
            }
            else
            {
                v.Value = ReadString();
                expectEnd("value");
            }

            return(v);
        }
Esempio n. 2
0
		private RelaxngValue ReadValuePattern ()
		{
			RelaxngValue v = new RelaxngValue ();
			FillLocation (v);
			expect ("value");

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

			if (MoveToAttribute ("type")) {
				v.Type = Value.Trim ();
				v.DatatypeLibrary = DatatypeLibrary;
			} else {
				v.Type = "token";
				v.DatatypeLibrary = "";
			}
//			v.Namespace = GetSpaceStrippedAttribute ("ns", String.Empty);
			MoveToElement ();
			if (IsEmptyElement) {
				v.Value = String.Empty;
				Read ();
			} else {
				v.Value = ReadString ();
				expectEnd ("value");
			}

			return v;
		}
Esempio n. 3
0
		RelaxngPattern CreatePatternFromType (XmlSchemaType type)
		{
			XmlSchemaSimpleType st = type as XmlSchemaSimpleType;
			if (st == null)
				throw new NotSupportedException ("Complex types are not supported as an attribute type.");
			XmlSchemaSimpleTypeRestriction r =
				st.Content as XmlSchemaSimpleTypeRestriction;
			if (r == null)
				throw new NotSupportedException ("Only simple type restriction is supported as an attribute type.");

			RelaxngChoice c = new RelaxngChoice ();
			foreach (XmlSchemaFacet f in r.Facets) {
				XmlSchemaEnumerationFacet en =
					f as XmlSchemaEnumerationFacet;
				if (en == null)
					throw new NotSupportedException ("Only enumeration facet is supported.");
				RelaxngValue v = new RelaxngValue ();
				v.Type = r.BaseTypeName.Name;
				v.DatatypeLibrary = RemapDatatypeLibrary (
					r.BaseTypeName.Namespace);
				v.Value = en.Value;
				c.Patterns.Add (v);
			}
			return c;
		}
Esempio n. 4
0
		public void WriteValue (RelaxngValue v)
		{
			WriteQName (v.Type, v.DatatypeLibrary, datansmgr);
			w.Write (' ');
			WriteLiteral (v.Value);
		}