internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip)
        {
            AttributeMatchState state;
            SchemaAttDef        def = this.GetAttributeXsd(ed, qname, null, out state);

            switch (state)
            {
            case AttributeMatchState.AttributeFound:
            case AttributeMatchState.AnyIdAttributeFound:
            case AttributeMatchState.UndeclaredElementAndAttribute:
            case AttributeMatchState.AnyAttributeLax:
                return(def);

            case AttributeMatchState.UndeclaredAttribute:
                throw new XmlSchemaException("Sch_UndeclaredAttribute", qname.ToString());

            case AttributeMatchState.AnyAttributeSkip:
                skip = true;
                return(def);

            case AttributeMatchState.ProhibitedAnyAttribute:
            case AttributeMatchState.ProhibitedAttribute:
                throw new XmlSchemaException("Sch_ProhibitedAttribute", qname.ToString());
            }
            return(def);
        }
        internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip)
        {
            AttributeMatchState attributeMatchState;

            SchemaAttDef attDef = GetAttributeXsd(ed, qname, null, out attributeMatchState);

            switch (attributeMatchState)
            {
            case AttributeMatchState.UndeclaredAttribute:
                throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());

            case AttributeMatchState.ProhibitedAnyAttribute:
            case AttributeMatchState.ProhibitedAttribute:
                throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());

            case AttributeMatchState.AttributeFound:
            case AttributeMatchState.AnyIdAttributeFound:
            case AttributeMatchState.AnyAttributeLax:
            case AttributeMatchState.UndeclaredElementAndAttribute:
                break;

            case AttributeMatchState.AnyAttributeSkip:
                skip = true;
                break;

            default:
                Debug.Assert(false);
                break;
            }
            return(attDef);
        }
Пример #3
0
        private void DefineModuleType(
            XmlQualifiedName name,
            string displayName,
            string description,
            string imageName,
            ElementType.Pin[] inputs,
            ElementType.Pin[] outputs,
            SchemaLoader loader)
        {
            // turn input pins into attributes on the type
            var attributes = new List <AttributeInfo>();

            foreach (ElementType.Pin pin in inputs)
            {
                attributes.Add(
                    new AttributeInfo(
                        pin.Name,
                        (pin.TypeName == BooleanPinTypeName) ? BooleanPinType : FloatPinType));
            }

            // create the type
            var type = new DomNodeType(
                name.ToString(),
                Schema.moduleType.Type,
                attributes,
                EmptyArray <ChildInfo> .Instance,
                EmptyArray <ExtensionInfo> .Instance);

            // add it to the schema-defined types
            loader.AddNodeType(name.ToString(), type);

            // create an element type and add it to the type metadata
            // For now, let all circuit elements be used as 'connectors' which means
            //  that their pins will be used to create the pins on a master instance.
            bool isConnector = true; //(inputs.Length + outputs.Length) == 1;

            type.SetTag <ICircuitElementType>(
                new ElementType(
                    displayName,
                    isConnector,
                    new Size(),
                    ResourceUtil.GetImage32(imageName),
                    inputs,
                    outputs));

            // add the type to the palette
            m_paletteService.AddItem(
                new NodeTypePaletteItem(
                    type,
                    displayName,
                    description,
                    imageName),
                PaletteCategory,
                this);
        }
Пример #4
0
        /// <summary>
        /// Gets the root element metadata for the reader's current XML node</summary>
        /// <param name="reader">XML reader</param>
        /// <param name="rootUri">URI of XML data</param>
        /// <returns>Root element metadata for the reader's current XML node</returns>
        protected override ChildInfo CreateRootElement(XmlReader reader, Uri rootUri)
        {
            string fileNameForm = reader.GetAttribute("filenameform");

            if (fileNameForm != null)
            {
                m_relativeFilePaths = (fileNameForm == "atgrootrelative");
            }

            // ignore the ATGI version in the document, and use the loaded ATGI schema instead
            AtgiSchemaTypeLoader atgiSchemaTypeLoader = TypeLoader as AtgiSchemaTypeLoader;

            if (atgiSchemaTypeLoader != null)
            {
                XmlQualifiedName rootElementName =
                    new XmlQualifiedName(reader.LocalName, atgiSchemaTypeLoader.Namespace);
                ChildInfo rootElement = TypeLoader.GetRootElement(rootElementName.ToString());
                // ID passed to TypeLoader.GetRootElement must be same format as in XmlSchemaTypeLoader.Load(XmlSchemaSet)
                // In XmlSchemaTypeLoader.cs look for "string name = element.QualifiedName.ToString();"
                return(rootElement);
            }
            else
            {
                return(base.CreateRootElement(reader, rootUri));
            }
        }
Пример #5
0
 protected void WriteAttribute(string localName, string ns, XmlQualifiedName value)
 {
     if (!value.IsEmpty)
     {
         this.WriteAttribute(localName, ns, value.ToString());
     }
 }
