Beispiel #1
0
		private void checkInvalidAttrNameClass (RdpNameClass nc)
		{
			string xmlnsNS = "http://www.w3.org/2000/xmlns";
			RdpNameClassChoice choice = nc as RdpNameClassChoice;
			if (choice != null) {
				checkInvalidAttrNameClass (choice.LValue);
				checkInvalidAttrNameClass (choice.RValue);
				return;
			}
			RdpAnyNameExcept except = nc as RdpAnyNameExcept;
			if (except != null) {
				checkInvalidAttrNameClass (except.ExceptNameClass);
				return;
			}
			if (nc is RdpAnyName)
				return;

			RdpName n = nc as RdpName;
			if (n != null) {
				if (n.NamespaceURI == xmlnsNS)
					throw new RelaxngException (this, "cannot specify \"" + xmlnsNS + "\" for name of attribute.");
				if (n.LocalName == "xmlns" && n.NamespaceURI == "")
					throw new RelaxngException (this, "cannot specify \"xmlns\" inside empty ns context.");
			} else {
				RdpNsName nn = nc as RdpNsName;
				if (nn.NamespaceURI == "http://www.w3.org/2000/xmlns")
					throw new RelaxngException (this, "cannot specify \"" + xmlnsNS + "\" for name of attribute.");
				RdpNsNameExcept x = nc as RdpNsNameExcept;
				if (x != null)
					checkInvalidAttrNameClass (x.ExceptNameClass);
			}
		}
Beispiel #2
0
		internal override RdpPattern Compile (RelaxngGrammar grammar)
		{
			IsCompiled = true;
			RdpNameClass cnc = nc.Compile (grammar);
			this.checkInvalidAttrNameClass (cnc);

			return new RdpAttribute (cnc,
				(p != null) ?
					p.Compile (grammar) :
					RdpText.Instance);
		}
Beispiel #3
0
 internal override RdpNameClass Compile(RelaxngGrammar g)
 {
     if (except != null)
     {
         RdpNameClass exc = except.Compile(g);
         if (FindInvalidType(exc, false))
         {
             throw new RelaxngException(except, "nsName except cannot have anyName nor nsName children.");
         }
         return(new RdpNsNameExcept(ns, exc));
     }
     else
     {
         return(new RdpNsName(ns));
     }
 }
Beispiel #4
0
 internal override RdpNameClass Compile(RelaxngGrammar g)
 {
     if (except != null)
     {
         RdpNameClass exc = except.Compile(g);
         if (FindInvalidType(exc, true))
         {
             throw new RelaxngException(except, "anyName except cannot have anyName children.");
         }
         return(new RdpAnyNameExcept(exc));
     }
     else
     {
         return(RdpAnyName.Instance);
     }
 }
Beispiel #5
0
        internal RdpNameClass Compile(RelaxngGrammar g)
        {
            // Flatten names into RdpGroup. See 4.12.
            if (names.Count == 0)
            {
                return(null);
            }
            RdpNameClass p = ((RelaxngNameClass)names [0]).Compile(g);

            for (int i = 1; i < names.Count; i++)
            {
                p = new RdpNameClassChoice(
                    ((RelaxngNameClass)names [i]).Compile(g),
                    p);
            }
            return(p);
        }
Beispiel #6
0
        internal override RdpNameClass Compile(RelaxngGrammar g)
        {
            // Flatten names into RdpChoice. See 4.12.
            if (names.Count == 0)
            {
                return(null);
            }
            RdpNameClass p = ((RelaxngNameClass)names [0]).Compile(g);

            if (names.Count == 1)
            {
                return(p);
            }

            for (int i = 1; i < names.Count; i++)
            {
                p = new RdpNameClassChoice(p, ((RelaxngNameClass)names [i]).Compile(g));
            }
            return(p);
        }
Beispiel #7
0
        internal bool FindInvalidType(RdpNameClass nc, bool allowNsName)
        {
            RdpNameClassChoice choice = nc as RdpNameClassChoice;

            if (choice != null)
            {
                return(FindInvalidType(choice.LValue, allowNsName) ||
                       FindInvalidType(choice.RValue, allowNsName));
            }
            else if (nc is RdpAnyName)
            {
                return(true);
            }
            else if (nc is RdpNsName && !allowNsName)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }