Ejemplo n.º 1
0
 internal void AddNotation(SchemaNotation notation, ValidationEventHandler eventhandler)
 {
     if (notations[notation.Name.Name] == null)
     {
         notations.Add(notation.Name.Name, notation);
     }
     else if (eventhandler != null)
     {
         eventhandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_DupNotation, notation.Name.Name)));
     }
 }
        internal void AddCompiledInfo(SchemaInfo schemaInfo)
        {
            XmlQualifiedName qualifiedName;

            foreach (XmlSchemaElement element in this.elements.Values)
            {
                qualifiedName = element.QualifiedName;
                schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
                if (schemaInfo.ElementDecls[qualifiedName] == null)
                {
                    schemaInfo.ElementDecls.Add(qualifiedName, element.ElementDecl);
                }
            }
            foreach (XmlSchemaAttribute attribute in this.attributes.Values)
            {
                qualifiedName = attribute.QualifiedName;
                schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
                if (schemaInfo.ElementDecls[qualifiedName] == null)
                {
                    schemaInfo.AttributeDecls.Add(qualifiedName, attribute.AttDef);
                }
            }
            foreach (XmlSchemaType type in this.types.Values)
            {
                qualifiedName = type.QualifiedName;
                schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
                if ((!(type is XmlSchemaComplexType) || (type != XmlSchemaComplexType.AnyType)) && (schemaInfo.ElementDeclsByType[qualifiedName] == null))
                {
                    schemaInfo.ElementDeclsByType.Add(qualifiedName, type.ElementDecl);
                }
            }
            foreach (XmlSchemaNotation notation in this.notations.Values)
            {
                qualifiedName = notation.QualifiedName;
                schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
                SchemaNotation notation2 = new SchemaNotation(qualifiedName)
                {
                    SystemLiteral = notation.System,
                    Pubid         = notation.Public
                };
                if (schemaInfo.Notations[qualifiedName.Name] == null)
                {
                    schemaInfo.Notations.Add(qualifiedName.Name, notation2);
                }
            }
        }
Ejemplo n.º 3
0
        internal void AddCompiledInfo(SchemaInfo schemaInfo)
        {
            XmlQualifiedName itemName;

            foreach (XmlSchemaElement element in elements.Values)
            {
                itemName = element.QualifiedName;
                schemaInfo.TargetNamespaces[itemName.Namespace] = true;
                if (schemaInfo.ElementDecls[itemName] == null)
                {
                    schemaInfo.ElementDecls.Add(itemName, element.ElementDecl);
                }
            }
            foreach (XmlSchemaAttribute attribute in attributes.Values)
            {
                itemName = attribute.QualifiedName;
                schemaInfo.TargetNamespaces[itemName.Namespace] = true;
                if (schemaInfo.ElementDecls[itemName] == null)
                {
                    schemaInfo.AttributeDecls.Add(itemName, attribute.AttDef);
                }
            }
            foreach (XmlSchemaType type in types.Values)
            {
                itemName = type.QualifiedName;
                schemaInfo.TargetNamespaces[itemName.Namespace] = true;
                XmlSchemaComplexType complexType = type as XmlSchemaComplexType;
                if ((complexType == null || type != XmlSchemaComplexType.AnyType) && schemaInfo.ElementDeclsByType[itemName] == null)
                {
                    schemaInfo.ElementDeclsByType.Add(itemName, type.ElementDecl);
                }
            }
            foreach (XmlSchemaNotation notation in notations.Values)
            {
                itemName = notation.QualifiedName;
                schemaInfo.TargetNamespaces[itemName.Namespace] = true;
                SchemaNotation no = new SchemaNotation(itemName);
                no.SystemLiteral = notation.System;
                no.Pubid         = notation.Public;
                if (schemaInfo.Notations[itemName.Name] == null)
                {
                    schemaInfo.Notations.Add(itemName.Name, no);
                }
            }
        }
 private void Output(SchemaInfo schemaInfo)
 {
     foreach (XmlSchemaElement element in this.schema.Elements.Values)
     {
         schemaInfo.TargetNamespaces[element.QualifiedName.Namespace] = true;
         schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl);
     }
     foreach (XmlSchemaAttribute attribute in this.schema.Attributes.Values)
     {
         schemaInfo.TargetNamespaces[attribute.QualifiedName.Namespace] = true;
         schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef);
     }
     foreach (XmlSchemaType type in this.schema.SchemaTypes.Values)
     {
         schemaInfo.TargetNamespaces[type.QualifiedName.Namespace] = true;
         XmlSchemaComplexType type2 = type as XmlSchemaComplexType;
         if ((type2 == null) || (!type2.IsAbstract && (type != XmlSchemaComplexType.AnyType)))
         {
             schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl);
         }
     }
     foreach (XmlSchemaNotation notation in this.schema.Notations.Values)
     {
         schemaInfo.TargetNamespaces[notation.QualifiedName.Namespace] = true;
         SchemaNotation notation2 = new SchemaNotation(notation.QualifiedName) {
             SystemLiteral = notation.System,
             Pubid = notation.Public
         };
         if (!schemaInfo.Notations.ContainsKey(notation2.Name.Name))
         {
             schemaInfo.Notations.Add(notation2.Name.Name, notation2);
         }
     }
 }