Пример #6
0
        /// <summary>
        ///     Creates a new instance of the wanted tag.
        /// </summary>
        /// <param name="qname">Qualified Namespace</param>
        /// <returns>A new instance of the requested tag</returns>
        public static T GetTag <T>(XmlQualifiedName qname) where T : Tag
        {
            T    tag = null;
            Type t;

            Log.Debug("Finding tag {TagName}...", qname);

            if (RegisteredItems.TryGetValue(qname.ToString(), out t))
            {
                var ctor = t.GetConstructor(new Type[] {});
                if (ctor == null)
                {
                    ctor = t.GetConstructor(new[] { typeof(XmlQualifiedName) });
                    if (ctor != null)
                    {
                        tag = (T)ctor.Invoke(new object[] { qname });
                    }
                }
                else
                {
                    tag = (T)ctor.Invoke(new object[] {});
                }
            }
            else
            {
                ProtocolState.Events.Error(null, ErrorType.UnregisteredItem, ErrorSeverity.Information, "Tag {0} not found in registry. Please load appropriate library.", qname);
                return(null);
            }

            return(tag);
        }
        internal override Exception CheckValueFacets(XmlQualifiedName value, SimpleTypeValidator type)
        {
            RestrictionFacets facets = type.RestrictionFacets;

            if (facets == null || !facets.HasValueFacets)
            {
                return(null);
            }


            if (facets == null)
            {
                return(null);
            }
            RestrictionFlags  flags    = facets.Flags;
            XmlSchemaDatatype datatype = type.DataType;


            if ((flags & RestrictionFlags.Enumeration) != 0)
            {
                ArrayList enums = facets.Enumeration;


                if (!MatchEnumeration(value, enums, datatype))
                {
                    return(new LinqToXsdFacetException(RestrictionFlags.Enumeration,
                                                       facets.Enumeration,
                                                       value));
                }
            }

            string strValue = value.ToString();
            int    length   = strValue.Length;

            if ((flags & RestrictionFlags.Length) != 0)
            {
                if (length != facets.Length)
                {
                    return(new LinqToXsdFacetException(RestrictionFlags.Length, facets.Length, value));
                }
            }

            if ((flags & RestrictionFlags.MaxLength) != 0)
            {
                if (length > facets.MaxLength)
                {
                    return(new LinqToXsdFacetException(RestrictionFlags.MaxLength, facets.MaxLength, value));
                }
            }

            if ((flags & RestrictionFlags.MinLength) != 0)
            {
                if (length < facets.MinLength)
                {
                    return(new LinqToXsdFacetException(RestrictionFlags.MinLength, facets.MinLength, value));
                }
            }

            return(null);
        }
        public string ToString([CanBeNull] string prefix)
        {
            var result = XmlQualifiedName.ToString(this.LocalName,
                                                   prefix);

            return(result);
        }
Пример #9
0
        public void ExportBrowseNameTest()
        {
            UANodeSet _tm = TestData.CreateNodeSetModel();
            Mock <IAddressSpaceBuildContext> _asMock = new Mock <IAddressSpaceBuildContext>();

            _asMock.Setup(x => x.GetNamespace(0)).Returns <ushort>(x => "tempuri.org");
            UANode _nodeFactory = new UAVariable()
            {
                NodeId       = "ns=1;i=47",
                BrowseName   = "EURange",
                ParentNodeId = "ns=1;i=43",
                DataType     = "i=884",
                DisplayName  = new XML.LocalizedText[] { new XML.LocalizedText()
                                                         {
                                                             Value = "EURange"
                                                         } }
            };
            UANodeContext _node = new UANodeContext(NodeId.Parse("ns=1;i=47"), _asMock.Object);

            _node.Update(_nodeFactory, x => Assert.Fail());
            XmlQualifiedName _resolvedName = _node.ExportNodeBrowseName();

            _asMock.Verify(x => x.GetNamespace(0), Times.Once);
            Assert.IsNotNull(_resolvedName);
            Assert.AreEqual <string>("tempuri.org:EURange", _resolvedName.ToString());
        }
Пример #10
0
        internal override Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype)
        {
            RestrictionFacets restriction = datatype.Restriction;
            RestrictionFlags  flags       = (restriction != null) ? restriction.Flags : ((RestrictionFlags)0);

            if (flags != 0)
            {
                int length = value.ToString().Length;
                if (((flags & RestrictionFlags.Length) != 0) && (restriction.Length != length))
                {
                    return(new XmlSchemaException("Sch_LengthConstraintFailed", string.Empty));
                }
                if (((flags & RestrictionFlags.MinLength) != 0) && (length < restriction.MinLength))
                {
                    return(new XmlSchemaException("Sch_MinLengthConstraintFailed", string.Empty));
                }
                if (((flags & RestrictionFlags.MaxLength) != 0) && (restriction.MaxLength < length))
                {
                    return(new XmlSchemaException("Sch_MaxLengthConstraintFailed", string.Empty));
                }
                if (((flags & RestrictionFlags.Enumeration) != 0) && !this.MatchEnumeration(value, restriction.Enumeration))
                {
                    return(new XmlSchemaException("Sch_EnumerationConstraintFailed", string.Empty));
                }
            }
            return(null);
        }
        internal XmlSchemaObject AddItem(XmlSchemaObject item, XmlQualifiedName qname, XmlSchemas schemas)
        {
            if (item == null)
            {
                return(null);
            }
            if ((qname == null) || qname.IsEmpty)
            {
                return(null);
            }
            string    str  = item.GetType().Name + ":" + qname.ToString();
            ArrayList list = (ArrayList)this.ObjectCache[str];

            if (list == null)
            {
                list = new ArrayList();
                this.ObjectCache[str] = list;
            }
            for (int i = 0; i < list.Count; i++)
            {
                XmlSchemaObject obj2 = (XmlSchemaObject)list[i];
                if (obj2 == item)
                {
                    return(obj2);
                }
                if (this.Match(obj2, item, true))
                {
                    return(obj2);
                }
                this.Warnings.Add(Res.GetString("XmlMismatchSchemaObjects", new object[] { item.GetType().Name, qname.Name, qname.Namespace }));
                this.Warnings.Add("DEBUG:Cached item key:\r\n" + ((string)this.looks[obj2]) + "\r\nnew item key:\r\n" + ((string)this.looks[item]));
            }
            list.Add(item);
            return(item);
        }
Пример #12
0
        void Write12_XmlSchemaSimpleTypeUnion(XmlSchemaSimpleTypeUnion o)
        {
            if ((object)o == null)
            {
                return;
            }
            WriteStartElement("union");

            WriteAttribute(@"id", @"", ((System.String)o.@Id));
            WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);

            if (o.MemberTypes != null)
            {
                ArrayList list = new ArrayList();
                for (int i = 0; i < o.MemberTypes.Length; i++)
                {
                    list.Add(o.MemberTypes[i]);
                }
                list.Sort(new QNameComparer());

                w.Append(",");
                w.Append("memberTypes=");

                for (int i = 0; i < list.Count; i++)
                {
                    XmlQualifiedName q = (XmlQualifiedName)list[i];
                    w.Append(q.ToString());
                    w.Append(",");
                }
            }
            Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
            WriteSortedItems(o.@BaseTypes);
            WriteEndElement();
        }