Ejemplo n.º 5
0
        private void ParseNotationDecl()
        {
            // notation name
            if (GetToken(true) != Token.Name)
            {
                OnUnexpectedError();
            }

            XmlQualifiedName notationName = GetNameQualified(false);
#if !SILVERLIGHT
            SchemaNotation notation = null;
            if (!_schemaInfo.Notations.ContainsKey(notationName.Name))
            {
                if (_undeclaredNotations != null)
                {
                    _undeclaredNotations.Remove(notationName.Name);
                }
                notation = new SchemaNotation(notationName);
                _schemaInfo.Notations.Add(notation.Name.Name, notation);
            }
            else
            {
                // duplicate notation
                if (_validate)
                {
                    SendValidationEvent(_curPos - notationName.Name.Length, XmlSeverityType.Error, SR.Sch_DupNotation, notationName.Name);
                }
            }
#endif

            // public / system id
            Token token = GetToken(true);
            if (token == Token.SYSTEM || token == Token.PUBLIC)
            {
                string notationPublicId, notationSystemId;

                ParseExternalId(token, Token.NOTATION, out notationPublicId, out notationSystemId);

#if !SILVERLIGHT
                if (notation != null)
                {
                    notation.SystemLiteral = notationSystemId;
                    notation.Pubid = notationPublicId;
                }
#endif
            }
            else
            {
                OnUnexpectedError();
            }

            if (GetToken(false) != Token.GreaterThan)
                OnUnexpectedError();
        }
 private void Output(SchemaInfo schemaInfo) {
     string tns;
     foreach(XmlSchema schema in schemasToCompile.Values) {
         tns = schema.TargetNamespace;
         if (tns == null) {
             tns = string.Empty;
         }
         schemaInfo.TargetNamespaces[tns] = true;
     }
     foreach (XmlSchemaElement element in elements.Values) {
         schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl);
     }
     foreach (XmlSchemaAttribute attribute in attributes.Values) {
         schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef);
     }    
     foreach (XmlSchemaType type in schemaTypes.Values) {
         schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl);
     }
     foreach (XmlSchemaNotation notation in notations.Values) {
         SchemaNotation no = new SchemaNotation(notation.QualifiedName);
         no.SystemLiteral = notation.System;
         no.Pubid = notation.Public;
         if (!schemaInfo.Notations.ContainsKey(no.Name.Name)) {
             schemaInfo.Notations.Add(no.Name.Name, no);
         }
     }
    
 }
 internal void AddCompiledInfo(SchemaInfo schemaInfo)
 {
     XmlQualifiedName qualifiedName;
     foreach (XmlSchemaElement element in this.elements.Values)
     {
         qualifiedName = element.QualifiedName;
         schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
         if (schemaInfo.ElementDecls[qualifiedName] == null)
         {
             schemaInfo.ElementDecls.Add(qualifiedName, element.ElementDecl);
         }
     }
     foreach (XmlSchemaAttribute attribute in this.attributes.Values)
     {
         qualifiedName = attribute.QualifiedName;
         schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
         if (schemaInfo.ElementDecls[qualifiedName] == null)
         {
             schemaInfo.AttributeDecls.Add(qualifiedName, attribute.AttDef);
         }
     }
     foreach (XmlSchemaType type in this.types.Values)
     {
         qualifiedName = type.QualifiedName;
         schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
         if ((!(type is XmlSchemaComplexType) || (type != XmlSchemaComplexType.AnyType)) && (schemaInfo.ElementDeclsByType[qualifiedName] == null))
         {
             schemaInfo.ElementDeclsByType.Add(qualifiedName, type.ElementDecl);
         }
     }
     foreach (XmlSchemaNotation notation in this.notations.Values)
     {
         qualifiedName = notation.QualifiedName;
         schemaInfo.TargetNamespaces[qualifiedName.Namespace] = true;
         SchemaNotation notation2 = new SchemaNotation(qualifiedName) {
             SystemLiteral = notation.System,
             Pubid = notation.Public
         };
         if (schemaInfo.Notations[qualifiedName.Name] == null)
         {
             schemaInfo.Notations.Add(qualifiedName.Name, notation2);
         }
     }
 }