Пример #13
0
        internal void AddDecimalFormat(XmlQualifiedName name, DecimalFormat formatinfo)
        {
            DecimalFormat exist = (DecimalFormat)this.decimalFormatTable[name];

            if (exist != null)
            {
                NumberFormatInfo info    = exist.info;
                NumberFormatInfo newinfo = formatinfo.info;
                if (info.NumberDecimalSeparator != newinfo.NumberDecimalSeparator ||
                    info.NumberGroupSeparator != newinfo.NumberGroupSeparator ||
                    info.PositiveInfinitySymbol != newinfo.PositiveInfinitySymbol ||
                    info.NegativeSign != newinfo.NegativeSign ||
                    info.NaNSymbol != newinfo.NaNSymbol ||
                    info.PercentSymbol != newinfo.PercentSymbol ||
                    info.PerMilleSymbol != newinfo.PerMilleSymbol ||
                    exist.zeroDigit != formatinfo.zeroDigit ||
                    exist.digit != formatinfo.digit ||
                    exist.patternSeparator != formatinfo.patternSeparator
                    )
                {
                    throw new XsltException(Res.Xslt_DupDecimalFormat, name.ToString());
                }
            }
            this.decimalFormatTable[name] = formatinfo;
        }
Пример #14
0
        /// <summary>
        /// Creates a new instance of the wanted tag.
        /// </summary>
        /// <param name="qname">Qualified Namespace</param>
        /// <param name="doc">XmlDocument to create tag with</param>
        /// <returns>A new instance of the requested tag</returns>
        public static T GetTag <T>(XmlQualifiedName qname) where T : Tag
        {
            T    tag = null;
            Type t;

            Logger.DebugFormat(typeof(TagRegistry), "Finding tag: {0}", qname);

            if (RegisteredItems.TryGetValue(qname.ToString(), out t))
            {
                var ctor = t.GetConstructor(new Type[] {});
                if (ctor == null)
                {
                    ctor = t.GetConstructor(new[] { typeof(XmlQualifiedName) });
                    if (ctor != null)
                    {
                        tag = (T)ctor.Invoke(new object[] { qname });
                    }
                }
                else
                {
                    tag = (T)ctor.Invoke(new object[] {});
                }
            }
            else
            {
                Errors.SendError(typeof(TagRegistry), ErrorType.UnregisteredItem,
                                 "Tag " + qname + " not found in registry.  Please load appropriate library.");
                return(null);
            }

            return(tag);
        }
        public static string ReduceName([NotNull] this XElement element,
                                        [NotNull] XName name)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            string result;

            var prefix = element.EnsurePrefixRegistrationOfNamespace(name.Namespace);

            if (prefix == null)
            {
                result = name.LocalName;
            }
            else
            {
                result = XmlQualifiedName.ToString(name.LocalName,
                                                   prefix);
            }

            return(result);
        }
Пример #16
0
 private void WriteAttribute(string localName, string ns, XmlQualifiedName value)
 {
     if (value.IsEmpty)
     {
         return;
     }
     WriteAttribute(localName, ns, value.ToString());
 }
Пример #17
0
 public ExprVariable(XmlQualifiedName name, IStaticXsltContext ctx)
 {
     if (ctx != null)
     {
         name = ctx.LookupQName(name.ToString());
         this.resolvedName = true;
     }
     this._name = name;
 }
Пример #18
0
 public NodeNameTest(Axes axis, XmlQualifiedName name, IStaticXsltContext ctx) : base(axis)
 {
     if (ctx != null)
     {
         name = ctx.LookupQName(name.ToString());
         this.resolvedName = true;
     }
     this._name = name;
 }
        // --------------------------- XsltContext -------------------
        //                Resolving variables and functions

        public override IXsltContextVariable ResolveVariable(string prefix, string name) {
            string namespaceURI = this.LookupNamespace(prefix);
            XmlQualifiedName qname = new XmlQualifiedName(name, namespaceURI);
            IXsltContextVariable variable = this.manager.VariableScope.ResolveVariable(qname);
            if (variable == null) {
                throw XsltException.Create(Res.Xslt_InvalidVariable, qname.ToString());
            }
            return variable;
        }
Пример #20
0
 /// <summary>
 /// Add a type to the packet factory.
 /// </summary>
 /// <param name="qname"></param>
 /// <param name="ci"></param>
 public void AddType(XmlQualifiedName qname, ConstructorInfo ci)
 {
     Debug.Assert(ci != null);
     if (m_types.Contains(qname))
     {
         Debug.WriteLine("Warning: overriding existing packet factory: " + qname.ToString());
     }
     m_types[qname] = ci;
 }
Пример #21
0
        internal AttributeSetAction GetAttributeSet(XmlQualifiedName name)
        {
            AttributeSetAction?action = (AttributeSetAction?)_attributeSetTable[name];

            if (action == null)
            {
                throw XsltException.Create(SR.Xslt_NoAttributeSet, name.ToString());
            }
            return(action);
        }
Пример #22
0
        internal AttributeSetAction GetAttributeSet(XmlQualifiedName name)
        {
            AttributeSetAction action = (AttributeSetAction)this.attributeSetTable[name];

            if (action == null)
            {
                throw new XsltException(Res.Xslt_NoAttributeSet, name.ToString());
            }
            return(action);
        }
        ServiceDescription GetServiceDescription(XmlQualifiedName name)
        {
            ServiceDescription serviceDescription = this[name.Namespace];

            if (serviceDescription == null)
            {
                throw new ArgumentException(Res.GetString(Res.WebDescriptionMissing, name.ToString(), name.Namespace), "name");
            }
            return(serviceDescription);
        }
Пример #24
0
        private ServiceDescription GetServiceDescription(XmlQualifiedName name)
        {
            ServiceDescription serviceDescription = this[name.Namespace];

            if (serviceDescription == null)
            {
                throw new ArgumentException(SR.Format(SR.WebDescriptionMissing, name.ToString(), name.Namespace), nameof(name));
            }

            return(serviceDescription);
        }
Пример #25
0
 public ReferenceLink VarIndexByName(XmlQualifiedName name)
 {
     for (int k = _slots.Count - 1; k >= 0; k--)
     {
         if (_slots[k].name.Equals(name))
         {
             return(_slots[k].id);
         }
     }
     throw new XPath2Exception("XPST0008", Resources.XPST0008, name.ToString());
 }
        internal override Exception CheckValueFacets(XmlQualifiedName value, SimpleTypeValidator type)
        {
            Exception linqToXsdFacetException;

            Xml.Schema.Linq.RestrictionFacets facets = type.RestrictionFacets;
            if (!(facets == null ? false : facets.HasValueFacets))
            {
                linqToXsdFacetException = null;
            }
            else if (facets != null)
            {
                Xml.Schema.Linq.RestrictionFlags flags = facets.Flags;
                XmlSchemaDatatype datatype             = type.DataType;
                if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Enumeration) != 0)
                {
                    if (!this.MatchEnumeration(value, facets.Enumeration, datatype))
                    {
                        linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Enumeration, facets.Enumeration, value);
                        return(linqToXsdFacetException);
                    }
                }
                int length = value.ToString().Length;
                if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.Length) != 0)
                {
                    if (length != facets.Length)
                    {
                        linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.Length, (object)facets.Length, value);
                        return(linqToXsdFacetException);
                    }
                }
                if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MaxLength) != 0)
                {
                    if (length > facets.MaxLength)
                    {
                        linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MaxLength, (object)facets.MaxLength, value);
                        return(linqToXsdFacetException);
                    }
                }
                if ((int)(flags & Xml.Schema.Linq.RestrictionFlags.MinLength) != 0)
                {
                    if (length < facets.MinLength)
                    {
                        linqToXsdFacetException = new LinqToXsdFacetException(Xml.Schema.Linq.RestrictionFlags.MinLength, (object)facets.MinLength, value);
                        return(linqToXsdFacetException);
                    }
                }
                linqToXsdFacetException = null;
            }
            else
            {
                linqToXsdFacetException = null;
            }
            return(linqToXsdFacetException);
        }
Пример #27
0
        public override void Validate()
        {
            if (schemaInfo.SchemaType == SchemaType.DTD)
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    ValidateElement();
                    if (reader.IsEmptyElement)
                    {
                        goto case XmlNodeType.EndElement;
                    }
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    if (MeetsStandAloneConstraint())
                    {
                        ValidateWhitespace();
                    }
                    break;

                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.Comment:
                    ValidatePIComment();
                    break;

                case XmlNodeType.Text:              // text inside a node
                case XmlNodeType.CDATA:             // <![CDATA[...]]>
                    ValidateText();
                    break;

                case XmlNodeType.EntityReference:
                    if (!GenEntity(new XmlQualifiedName(reader.LocalName, reader.Prefix)))
                    {
                        ValidateText();
                    }
                    break;

                case XmlNodeType.EndElement:
                    ValidateEndElement();
                    break;
                }
            }
            else
            {
                if (reader.Depth == 0 &&
                    reader.NodeType == XmlNodeType.Element)
                {
                    SendValidationEvent(SR.Xml_NoDTDPresent, _name.ToString(), XmlSeverityType.Warning);
                }
            }
        }
        internal SchemaAttDef GetAttributeXdr(SchemaElementDecl ed, XmlQualifiedName qname)
        {
            SchemaAttDef attdef = null;

            if (ed != null)
            {
                attdef = ed.GetAttDef(qname);;
                if (attdef == null)
                {
                    if (!ed.ContentValidator.IsOpen || qname.Namespace.Length == 0)
                    {
                        throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                    }
                    if (!attributeDecls.TryGetValue(qname, out attdef) && targetNamespaces.ContainsKey(qname.Namespace))
                    {
                        throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                    }
                }
            }
            return(attdef);
        }
Пример #29
0
        /// <summary>
        /// Adds a reference to the AddressSpace.
        /// </summary>
        /// <param name="sourceIndex">Index of the source node that must be registered before this method is called.</param>
        /// <param name="referenceTypeName">Name of the reference type.</param>
        /// <param name="inverse">if set to <c>true</c> it is inverse reference.</param>
        /// <param name="targetName">Name of the target element this reference points to.</param>
        public void AddReference(int sourceIndex, XmlQualifiedName referenceTypeName, bool inverse, XmlQualifiedName targetName)
        {
            //targetName can be null in case of HasTypeDefinition of basic types.
            this.Assert((referenceTypeName != null && !referenceTypeName.IsEmpty), sourceIndex, "The reference type name of the reference cannot be null or empty");
            if (targetName.IsNullOrEmpty() || referenceTypeName.IsNullOrEmpty())
            {
                return;
            }
            int targetIndex = TryGetAndAddIfNeeded(targetName.ToString());

            this.AddReference(sourceIndex, referenceTypeName, inverse, targetIndex);
        }
Пример #30
0
        // --------------------------- XsltContext -------------------
        //                Resolving variables and functions

        public override IXsltContextVariable ResolveVariable(string prefix, string name)
        {
            string               namespaceURI = this.LookupNamespace(prefix);
            XmlQualifiedName     qname        = new XmlQualifiedName(name, namespaceURI);
            IXsltContextVariable variable     = this.manager.VariableScope.ResolveVariable(qname);

            if (variable == null)
            {
                throw XsltException.Create(Res.Xslt_InvalidVariable, qname.ToString());
            }
            return(variable);
        }
Пример #31
0
 internal void CheckDuplicateParams(XmlQualifiedName name)
 {
     if (this.containedActions != null)
     {
         foreach (WithParamAction param in this.containedActions)
         {
             if (param.Name == name)
             {
                 throw new XsltException(Res.Xslt_DuplicateParametr, name.ToString());
             }
         }
     }
 }