Ejemplo n.º 8
0
        private async Task ParseNotationDeclAsync() {
            // notation name
            if ( await GetTokenAsync( true ).ConfigureAwait(false) != Token.Name ) {
                OnUnexpectedError();
            }

            XmlQualifiedName notationName = GetNameQualified( false ); 
#if !SILVERLIGHT
            SchemaNotation notation = null;
            if ( !schemaInfo.Notations.ContainsKey( notationName.Name ) ) {
                if ( undeclaredNotations != null ) {
                    undeclaredNotations.Remove( notationName.Name );
                }
                notation = new SchemaNotation( notationName );
                schemaInfo.Notations.Add(notation.Name.Name, notation);
                
            }
            else {
                // duplicate notation
                if ( validate ) {
                    SendValidationEvent( curPos - notationName.Name.Length, XmlSeverityType.Error, Res.Sch_DupNotation, notationName.Name );
                }
            }
#endif

            // public / system id
            Token token = await GetTokenAsync( true ).ConfigureAwait(false);
            if ( token == Token.SYSTEM || token == Token.PUBLIC ) {
                string notationPublicId, notationSystemId;

                var tuple_2 = await ParseExternalIdAsync( token,  Token.NOTATION).ConfigureAwait(false);
                notationPublicId = tuple_2.Item1;
                notationSystemId = tuple_2.Item2;

#if !SILVERLIGHT
                if ( notation != null ) {
                    notation.SystemLiteral = notationSystemId;
                    notation.Pubid = notationPublicId;
                }
#endif
            }
            else {
                OnUnexpectedError();
            }

            if ( await GetTokenAsync( false ).ConfigureAwait(false) != Token.GreaterThan ) 
                OnUnexpectedError();
        }