Пример #32
0
        public SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip) {
            AttributeMatchState attributeMatchState;

            SchemaAttDef attDef = GetAttributeXsd(ed, qname, null, out attributeMatchState);
            switch(attributeMatchState) {
                case AttributeMatchState.UndeclaredAttribute:
                    throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());

                case AttributeMatchState.ProhibitedAnyAttribute:
                case AttributeMatchState.ProhibitedAttribute:
                    throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());

                case AttributeMatchState.AttributeFound:
                case AttributeMatchState.AnyAttributeLax:
                case AttributeMatchState.UndeclaredElementAndAttribute:
                    break;

                case AttributeMatchState.AnyAttributeSkip:
                    skip = true;
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }
            return attDef;
        }
Пример #33
0
        private static string QNameToString(XmlQualifiedName qname, IXmlNamespaceResolver nsResolver)
        {
            string prefix;

            if (nsResolver == null)
                return string.Concat("{", qname.Namespace, "}", qname.Name);

            prefix = nsResolver.LookupPrefix(qname.Namespace);
            if (prefix == null)
                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoPrefix, qname.ToString(), qname.Namespace));

            return (prefix.Length != 0) ? string.Concat(prefix, ":", qname.Name) : qname.Name;
        }
Пример #34
0
 internal override Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype) {
     RestrictionFacets restriction = datatype.Restriction;
     RestrictionFlags flags = restriction != null ? restriction.Flags : 0;
     if (flags != 0) { //If there are facets defined
         string strValue = value.ToString();
         int length = strValue.Length;
         if ((flags & RestrictionFlags.Length) != 0) {
             if (restriction.Length != length) {
                 return new XmlSchemaException(Res.Sch_LengthConstraintFailed, string.Empty);
             }
         }
         if ((flags & RestrictionFlags.MinLength) != 0) {
             if (length < restriction.MinLength) {
                 return new XmlSchemaException(Res.Sch_MinLengthConstraintFailed, string.Empty);
             }
         }
         if ((flags & RestrictionFlags.MaxLength) != 0) {
             if (restriction.MaxLength < length) {
                 return new XmlSchemaException(Res.Sch_MaxLengthConstraintFailed, string.Empty);
             }
         }
         if ((flags & RestrictionFlags.Enumeration) != 0) {
             if (!MatchEnumeration(value, restriction.Enumeration)) {
                 return new XmlSchemaException(Res.Sch_EnumerationConstraintFailed, string.Empty);
             }
         }
     }
     return null;
 }
Пример #35
0
 private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil)
 {
     if (elementDecl == null)
     {
         elementDecl = schemaInfo.GetElementDecl(elementName);
     }
     if (elementDecl != null)
     {
         if (xsiType.IsEmpty)
         {
             if (elementDecl.IsAbstract)
             {
                 SendValidationEvent(SR.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
                 elementDecl = null;
             }
         }
         else if (xsiNil != null && xsiNil.Equals("true"))
         {
             SendValidationEvent(SR.Sch_XsiNilAndType);
         }
         else
         {
             SchemaElementDecl elementDeclXsi;
             if (!schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out elementDeclXsi) && xsiType.Namespace == _nsXs)
             {
                 XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, _nsXs));
                 if (simpleType != null)
                 {
                     elementDeclXsi = simpleType.ElementDecl;
                 }
             }
             if (elementDeclXsi == null)
             {
                 SendValidationEvent(SR.Sch_XsiTypeNotFound, xsiType.ToString());
                 elementDecl = null;
             }
             else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block))
             {
                 SendValidationEvent(SR.Sch_XsiTypeBlockedEx, new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(context.LocalName, context.Namespace) });
                 elementDecl = null;
             }
             else
             {
                 elementDecl = elementDeclXsi;
             }
         }
         if (elementDecl != null && elementDecl.IsNillable)
         {
             if (xsiNil != null)
             {
                 context.IsNill = XmlConvert.ToBoolean(xsiNil);
                 if (context.IsNill && elementDecl.DefaultValueTyped != null)
                 {
                     SendValidationEvent(SR.Sch_XsiNilAndFixed);
                 }
             }
         }
         else if (xsiNil != null)
         {
             SendValidationEvent(SR.Sch_InvalidXsiNill);
         }
     }
     return elementDecl;
 }
Пример #36
0
 XmlSchemaSimpleType FindDataType(XmlQualifiedName name) {
     TypeDesc typeDesc = scope.GetTypeDesc(name);
     if (typeDesc != null)
         return typeDesc.DataType;
     XmlSchemaSimpleType dataType = (XmlSchemaSimpleType)schemas.Find(name, typeof(XmlSchemaSimpleType));
     if (dataType != null)
         return dataType;
     if (name.Namespace == XmlSchema.Namespace)
         return scope.GetTypeDesc(typeof(string)).DataType;
     else {
         if (name.Name == Soap.Array && name.Namespace == Soap.Encoding) {
             throw new InvalidOperationException(Res.GetString(Res.XmlInvalidEncoding, name.ToString()));
         }
         else {
             throw new InvalidOperationException(Res.GetString(Res.XmlMissingDataType, name.ToString()));
         }
     }
 }
Пример #37
0
 public SchemaAttDef GetAttributeXdr(SchemaElementDecl ed, XmlQualifiedName qname) {
     SchemaAttDef attdef = null;
     if (ed != null) {
         attdef = ed.GetAttDef(qname);;
         if (attdef == null) {
             if (!ed.ContentValidator.IsOpen || qname.Namespace.Length == 0) {
                 throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
             }
             attdef = (SchemaAttDef)attributeDecls[qname];
             if (attdef == null && targetNamespaces.Contains(qname.Namespace)) {
                 throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
             }
         }
     }
     return attdef;
 }
Пример #38
0
 internal override bool ProcessElement(string prefix, string name, string ns) {
     XmlQualifiedName qname = new XmlQualifiedName(name, ns);
     if (GetNextState(qname)) {
         Push();
         Debug.Assert(this.currentEntry.InitFunc != null);
         xso = null;
         this.currentEntry.InitFunc(this, null);
         Debug.Assert(xso != null);
         RecordPosition();
     }
     else {
         if (!IsSkipableElement(qname)) {
             SendValidationEvent(Res.Sch_UnsupportedElement, qname.ToString());
         }
         return false;
     }
     return true;
 }
Пример #39
0
 public static string DecodeQName(XmlQualifiedName value)
 {
     return value.ToString();
 }
Пример #40
0
 protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
     if (qname.Name.Length == 0) {
         return;
     }
     XmlSchemaObject existingObject = (XmlSchemaObject)table[qname];
     
     if (existingObject != null) {
         if (existingObject == item) { 
             return;
         }
         string code = Res.Sch_DupGlobalElement; 
         if (item is XmlSchemaAttributeGroup) {
             string ns = nameTable.Add(qname.Namespace);
             if (Ref.Equal(ns, NsXml)) { //Check for xml namespace
                 XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
                 XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname];
                 if ((object)existingObject == (object)builtInAttributeGroup) {
                     table.Insert(qname, item);
                     return;
                 }
                 else if ((object)item == (object)builtInAttributeGroup) { //trying to overwrite customer's component with built-in, ignore built-in
                     return;
                 }
             }
             else if (IsValidAttributeGroupRedefine(existingObject, item, table)){ //check for redefines
                 return;
             }
             code = Res.Sch_DupAttributeGroup;
         } 
         else if (item is XmlSchemaAttribute) {
             string ns = nameTable.Add(qname.Namespace);
             if (Ref.Equal(ns, NsXml)) {
                 XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
                 XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
                 if ((object)existingObject == (object)builtInAttribute) { //replace built-in one
                     table.Insert(qname, item);
                     return;
                 }
                 else if ((object)item == (object)builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in
                     return;
                 }
             }
             code = Res.Sch_DupGlobalAttribute;
         } 
         else if (item is XmlSchemaSimpleType) {
             if (IsValidTypeRedefine(existingObject, item, table)) {
                 return;
             }
             code = Res.Sch_DupSimpleType;
         } 
         else if (item is XmlSchemaComplexType) {
             if (IsValidTypeRedefine(existingObject, item, table)) {
                 return;
             }
             code = Res.Sch_DupComplexType;
         }
         else if (item is XmlSchemaGroup) {
             if (IsValidGroupRedefine(existingObject, item, table)){ //check for redefines
                 return;
             }
             code = Res.Sch_DupGroup;
         } 
         else if (item is XmlSchemaNotation) {
             code = Res.Sch_DupNotation;
         }
         else if (item is XmlSchemaIdentityConstraint) {
             code = Res.Sch_DupIdentityConstraint;
         }
         else {
             Debug.Assert(item is XmlSchemaElement);
         }
         SendValidationEvent(code, qname.ToString(), item);
     } 
     else {
         table.Add(qname, item);
     }
 }
Пример #41
0
 internal SchemaAttDef GetAttribute(SchemaElementDecl ed, XmlQualifiedName qname, out bool skip) {
     SchemaAttDef attdef = null;
     skip = false;
     if (ed != null) { // local attribute or XSD
         attdef = ed.GetAttDef(qname);
         if (attdef == null) {
             // In DTD, every attribute must be declared.
             if (schemaType == SchemaType.DTD) {
                 throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
             }
             else if (schemaType == SchemaType.XDR) {
                 if (ed.Content.IsOpen) {
                     attdef = (SchemaAttDef)attributeDecls[qname];
                     if ((attdef == null) && ((qname.Namespace == String.Empty) || HasSchema(qname.Namespace))) {
                         throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                     }
                 }
                 else {
                     throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                 }
             }
             else { //XML Schema
                 XmlSchemaAnyAttribute any = ed.AnyAttribute;
                 if (any != null) {
                     if (any.NamespaceList.Allows(qname) && ed.ProhibitedAttributes[qname] == null) {
                         if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) {
                             attdef = (SchemaAttDef)attributeDecls[qname];
                             if (attdef == null && any.ProcessContentsCorrect == XmlSchemaContentProcessing.Strict) {
                                 throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                             }
                         }
                         else {
                             skip = true;
                         }
                     }
                     else {
                         throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());
                     }
                 }
                 else if (ed.ProhibitedAttributes[qname] != null) {
                     throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());
                 }
                 else {
                     throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
                 }
             }
         }
     }
     else { // global attribute
         attdef = (SchemaAttDef)attributeDecls[qname];
         if ((attdef == null) && HasSchema(qname.Namespace)) {
             throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
         }
     }
     return attdef;
 }
Пример #42
0
 private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
     if (qname.Name.Length == 0) {
         return true;
     }
     XmlSchemaObject existingObject = (XmlSchemaObject)table[qname]; 
     if (existingObject != null) {
         if (existingObject == item || existingObject.SourceUri == item.SourceUri) {
             return true;
         }
         string code = string.Empty;
         if (item is XmlSchemaComplexType) {
             code = Res.Sch_DupComplexType;
         } 
         else if (item is XmlSchemaSimpleType) {
             code = Res.Sch_DupSimpleType;
         } 
         else if (item is XmlSchemaElement) {
             code = Res.Sch_DupGlobalElement;
         } 
         else if (item is XmlSchemaAttribute) {
             if (qname.Namespace == XmlReservedNs.NsXml) {
                 XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
                 XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
                 if (existingObject == builtInAttribute) { //replace built-in one
                     table.Insert(qname, item);
                     return true;
                 }
                 else if (item == builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in
                     return true;
                 }
             }
             code = Res.Sch_DupGlobalAttribute;
         } 
         SendValidationEvent(new XmlSchemaException(code,qname.ToString()), XmlSeverityType.Error);
         return false;
     } 
     else {
         table.Add(qname, item);
         return true;
     }
 }