Ejemplo n.º 9
0
        private void CompileTo(SchemaInfo schemaInfo) {
            this.schema.SchemaTypes.Insert(this.schemaNames.QnXsdAnyType, XmlSchemaComplexType.AnyType);
            this.schemaInfo = schemaInfo;
            this.complexTypeStack = new Stack();
            this.repeatAttributes = new Hashtable();

            foreach (XmlSchemaSubstitutionGroup sgroup in this.schema.Examplars.Values) {
                CompileSubstitutionGroup(sgroup);
            }

            foreach (XmlSchemaGroup group in this.schema.Groups.Values) {
                CompileGroup(group);
            }

            foreach (XmlSchemaAttributeGroup attributeGroup in this.schema.AttributeGroups.Values) {
                CompileAttributeGroup(attributeGroup);
            }

            foreach (XmlSchemaType type in this.schema.SchemaTypes.Values) {
                if (type is XmlSchemaComplexType) {
                    CompileComplexType((XmlSchemaComplexType)type);
                }
                else {
                    CompileSimpleType((XmlSchemaSimpleType)type);
                }
            }

            foreach (XmlSchemaElement element in this.schema.Elements.Values) {
                if (element.ElementDecl == null) {
                    CompileElement(element);
                }
            }

            foreach (XmlSchemaAttribute attribute in this.schema.Attributes.Values) {
                if (attribute.AttDef == null) {
                    CompileAttribute(attribute);
                }
            }    

            foreach (XmlSchemaIdentityConstraint identityConstraint in this.identityConstraints.Values) {
                if (identityConstraint.CompiledConstraint == null) {
                    CompileIdentityConstraint(identityConstraint);
                }
            }    

            while (this.complexTypeStack.Count > 0) {
                XmlSchemaComplexType type = (XmlSchemaComplexType)this.complexTypeStack.Pop();
                CompileCompexTypeElements(type);
            }

            foreach (XmlSchemaType type in this.schema.SchemaTypes.Values) {
                if (type is XmlSchemaComplexType) {
                    CheckParticleDerivation((XmlSchemaComplexType)type);
                }
            }

            foreach (XmlSchemaElement element in this.schema.Elements.Values) {
                if (element.ElementType is XmlSchemaComplexType && element.SchemaTypeName == XmlQualifiedName.Empty) { // only local types
                    CheckParticleDerivation((XmlSchemaComplexType)element.ElementType);
                }
            }

            foreach (XmlSchemaSubstitutionGroup sgroup in this.schema.Examplars.Values) {
                CheckSubstitutionGroup(sgroup);
            }


            if (this.schema.ErrorCount == 0) {
                foreach (XmlSchemaElement element in this.schema.Elements.Values) {
                    this.schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl);
                }
                foreach (XmlSchemaAttribute attribute in this.schema.Attributes.Values) {
                    this.schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef);
                }    
                foreach (XmlSchemaType type in this.schema.SchemaTypes.Values) {
                     XmlSchemaComplexType complexType = type as XmlSchemaComplexType;
                     if (complexType == null || (!complexType.IsAbstract && type != XmlSchemaComplexType.AnyType)) {
                        this.schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl);
                     }
                }
                foreach (DictionaryEntry entry in this.schema.Notations) {
                    XmlSchemaNotation notation = (XmlSchemaNotation)entry.Value;
                    SchemaNotation no = new SchemaNotation((XmlQualifiedName)entry.Key);
                    no.SystemLiteral = notation.System;
                    no.Pubid = notation.Public;
                    this.schemaInfo.AddNotation(no, this.validationEventHandler);
                }
            }
            this.schema.SchemaTypes.Remove(this.schemaNames.QnXsdAnyType);
        }
Ejemplo n.º 10
0
 internal void AddNotation(SchemaNotation notation, ValidationEventHandler eventhandler) {
     if (notations[notation.Name.Name] == null)
         notations.Add(notation.Name.Name, notation);
     else if (eventhandler != null) {
         eventhandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_DupNotation, notation.Name.Name)));
     }
 }
Ejemplo n.º 11
0
 internal void AddCompiledInfo(SchemaInfo schemaInfo) {
     XmlQualifiedName itemName;
     foreach (XmlSchemaElement element in elements.Values) {
         itemName = element.QualifiedName;
         schemaInfo.TargetNamespaces[itemName.Namespace] = true;
         if (schemaInfo.ElementDecls[itemName] == null) {
             schemaInfo.ElementDecls.Add(itemName, element.ElementDecl);
         }
     }
     foreach (XmlSchemaAttribute attribute in attributes.Values) {
         itemName = attribute.QualifiedName;
         schemaInfo.TargetNamespaces[itemName.Namespace] = true;
         if (schemaInfo.ElementDecls[itemName] == null) {
             schemaInfo.AttributeDecls.Add(itemName, attribute.AttDef);
         }
     }    
     foreach (XmlSchemaType type in types.Values) {
         itemName = type.QualifiedName;
         schemaInfo.TargetNamespaces[itemName.Namespace] = true;
         XmlSchemaComplexType complexType = type as XmlSchemaComplexType;
         if ((complexType == null || type != XmlSchemaComplexType.AnyType) && schemaInfo.ElementDeclsByType[itemName] == null) {
             schemaInfo.ElementDeclsByType.Add(itemName, type.ElementDecl);
         }
     }
     foreach (XmlSchemaNotation notation in notations.Values) {
         itemName = notation.QualifiedName;
         schemaInfo.TargetNamespaces[itemName.Namespace] = true;
         SchemaNotation no = new SchemaNotation(itemName);
         no.SystemLiteral = notation.System;
         no.Pubid = notation.Public;
         if (schemaInfo.Notations[itemName.Name] == null) {
             schemaInfo.Notations.Add(itemName.Name, no);
         }
     }
 }
 private void Output(SchemaInfo schemaInfo) {
     foreach (XmlSchemaElement element in this.schema.Elements.Values) {
         schemaInfo.TargetNamespaces[element.QualifiedName.Namespace] = true;
         schemaInfo.ElementDecls.Add(element.QualifiedName, element.ElementDecl);
     }
     foreach (XmlSchemaAttribute attribute in this.schema.Attributes.Values) {
         schemaInfo.TargetNamespaces[attribute.QualifiedName.Namespace] = true;
         schemaInfo.AttributeDecls.Add(attribute.QualifiedName, attribute.AttDef);
     }    
     foreach (XmlSchemaType type in this.schema.SchemaTypes.Values) {
         schemaInfo.TargetNamespaces[type.QualifiedName.Namespace] = true;
          XmlSchemaComplexType complexType = type as XmlSchemaComplexType;
          if (complexType == null || (!complexType.IsAbstract && type != XmlSchemaComplexType.AnyType)) {
             schemaInfo.ElementDeclsByType.Add(type.QualifiedName, type.ElementDecl);
          }
     }
     foreach (XmlSchemaNotation notation in this.schema.Notations.Values) {
         schemaInfo.TargetNamespaces[notation.QualifiedName.Namespace] = true;
         SchemaNotation no = new SchemaNotation(notation.QualifiedName);
         no.SystemLiteral = notation.System;
         no.Pubid = notation.Public;
         if (schemaInfo.Notations[no.Name.Name] == null) {
             schemaInfo.Notations.Add(no.Name.Name, no);
         }
     }
 }
Ejemplo n.º 13
0
        private     void ParseNotation() {
            while (true) {
                switch (_SubState) {
                    case 0:
                        GetToken();
                        _Notation = new SchemaNotation(GetName(_Token, false));
                        _SchemaInfo.AddNotation(_Notation, _InternalValidationEventHandler);
                        _SubState = 1;
                        break;

                    case 1:
                        GetToken();
                        _SubState = 2;
                        _IsPubid = true;
                        Push(DtdFunctionIndex.ParseExternalID);
                        ParseExternalID();
                        break;

                    case 2:
                        if (_HasExternalID) {
                            if (_SystemLiteral != null) {
                                GetToken();
                                _Notation.SystemLiteral = _SystemLiteral;
                            }

                            _Notation.Pubid = _PubidLiteral;
                            _IsPubid = false;
                            _SubState = 3;
                        }
                        else {
                            throw new XmlException(Res.Xml_ExpectExternalOrPublicId, _Scanner.StartLineNum, _Scanner.StartLinePos);
                        }
                        break;

                    case 3:
                        CheckTagend(_Token);
                        Pop();
                        return;
                }
            }
        }