Пример #43
0
        internal void CheckContent(ValidationState context, XmlQualifiedName qname, ref XmlSchemaContentProcessing processContents) {
#if DEBUG
            Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, String.Format("\t\t\tSchemaContentModel.CheckContent({0}) in \"{1}\"", "\"" + qname.ToString() + "\"", context.Name));
#endif
            XmlQualifiedName n = qname.IsEmpty ? (schemaNames == null ? XmlQualifiedName.Empty : schemaNames.QnPCData) : qname;
            Object lookup;

            if (context.IsNill) {
                throw new XmlSchemaException(Res.Sch_ContentInNill, context.Name.ToString());
            }

            switch(contentType) {
                case CompiledContentModel.Type.Any:
                    context.HasMatched = true;
                    return;

                case CompiledContentModel.Type.Empty:
                    goto error;
                
                case CompiledContentModel.Type.Text:
                    if(qname.IsEmpty) 
                        return;
                    else
                        goto error;

                case CompiledContentModel.Type.Mixed:
                    if (qname.IsEmpty)
                        return;
                    break;

                case CompiledContentModel.Type.ElementOnly:
                    if (qname.IsEmpty)
                        goto error;
                    break;

                default:
                    break;
            }
    
            if (IsAllElements) {
                lookup = symbolTable[n];
                if (lookup != null) {
                    int index = (int)lookup;
                    if (context.AllElementsSet.Get(index)) {
                        throw new XmlSchemaException(Res.Sch_AllElement, qname.Name);
                    }
                    else {
                        context.AllElementsSet.Set(index);
                    }
                }
                else {
                    goto error;
                }
                return;
            }
            if (!IsCompiled) {
                CheckXsdContent(context, qname, ref processContents);
                return;
            }

            lookup = symbolTable[n];

            if (lookup != null) {
                int sym = (int)lookup;
                if (sym != -1 && dtrans != null) {
                    int state = ((int[])dtrans[context.State])[sym];
                    if (state != -1) {
                        context.State = state;
                        context.HasMatched = ((int[])dtrans[context.State])[symbols.Count] > 0;
                        return;
                    }
                }
            }

            if (IsOpen && context.HasMatched) {
                // XDR allows any well-formed contents after matched.
                return;
            }

            //
            // report error
            //
            context.NeedValidateChildren = false;

            error:
        
            ArrayList v = null;
            if (dtrans != null) {
                v = ExpectedElements(context.State, context.AllElementsSet);
            }
            if (v == null || v.Count == 0) {
                if (!(qname.IsEmpty)) {
                    throw new XmlSchemaException(Res.Sch_InvalidElementContent, new string[] { context.Name.ToString(), n.ToString() });
                }
                else {
                    if (n.Name.Equals("#PCDATA")) {
                        if(contentType == CompiledContentModel.Type.Empty)
                            throw new XmlSchemaException(Res.Sch_InvalidTextWhiteSpace);
                        else
                            throw new XmlSchemaException(Res.Sch_InvalidTextInElement,context.Name.ToString());
                    }
                    else {
                        throw new XmlSchemaException(Res.Sch_InvalidContent, context.Name.ToString());    
                    }
                }
            }
            else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < v.Count; ++i) {
                    builder.Append(v[i].ToString());
                    if (i+1 < v.Count)
                        builder.Append(" ");
                }
                if (qname.IsEmpty) {
                    if (n.Name.Equals("#PCDATA")) 
                        throw new XmlSchemaException(Res.Sch_InvalidTextInElementExpecting, new string[] { context.Name.ToString(), builder.ToString() } );
                    else
                        throw new XmlSchemaException(Res.Sch_InvalidContentExpecting, new string[] { context.Name.ToString(), builder.ToString() } );
                }
                else {
                    throw new XmlSchemaException(Res.Sch_InvalidElementContentExpecting, new string[] { context.Name.ToString(), n.ToString(), builder.ToString() });
                }
            }
        }
Пример #44
0
        internal void AddTerminal(XmlQualifiedName qname, String prefix, ValidationEventHandler eventHandler) {
            if (schemaNames.QnPCData.Equals(qname)) {
                nodeTable = new Hashtable();
            }
            else if (nodeTable != null) {
                if (nodeTable.ContainsKey(qname)) {
                    if (eventHandler != null) {
                        eventHandler(
                            this,
                            new ValidationEventArgs(
                                new XmlSchemaException(Res.Sch_DupElement, qname.ToString())
                            )
                        );
                    }
                    //notice: should not return here!
                }
                else {
                    nodeTable.Add(qname, qname);
                }
            }

            ContentNode n = NewTerminalNode(qname);
            if (stack.Count > 0) {
                InternalNode inNode = (InternalNode)stack.Pop();
                if (inNode != null) {
                    inNode.RightNode = n;
                    n.ParentNode = inNode;
                    n = inNode;
                }
            }
            stack.Push( n );
            isPartial = true;
        }
Пример #45
0
        private void ValidateStartElement()
        {
            if (context.ElementDecl != null)
            {
                if (context.ElementDecl.IsAbstract)
                {
                    SendValidationEvent(SR.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
                }

                reader.SchemaTypeObject = context.ElementDecl.SchemaType;

                if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null)
                {
                    reader.TypedValueObject = UnWrapUnion(context.ElementDecl.DefaultValueTyped);
                    context.IsNill = true; // reusing IsNill
                }
                else
                {
                    reader.TypedValueObject = null; //Typed value cleanup 
                }
                if (this.context.ElementDecl.HasRequiredAttribute || HasIdentityConstraints)
                {
                    _attPresence.Clear();
                }
            }

            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    if ((object)reader.NamespaceURI == (object)_nsXmlNs)
                    {
                        continue;
                    }
                    if ((object)reader.NamespaceURI == (object)_nsXsi)
                    {
                        continue;
                    }

                    try
                    {
                        reader.SchemaTypeObject = null;
                        XmlQualifiedName attQName = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI);
                        bool skipContents = (_processContents == XmlSchemaContentProcessing.Skip);
                        SchemaAttDef attnDef = schemaInfo.GetAttributeXsd(context.ElementDecl, attQName, ref skipContents);

                        if (attnDef != null)
                        {
                            if (context.ElementDecl != null && (context.ElementDecl.HasRequiredAttribute || _startIDConstraint != -1))
                            {
                                _attPresence.Add(attnDef.Name, attnDef);
                            }
                            Debug.Assert(attnDef.SchemaType != null);
                            reader.SchemaTypeObject = attnDef.SchemaType;
                            if (attnDef.Datatype != null)
                            {
                                // need to check the contents of this attribute to make sure
                                // it is valid according to the specified attribute type.
                                CheckValue(reader.Value, attnDef);
                            }
                            if (HasIdentityConstraints)
                            {
                                AttributeIdentityConstraints(reader.LocalName, reader.NamespaceURI, reader.TypedValueObject, reader.Value, attnDef);
                            }
                        }
                        else if (!skipContents)
                        {
                            if (context.ElementDecl == null
                                && _processContents == XmlSchemaContentProcessing.Strict
                                && attQName.Namespace.Length != 0
                                && schemaInfo.Contains(attQName.Namespace)
                                )
                            {
                                SendValidationEvent(SR.Sch_UndeclaredAttribute, attQName.ToString());
                            }
                            else
                            {
                                SendValidationEvent(SR.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning);
                            }
                        }
                    }
                    catch (XmlSchemaException e)
                    {
                        e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition);
                        SendValidationEvent(e);
                    }
                } while (reader.MoveToNextAttribute());
                reader.MoveToElement();
            }
        }
Пример #46
0
 private XmlSchemaSimpleType FindDataType(XmlQualifiedName name, TypeFlags flags)
 {
     if (name == null || name.IsEmpty)
     {
         return (XmlSchemaSimpleType)Scope.GetTypeDesc(typeof(string)).DataType;
     }
     TypeDesc typeDesc = Scope.GetTypeDesc(name.Name, name.Namespace, flags);
     if (typeDesc != null && typeDesc.DataType is XmlSchemaSimpleType)
         return (XmlSchemaSimpleType)typeDesc.DataType;
     XmlSchemaSimpleType dataType = (XmlSchemaSimpleType)Schemas.Find(name, typeof(XmlSchemaSimpleType));
     if (dataType != null)
     {
         return dataType;
     }
     if (name.Namespace == XmlSchema.Namespace)
         return (XmlSchemaSimpleType)Scope.GetTypeDesc("string", XmlSchema.Namespace, flags).DataType;
     else
     {
         if (name.Name == Soap.Array && name.Namespace == Soap.Encoding)
         {
             throw new InvalidOperationException(SR.Format(SR.XmlInvalidEncoding, name.ToString()));
         }
         else
         {
             throw new InvalidOperationException(SR.Format(SR.XmlMissingDataType, name.ToString()));
         }
     }
 }
Пример #47
0
        internal override void ProcessAttribute(string prefix, string name, string ns, string value) {
            XmlQualifiedName qname = new XmlQualifiedName(name, ns);
            if (this.currentEntry.Attributes != null) {
                for (int i = 0; i < this.currentEntry.Attributes.Length; i++) {
                    XsdAttributeEntry a = this.currentEntry.Attributes[i];
                    if (this.schemaNames.TokenToQName[(int)a.Attribute].Equals(qname)) {
                        try {
                            a.BuildFunc(this, value);
                        } 
                        catch (XmlSchemaException e) {
                            e.SetSource(this.reader.BaseURI, this.positionInfo.LineNumber, this.positionInfo.LinePosition);
                            SendValidationEvent(Res.Sch_InvalidXsdAttributeDatatypeValue, new string[] {name, e.Message},XmlSeverityType.Error);
                        }
                        return;
                    }
                }
            }

            // Check non-supported attribute
            if ((ns != this.schemaNames.NsXs) && (ns.Length != 0)) {
                if (ns == this.schemaNames.NsXmlNs) {
                    if (this.namespaces == null) {
                        this.namespaces = new Hashtable();
                    }
                    this.namespaces.Add((name == this.schemaNames.QnXmlNs.Name) ? string.Empty : name, value);
                }
                else {
                    XmlAttribute attribute = new XmlAttribute(prefix, name, ns, this.schema.Document);
                    attribute.Value = value;
                    this.unhandledAttributes.Add(attribute);
                }
            } 
            else {
                SendValidationEvent(Res.Sch_UnsupportedAttribute, qname.ToString());
            }
        }
Пример #48
0
 private void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
     if (qname.Name == string.Empty) {
         return;
     } 
     else if (table[qname] != null) {
         string code = Res.Sch_DupGlobalAttribute;
         if (item is XmlSchemaAttributeGroup) {
             code = Res.Sch_DupAttributeGroup;
         } 
         else if (item is XmlSchemaComplexType) {
             code = Res.Sch_DupComplexType;
         } 
         else if (item is XmlSchemaSimpleType) {
             code = Res.Sch_DupSimpleType;
         } 
         else if (item is XmlSchemaElement) {
             code = Res.Sch_DupGlobalElement;
         } 
         else if (item is XmlSchemaGroup) {
             code = Res.Sch_DupGroup;
         } 
         else if (item is XmlSchemaNotation) {
             code = Res.Sch_DupNotation;
         }
         SendValidationEvent(code, qname.ToString(), item);
     } 
     else {
         table.Add(qname, item);
     }
 }
Пример #49
0
 XmlSchemaElement FindElement(XmlQualifiedName name) {
     XmlSchemaElement element = (XmlSchemaElement)schemas.Find(name, typeof(XmlSchemaElement));
     if (element == null) throw new InvalidOperationException(Res.GetString(Res.XmlMissingElement, name.ToString()));
     return element;
 }