Example #1
0
 public static void addFacets(XmlSchemaSimpleContentRestriction restriction, IEnumerable <ICctsFacet> facets)
 {
     foreach (var xmlFacet in createXmlFacets(facets))
     {
         restriction.Facets.Add(xmlFacet);
     }
 }
 static void addEnumerationValues(XmlSchemaSimpleContentRestriction restriction, UpccEnum basicEnum)
 {
     foreach (var codeListEntry in basicEnum.CodelistEntries)
     {
         var xmlEnum = new XmlSchemaEnumerationFacet();
         xmlEnum.Value = codeListEntry.Name;
         restriction.Facets.Add(xmlEnum);
     }
 }
Example #3
0
 private static void Equal(XmlSchemaSimpleContentRestriction expected, XmlSchemaSimpleContentRestriction actual)
 {
     AnnotatedEqual(expected, actual);
     Assert.Equal(expected.BaseTypeName, actual.BaseTypeName);
     IsEquivalentTo(expected.BaseType, actual.BaseType);
     FacetsEquivalentTo(expected.Facets, actual.Facets);
     IsEquivalentTo(expected.Attributes, actual.Attributes);
     IsEquivalentTo(expected.AnyAttribute, actual.AnyAttribute);
 }
Example #4
0
        public static void ObtenerTipoDeDatoDerivadoDeXbrl(XmlSchema esquema, XmlSchemaType dataType, out XmlSchemaType dataTypeBaseQName)
        {
            dataTypeBaseQName = null;
            if (dataType.QualifiedName != null && dataType.QualifiedName.Namespace.Equals(EspacioNombresConstantes.InstanceNamespace))
            {
                if (TiposDatoXBRL.TiposXBRL.Contains(dataType.QualifiedName.Name))
                {
                    dataTypeBaseQName = dataType;
                }
            }
            else
            {
                if (dataType.DerivedBy.Equals(XmlSchemaDerivationMethod.Restriction))
                {
                    XmlQualifiedName qName = null;

                    if (dataType.GetType() == typeof(XmlSchemaSimpleType))
                    {
                        XmlSchemaSimpleType            simpleType            = (XmlSchemaSimpleType)dataType;
                        XmlSchemaSimpleTypeRestriction simpleTypeRestriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
                        qName = simpleTypeRestriction.BaseTypeName;
                    }
                    else if (dataType.GetType() == typeof(XmlSchemaComplexType))
                    {
                        XmlSchemaComplexType complexType = (XmlSchemaComplexType)dataType;
                        if (complexType.ContentModel == null)
                        {
                            ;
                        }
                        else
                        {
                            if (complexType.ContentModel.Content.GetType() == typeof(XmlSchemaComplexContentRestriction))
                            {
                                XmlSchemaComplexContentRestriction content = (XmlSchemaComplexContentRestriction)complexType.ContentModel.Content;
                                qName = content.BaseTypeName;
                            }
                            else
                            {
                                XmlSchemaSimpleContentRestriction content = (XmlSchemaSimpleContentRestriction)complexType.ContentModel.Content;
                                qName = content.BaseTypeName;
                            }
                        }
                    }

                    if (qName != null)
                    {
                        XmlSchemaType tipo = esquema.SchemaTypes.Contains(qName) ? esquema.SchemaTypes[qName] as XmlSchemaType : null;
                        if (tipo != null)
                        {
                            ObtenerTipoDeDatoDerivadoDeXbrl(esquema, tipo, out dataTypeBaseQName);
                        }
                    }
                }
            }
        }
        protected virtual void Visit(XmlSchemaSimpleContentRestriction restriction)
        {
            Traverse(restriction.Facets);

            Traverse(restriction.Attributes);

            if (restriction.AnyAttribute != null)
            {
                Traverse(restriction.AnyAttribute);
            }
        }
Example #6
0
 protected virtual void WriteContentModel(XmlSchemaComplexType type,
                                          XmlWriter writer)
 {
     if (type.ContentModel != null)
     {
         if (type.ContentModel is XmlSchemaSimpleContent)
         {
             XmlSchemaSimpleContent            content     = type.ContentModel as XmlSchemaSimpleContent;
             XmlSchemaSimpleContentRestriction restriction =
                 content.Content as XmlSchemaSimpleContentRestriction;
             if (restriction != null)
             {
                 WriteExampleValue(type.QualifiedName.Name, restriction.BaseType, writer);
             }
             else
             {
                 XmlSchemaSimpleContentExtension extension =
                     content.Content as XmlSchemaSimpleContentExtension;
             }
         }
         else if (type.Particle == null && type.ContentModel is XmlSchemaComplexContent)
         {
             XmlSchemaComplexContent complexContent =
                 type.ContentModel as XmlSchemaComplexContent;
             XmlSchemaComplexContentExtension ext =
                 type.ContentModel.Content as XmlSchemaComplexContentExtension;
             if (type.BaseXmlSchemaType != null)
             {
                 XmlSchemaComplexType baseType =
                     type.BaseXmlSchemaType as XmlSchemaComplexType;
                 if (baseType != null)
                 {
                     WriteContentModel(baseType, writer);
                 }
             }
             if (ext != null && ext.Particle != null)
             {
                 if (ext.BaseTypeName != null)
                 {
                     object ao = Schema.Elements[ext.BaseTypeName];
                     //string data = ao.ToString();
                 }
                 WriteExampleParticle(ext.Particle, writer);
             }
         }
     }
     if (type.Particle != null)
     {
         WriteExampleParticle(type.Particle, writer);
     }
 }
        void Parse_SimpleContent(TreeNode inner, XmlSchemaSimpleContent content)
        {
            XmlSchemaSimpleContentExtension   ext = content.Content as XmlSchemaSimpleContentExtension;
            XmlSchemaSimpleContentRestriction rst = content.Content as XmlSchemaSimpleContentRestriction;

            if (ext != null)
            {
                Add_Attributes(inner, ext.Attributes, ext.AnyAttribute);
            }

            XmlQualifiedName qname = GetContentBaseType(content.Content);
            TreeNode         node  = new TreeNode((GetBuiltInTypeName(qname)));

            inner.Nodes.Add(node);
        }
        protected override void Visit(XmlSchemaSimpleContentRestriction restriction)
        {
            if (restriction.Facets.Count == 0)
            {
                TraverseBaseType(restriction.BaseTypeName);
            }
            else
            {
                PushNode(SimpleTypeStructureNodeType.Restriction, restriction);

                TraverseBaseType(restriction.BaseTypeName);
                Traverse(restriction.Facets);

                PopNode();
            }
        }
 public void GetExpectedValues(XmlSchemaType si, XmlIntellisenseList list)
 {
     if (si == null)
     {
         return;
     }
     if (si is XmlSchemaSimpleType)
     {
         XmlSchemaSimpleType st = (XmlSchemaSimpleType)si;
         GetExpectedValues(st, list);
     }
     else if (si is XmlSchemaComplexType)
     {
         XmlSchemaComplexType ct = (XmlSchemaComplexType)si;
         if (ct.ContentModel is XmlSchemaComplexContent)
         {
             XmlSchemaComplexContent cc = (XmlSchemaComplexContent)ct.ContentModel;
             if (cc.Content is XmlSchemaComplexContentExtension)
             {
                 XmlSchemaComplexContentExtension ce = (XmlSchemaComplexContentExtension)cc.Content;
                 GetExpectedValues(GetTypeInfo(ce.BaseTypeName), list);
             }
             else if (cc.Content is XmlSchemaComplexContentRestriction)
             {
                 XmlSchemaComplexContentRestriction cr = (XmlSchemaComplexContentRestriction)cc.Content;
                 GetExpectedValues(GetTypeInfo(cr.BaseTypeName), list);
             }
         }
         else if (ct.ContentModel is XmlSchemaSimpleContent)
         {
             XmlSchemaSimpleContent sc = (XmlSchemaSimpleContent)ct.ContentModel;
             if (sc.Content is XmlSchemaSimpleContentExtension)
             {
                 XmlSchemaSimpleContentExtension ce = (XmlSchemaSimpleContentExtension)sc.Content;
                 GetExpectedValues(GetTypeInfo(ce.BaseTypeName), list);
             }
             else if (sc.Content is XmlSchemaSimpleContentRestriction)
             {
                 XmlSchemaSimpleContentRestriction cr = (XmlSchemaSimpleContentRestriction)sc.Content;
                 GetExpectedValues(GetTypeInfo(cr.BaseTypeName), list);
             }
         }
     }
     return;
 }
Example #10
0
 private void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction o)
 {
     if (o != null)
     {
         this.WriteStartElement("restriction");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttributes(o.UnhandledAttributes, o);
         if (!o.BaseTypeName.IsEmpty)
         {
             this.WriteAttribute("base", "", o.BaseTypeName);
         }
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         this.Write9_XmlSchemaSimpleType(o.BaseType);
         this.WriteFacets(o.Facets);
         this.WriteSortedItems(o.Attributes);
         this.Write33_XmlSchemaAnyAttribute(o.AnyAttribute);
         this.WriteEndElement();
     }
 }
Example #11
0
 void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction o)
 {
     if ((object)o == null)
     {
         return;
     }
     WriteStartElement("restriction");
     WriteAttribute(@"id", @"", ((System.String)o.@Id));
     WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
     if ([email protected])
     {
         WriteAttribute(@"base", @"", o.@BaseTypeName);
     }
     Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
     Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@BaseType);
     WriteFacets(o.Facets);
     WriteSortedItems(o.Attributes);
     Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
     WriteEndElement();
 }
Example #12
0
        public XmlQualifiedName GetBaseTypeName(XmlSchemaComplexType ct)
        {
            XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;

            if (sc == null)
            {
                return(null);
            }
            XmlSchemaSimpleContentExtension ex = sc.Content as XmlSchemaSimpleContentExtension;

            if (ex != null)
            {
                return(ex.BaseTypeName);
            }
            XmlSchemaSimpleContentRestriction cr = sc.Content as XmlSchemaSimpleContentRestriction;

            if (cr != null)
            {
                return(cr.BaseTypeName);
            }
            return(null);
        }
Example #13
0
        public ElementWrapper(XmlSchemaElement element, bool collectSubElements)
        {
            this.element = element;
            this.schema  = GetSchema();
            XmlSchemaComplexType ct = this.ComplexType;

            if (collectSubElements && ct != null)
            {
                GetAnnotations();
                CollectSubElements();
                CheckForSimpleRestriction();
                CollectAttributes(ct.Attributes);
                XmlSchemaSimpleContentExtension scex = this.SimpleContentExtension;
                if (scex != null)
                {
                    CollectAttributes(scex.Attributes);
                }
                XmlSchemaSimpleContentRestriction scr = this.SimpleContentRestriction;
                if (scr != null)
                {
                    CollectAttributes(scr.Attributes);
                }
            }
        }
Example #14
0
 private void BuildContentModel(XmlSchemaComplexType type,
                                ObjectDef def)
 {
     if (type.ContentModel != null)
     {
         if (type.ContentModel is XmlSchemaSimpleContent)
         {
             XmlSchemaSimpleContent            content     = type.ContentModel as XmlSchemaSimpleContent;
             XmlSchemaSimpleContentRestriction restriction =
                 content.Content as XmlSchemaSimpleContentRestriction;
             if (restriction != null)
             {
                 FieldDef field;
                 bool     isEnum;
                 string   dataType =
                     GetClassTypeFromDataType
                         (restriction.BaseType, type.QualifiedName.Name, def.Name,
                         out isEnum);
                 if (isEnum)
                 {
                     field = def.DefineElement(type.QualifiedName.Name, null);
                     field.SetEnum(dataType);
                 }
                 else
                 {
                     field = def.DefineElement(type.QualifiedName.Name, dataType);
                 }
                 if ((type.Particle != null && type.Particle.MinOccurs > 0) ||
                     (type.ContentTypeParticle != null && type.ContentTypeParticle.MinOccurs > 0))
                 {
                     field.SetFlags("M");
                 }
             }
             else
             {
                 XmlSchemaSimpleContentExtension extension =
                     content.Content as XmlSchemaSimpleContentExtension;
                 BuildAttributes(extension.Attributes, def);
                 //FieldDef field = def.defineElement( type.QualifiedName.Name, extension.BaseTypeName.Name );
             }
         }
         else if (type.Particle == null && type.ContentModel is XmlSchemaComplexContent)
         {
             XmlSchemaComplexContent complexContent =
                 type.ContentModel as XmlSchemaComplexContent;
             XmlSchemaComplexContentExtension ext =
                 type.ContentModel.Content as XmlSchemaComplexContentExtension;
             if (type.BaseXmlSchemaType != null)
             {
                 XmlSchemaComplexType baseType =
                     type.BaseXmlSchemaType as XmlSchemaComplexType;
                 if (baseType != null)
                 {
                     BuildContentModel(baseType, def);
                 }
             }
             if (ext != null && ext.Particle != null)
             {
                 if (ext.BaseTypeName != null)
                 {
                     object ao = Schema.Elements[ext.BaseTypeName];
                     //string data = ao.ToString();
                 }
                 BuildParticle(ext.Particle, def, true);
             }
         }
     }
     else if (type.Particle != null)
     {
         try {
             BuildParticle(type.Particle, def, true);
         }
         catch (SchemaNotImplementedException xse) {
             Console.WriteLine
                 ("Type Not Implemented: " + type.QualifiedName + " : " +
                 xse.Particle.ToString() + xse.Particle.SourceUri + ":" +
                 xse.Particle.LineNumber);
         }
     }
 }
Example #15
0
        static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value)
        {
            if (value == null)
            {
                return;
            }

            if (visitedObjects.Contains(value))
            {
                return;
            }
            visitedObjects.Add(value, value);

            if (value is XmlSchemaImport)
            {
                XmlSchemaImport so = (XmlSchemaImport)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAll)
            {
                XmlSchemaAll so = (XmlSchemaAll)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAnnotation)
            {
                XmlSchemaAnnotation so = (XmlSchemaAnnotation)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAttribute)
            {
                XmlSchemaAttribute so = (XmlSchemaAttribute)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAttributeGroup)
            {
                XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.RedefinedAttributeGroup);
            }
            else if (value is XmlSchemaAttributeGroupRef)
            {
                XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaChoice)
            {
                XmlSchemaChoice so = (XmlSchemaChoice)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaComplexContent)
            {
                XmlSchemaComplexContent so = (XmlSchemaComplexContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaComplexContentExtension)
            {
                XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexContentRestriction)
            {
                XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexType)
            {
                XmlSchemaComplexType so = (XmlSchemaComplexType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.ContentModel);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.ContentTypeParticle);
                Check(ctx, checker, visitedObjects, so.AttributeWildcard);
            }
            else if (value is XmlSchemaElement)
            {
                XmlSchemaElement so = (XmlSchemaElement)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.SchemaType);
                CheckObjects(ctx, checker, visitedObjects, so.Constraints);
            }
            else if (value is XmlSchemaGroup)
            {
                XmlSchemaGroup so = (XmlSchemaGroup)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
            }
            else if (value is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef so = (XmlSchemaGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaIdentityConstraint)
            {
                XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Fields);
                Check(ctx, checker, visitedObjects, so.Selector);
            }
            else if (value is XmlSchemaKeyref)
            {
                XmlSchemaKeyref so = (XmlSchemaKeyref)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaRedefine)
            {
                XmlSchemaRedefine so = (XmlSchemaRedefine)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSequence)
            {
                XmlSchemaSequence so = (XmlSchemaSequence)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSimpleContent)
            {
                XmlSchemaSimpleContent so = (XmlSchemaSimpleContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleContentExtension)
            {
                XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaSimpleContentRestriction)
            {
                XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType so = (XmlSchemaSimpleType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleTypeList)
            {
                XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaSimpleTypeRestriction)
            {
                XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleTypeUnion)
            {
                XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion)value;
                checker.Check(ctx, so);
            }
        }
Example #16
0
        internal void Depends(XmlSchemaObject item, ArrayList refs)
        {
            if (item == null || scope[item] != null)
            {
                return;
            }

            Type t = item.GetType();

            if (typeof(XmlSchemaType).IsAssignableFrom(t))
            {
                XmlQualifiedName          baseName   = XmlQualifiedName.Empty;
                XmlSchemaType             baseType   = null;
                XmlSchemaParticle         particle   = null;
                XmlSchemaObjectCollection attributes = null;

                if (item is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType ct = (XmlSchemaComplexType)item;
                    if (ct.ContentModel != null)
                    {
                        XmlSchemaContent content = ct.ContentModel.Content;
                        if (content is XmlSchemaComplexContentRestriction)
                        {
                            baseName   = ((XmlSchemaComplexContentRestriction)content).BaseTypeName;
                            attributes = ((XmlSchemaComplexContentRestriction)content).Attributes;
                        }
                        else if (content is XmlSchemaSimpleContentRestriction)
                        {
                            XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content;
                            if (restriction.BaseType != null)
                            {
                                baseType = restriction.BaseType;
                            }
                            else
                            {
                                baseName = restriction.BaseTypeName;
                            }
                            attributes = restriction.Attributes;
                        }
                        else if (content is XmlSchemaComplexContentExtension)
                        {
                            XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
                            attributes = extension.Attributes;
                            particle   = extension.Particle;
                            baseName   = extension.BaseTypeName;
                        }
                        else if (content is XmlSchemaSimpleContentExtension)
                        {
                            XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension)content;
                            attributes = extension.Attributes;
                            baseName   = extension.BaseTypeName;
                        }
                    }
                    else
                    {
                        attributes = ct.Attributes;
                        particle   = ct.Particle;
                    }
                    if (particle is XmlSchemaGroupRef)
                    {
                        XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle;
                        particle = ((XmlSchemaGroup)schemas.Find(refGroup.RefName, typeof(XmlSchemaGroup), false)).Particle;
                    }
                    else if (particle is XmlSchemaGroupBase)
                    {
                        particle = (XmlSchemaGroupBase)particle;
                    }
                }
                else if (item is XmlSchemaSimpleType)
                {
                    XmlSchemaSimpleType        simpleType = (XmlSchemaSimpleType)item;
                    XmlSchemaSimpleTypeContent content    = simpleType.Content;
                    if (content is XmlSchemaSimpleTypeRestriction)
                    {
                        baseType = ((XmlSchemaSimpleTypeRestriction)content).BaseType;
                        baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName;
                    }
                    else if (content is XmlSchemaSimpleTypeList)
                    {
                        XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content;
                        if (list.ItemTypeName != null && !list.ItemTypeName.IsEmpty)
                        {
                            baseName = list.ItemTypeName;
                        }
                        if (list.ItemType != null)
                        {
                            baseType = list.ItemType;
                        }
                    }
                    else if (content is XmlSchemaSimpleTypeRestriction)
                    {
                        baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName;
                    }
                    else if (t == typeof(XmlSchemaSimpleTypeUnion))
                    {
                        XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes;

                        if (memberTypes != null)
                        {
                            for (int i = 0; i < memberTypes.Length; i++)
                            {
                                XmlSchemaType type = (XmlSchemaType)schemas.Find(memberTypes[i], typeof(XmlSchemaType), false);
                                AddRef(refs, type);
                            }
                        }
                    }
                }
                if (baseType == null && !baseName.IsEmpty && baseName.Namespace != XmlSchema.Namespace)
                {
                    baseType = (XmlSchemaType)schemas.Find(baseName, typeof(XmlSchemaType), false);
                }

                if (baseType != null)
                {
                    AddRef(refs, baseType);
                }
                if (particle != null)
                {
                    Depends(particle, refs);
                }
                if (attributes != null)
                {
                    for (int i = 0; i < attributes.Count; i++)
                    {
                        Depends(attributes[i], refs);
                    }
                }
            }
            else if (t == typeof(XmlSchemaElement))
            {
                XmlSchemaElement el = (XmlSchemaElement)item;
                if (!el.SubstitutionGroup.IsEmpty)
                {
                    if (el.SubstitutionGroup.Namespace != XmlSchema.Namespace)
                    {
                        XmlSchemaElement head = (XmlSchemaElement)schemas.Find(el.SubstitutionGroup, typeof(XmlSchemaElement), false);
                        AddRef(refs, head);
                    }
                }
                if (!el.RefName.IsEmpty)
                {
                    el = (XmlSchemaElement)schemas.Find(el.RefName, typeof(XmlSchemaElement), false);
                    AddRef(refs, el);
                }
                else if (!el.SchemaTypeName.IsEmpty)
                {
                    XmlSchemaType type = (XmlSchemaType)schemas.Find(el.SchemaTypeName, typeof(XmlSchemaType), false);
                    AddRef(refs, type);
                }
                else
                {
                    Depends(el.SchemaType, refs);
                }
            }
            else if (t == typeof(XmlSchemaGroup))
            {
                Depends(((XmlSchemaGroup)item).Particle);
            }
            else if (t == typeof(XmlSchemaGroupRef))
            {
                XmlSchemaGroup group = (XmlSchemaGroup)schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false);
                AddRef(refs, group);
            }
            else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(t))
            {
                foreach (XmlSchemaObject o in ((XmlSchemaGroupBase)item).Items)
                {
                    Depends(o, refs);
                }
            }
            else if (t == typeof(XmlSchemaAttributeGroupRef))
            {
                XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup)schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false);
                AddRef(refs, group);
            }
            else if (t == typeof(XmlSchemaAttributeGroup))
            {
                foreach (XmlSchemaObject o in ((XmlSchemaAttributeGroup)item).Attributes)
                {
                    Depends(o, refs);
                }
            }
            else if (t == typeof(XmlSchemaAttribute))
            {
                XmlSchemaAttribute at = (XmlSchemaAttribute)item;
                if (!at.RefName.IsEmpty)
                {
                    at = (XmlSchemaAttribute)schemas.Find(at.RefName, typeof(XmlSchemaAttribute), false);
                    AddRef(refs, at);
                }
                else if (!at.SchemaTypeName.IsEmpty)
                {
                    XmlSchemaType type = (XmlSchemaType)schemas.Find(at.SchemaTypeName, typeof(XmlSchemaType), false);
                    AddRef(refs, type);
                }
                else
                {
                    Depends(at.SchemaType, refs);
                }
            }
            if (typeof(XmlSchemaAnnotated).IsAssignableFrom(t))
            {
                XmlAttribute[] attrs = (XmlAttribute[])((XmlSchemaAnnotated)item).UnhandledAttributes;

                if (attrs != null)
                {
                    for (int i = 0; i < attrs.Length; i++)
                    {
                        XmlAttribute attribute = attrs[i];
                        if (attribute.LocalName == Wsdl.ArrayType && attribute.NamespaceURI == Wsdl.Namespace)
                        {
                            string           dims;
                            XmlQualifiedName qname = TypeScope.ParseWsdlArrayType(attribute.Value, out dims, item);
                            XmlSchemaType    type  = (XmlSchemaType)schemas.Find(qname, typeof(XmlSchemaType), false);
                            AddRef(refs, type);
                        }
                    }
                }
            }
        }
Example #17
0
 protected override void Visit(XmlSchemaSimpleContentRestriction restriction)
 {
     ProcessRestriction(restriction.BaseTypeName, restriction.Attributes, restriction.AnyAttribute);
 }
 public override void Check(ConformanceCheckContext ctx, XmlSchemaSimpleContentRestriction value)
 {
     CheckSchemaQName(ctx, value, value.BaseTypeName);
 }
Example #19
0
 public virtual void Check(ConformanceCheckContext ctx, XmlSchemaSimpleContentRestriction value)
 {
 }
        static XmlSchemaElement CreateBbieSchemaElement(IBbie bbie, GeneratorContext context)
        {
            // R 89A6: for every BBIE a named element must be locally declared
            XmlSchemaElement elementBBIE = new XmlSchemaElement();

            // R AEFE, R 96D9, R9A40, R A34A are implemented in GetXsdElementNameFromBbie(...)
            elementBBIE.Name = NDR.GetXsdElementNameFromBbie(bbie);
            // R 8B85: every BBIE type must be named the property term and qualifiers and the
            //         representation term of the basic business information entity (BBIE) it represents
            //         with the word 'Type' appended.
            if (bbie.Bdt != null && bbie.Bdt.Con != null)
            {
                if (bbie.Bdt.Con.BasicType != null && bbie.Bdt.Con.BasicType.IsEnum)
                {
                    //figure out if the set of values is restricted
                    var basicEnum = bbie.Bdt.Con.BasicType.Enum as UpccEnum;
                    //use this method only if there are values specified in the basic enum. If not then we simply use the type
                    if (basicEnum != null && basicEnum.CodelistEntries.Any())
                    {
                        var sourceEnum = basicEnum.SourceElement as UpccEnum;
                        if (sourceEnum != null)
                        {
                            var restrictedtype = new XmlSchemaComplexType();
                            var sympleContent  = new XmlSchemaSimpleContent();
                            var restriction    = new XmlSchemaSimpleContentRestriction();
                            restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));
                            addEnumerationValues(restriction, basicEnum);
                            //add restriction to simplecontent
                            sympleContent.Content = restriction;
                            //add the restriction to the simple type
                            restrictedtype.ContentModel = sympleContent;
                            //set the type of the BBIE
                            elementBBIE.SchemaType = restrictedtype;
                        }
                    }
                }
                if (bbie.Bdt.isDirectXSDType)
                {
                    var XSDtype = bbie.Bdt.xsdType;
                    if (!string.IsNullOrEmpty(XSDtype))
                    {
                        if (bbie.Bdt.Con.AllFacets.Any())
                        {
                            //add facets
                            var restrictedtype = new XmlSchemaSimpleType();
                            var restriction    = new XmlSchemaSimpleTypeRestriction();
                            restriction.BaseTypeName = new XmlQualifiedName(NSPREFIX_XSD + ":" + XSDtype);
                            NDR.addFacets(restriction, bbie.Bdt.Con.AllFacets);
                            //add the restriction to the simple type
                            restrictedtype.Content = restriction;
                            //set the type of the BBIE
                            elementBBIE.SchemaType = restrictedtype;
                        }
                        else
                        {
                            elementBBIE.SchemaTypeName = new XmlQualifiedName(NSPREFIX_XSD + ":" + XSDtype);
                        }
                    }
                }
                if (bbie.Facets.Any())
                {
                    //add facets
                    if (bbie.Bdt.Sups.Any())
                    {
                        //create a complex type
                        var complexType = new XmlSchemaComplexType();
                        //add the simple content extension
                        var simpleContent = new XmlSchemaSimpleContent();
                        var restriction   = new XmlSchemaSimpleContentRestriction();
                        restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));
                        //add the facets
                        NDR.addFacets(restriction, bbie.Facets);
                        //add the simple content to the complex object
                        simpleContent.Content    = restriction;
                        complexType.ContentModel = simpleContent;
                        //add the complex type to the element
                        elementBBIE.SchemaType = complexType;
                    }
                    else
                    {
                        //create a simple type
                        var restrictedtype = new XmlSchemaSimpleType();
                        var restriction    = new XmlSchemaSimpleTypeRestriction();
                        restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));
                        NDR.addFacets(restriction, bbie.Facets);
                        //add the restriction to the simple type
                        restrictedtype.Content = restriction;
                        //set the type of the BBIE
                        elementBBIE.SchemaType = restrictedtype;
                    }
                }
                if (elementBBIE.SchemaType == null && elementBBIE.SchemaTypeName.IsEmpty)
                {
                    //use type without facets
                    elementBBIE.SchemaTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));
                }
            }
            // R 90F9: cardinality of elements within the ABIE
            elementBBIE.MinOccursString = AdjustLowerBound(bbie.LowerBound);
            elementBBIE.MaxOccursString = AdjustUpperBound(bbie.UpperBound);

            return(elementBBIE);
        }
 internal void Depends(XmlSchemaObject item, ArrayList refs)
 {
     if ((item != null) && (this.scope[item] == null))
     {
         Type c = item.GetType();
         if (typeof(XmlSchemaType).IsAssignableFrom(c))
         {
             XmlQualifiedName          empty      = XmlQualifiedName.Empty;
             XmlSchemaType             o          = null;
             XmlSchemaParticle         particle   = null;
             XmlSchemaObjectCollection attributes = null;
             if (item is XmlSchemaComplexType)
             {
                 XmlSchemaComplexType type3 = (XmlSchemaComplexType)item;
                 if (type3.ContentModel != null)
                 {
                     XmlSchemaContent content = type3.ContentModel.Content;
                     if (content is XmlSchemaComplexContentRestriction)
                     {
                         empty      = ((XmlSchemaComplexContentRestriction)content).BaseTypeName;
                         attributes = ((XmlSchemaComplexContentRestriction)content).Attributes;
                     }
                     else if (content is XmlSchemaSimpleContentRestriction)
                     {
                         XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content;
                         if (restriction.BaseType != null)
                         {
                             o = restriction.BaseType;
                         }
                         else
                         {
                             empty = restriction.BaseTypeName;
                         }
                         attributes = restriction.Attributes;
                     }
                     else if (content is XmlSchemaComplexContentExtension)
                     {
                         XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
                         attributes = extension.Attributes;
                         particle   = extension.Particle;
                         empty      = extension.BaseTypeName;
                     }
                     else if (content is XmlSchemaSimpleContentExtension)
                     {
                         XmlSchemaSimpleContentExtension extension2 = (XmlSchemaSimpleContentExtension)content;
                         attributes = extension2.Attributes;
                         empty      = extension2.BaseTypeName;
                     }
                 }
                 else
                 {
                     attributes = type3.Attributes;
                     particle   = type3.Particle;
                 }
                 if (particle is XmlSchemaGroupRef)
                 {
                     XmlSchemaGroupRef ref2 = (XmlSchemaGroupRef)particle;
                     particle = ((XmlSchemaGroup)this.schemas.Find(ref2.RefName, typeof(XmlSchemaGroup), false)).Particle;
                 }
                 else if (particle is XmlSchemaGroupBase)
                 {
                     particle = (XmlSchemaGroupBase)particle;
                 }
             }
             else if (item is XmlSchemaSimpleType)
             {
                 XmlSchemaSimpleType        type4    = (XmlSchemaSimpleType)item;
                 XmlSchemaSimpleTypeContent content2 = type4.Content;
                 if (content2 is XmlSchemaSimpleTypeRestriction)
                 {
                     o     = ((XmlSchemaSimpleTypeRestriction)content2).BaseType;
                     empty = ((XmlSchemaSimpleTypeRestriction)content2).BaseTypeName;
                 }
                 else if (content2 is XmlSchemaSimpleTypeList)
                 {
                     XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content2;
                     if ((list.ItemTypeName != null) && !list.ItemTypeName.IsEmpty)
                     {
                         empty = list.ItemTypeName;
                     }
                     if (list.ItemType != null)
                     {
                         o = list.ItemType;
                     }
                 }
                 else if (content2 is XmlSchemaSimpleTypeRestriction)
                 {
                     empty = ((XmlSchemaSimpleTypeRestriction)content2).BaseTypeName;
                 }
                 else if (c == typeof(XmlSchemaSimpleTypeUnion))
                 {
                     XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes;
                     if (memberTypes != null)
                     {
                         for (int i = 0; i < memberTypes.Length; i++)
                         {
                             XmlSchemaType type5 = (XmlSchemaType)this.schemas.Find(memberTypes[i], typeof(XmlSchemaType), false);
                             this.AddRef(refs, type5);
                         }
                     }
                 }
             }
             if (((o == null) && !empty.IsEmpty) && (empty.Namespace != "http://www.w3.org/2001/XMLSchema"))
             {
                 o = (XmlSchemaType)this.schemas.Find(empty, typeof(XmlSchemaType), false);
             }
             if (o != null)
             {
                 this.AddRef(refs, o);
             }
             if (particle != null)
             {
                 this.Depends(particle, refs);
             }
             if (attributes != null)
             {
                 for (int j = 0; j < attributes.Count; j++)
                 {
                     this.Depends(attributes[j], refs);
                 }
             }
         }
         else if (c == typeof(XmlSchemaElement))
         {
             XmlSchemaElement element = (XmlSchemaElement)item;
             if (!element.SubstitutionGroup.IsEmpty && (element.SubstitutionGroup.Namespace != "http://www.w3.org/2001/XMLSchema"))
             {
                 XmlSchemaElement element2 = (XmlSchemaElement)this.schemas.Find(element.SubstitutionGroup, typeof(XmlSchemaElement), false);
                 this.AddRef(refs, element2);
             }
             if (!element.RefName.IsEmpty)
             {
                 element = (XmlSchemaElement)this.schemas.Find(element.RefName, typeof(XmlSchemaElement), false);
                 this.AddRef(refs, element);
             }
             else if (!element.SchemaTypeName.IsEmpty)
             {
                 XmlSchemaType type6 = (XmlSchemaType)this.schemas.Find(element.SchemaTypeName, typeof(XmlSchemaType), false);
                 this.AddRef(refs, type6);
             }
             else
             {
                 this.Depends(element.SchemaType, refs);
             }
         }
         else if (c == typeof(XmlSchemaGroup))
         {
             this.Depends(((XmlSchemaGroup)item).Particle);
         }
         else if (c == typeof(XmlSchemaGroupRef))
         {
             XmlSchemaGroup group = (XmlSchemaGroup)this.schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false);
             this.AddRef(refs, group);
         }
         else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(c))
         {
             foreach (XmlSchemaObject obj2 in ((XmlSchemaGroupBase)item).Items)
             {
                 this.Depends(obj2, refs);
             }
         }
         else if (c == typeof(XmlSchemaAttributeGroupRef))
         {
             XmlSchemaAttributeGroup group2 = (XmlSchemaAttributeGroup)this.schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false);
             this.AddRef(refs, group2);
         }
         else if (c == typeof(XmlSchemaAttributeGroup))
         {
             foreach (XmlSchemaObject obj3 in ((XmlSchemaAttributeGroup)item).Attributes)
             {
                 this.Depends(obj3, refs);
             }
         }
         else if (c == typeof(XmlSchemaAttribute))
         {
             XmlSchemaAttribute attribute = (XmlSchemaAttribute)item;
             if (!attribute.RefName.IsEmpty)
             {
                 attribute = (XmlSchemaAttribute)this.schemas.Find(attribute.RefName, typeof(XmlSchemaAttribute), false);
                 this.AddRef(refs, attribute);
             }
             else if (!attribute.SchemaTypeName.IsEmpty)
             {
                 XmlSchemaType type7 = (XmlSchemaType)this.schemas.Find(attribute.SchemaTypeName, typeof(XmlSchemaType), false);
                 this.AddRef(refs, type7);
             }
             else
             {
                 this.Depends(attribute.SchemaType, refs);
             }
         }
         if (typeof(XmlSchemaAnnotated).IsAssignableFrom(c))
         {
             XmlAttribute[] unhandledAttributes = ((XmlSchemaAnnotated)item).UnhandledAttributes;
             if (unhandledAttributes != null)
             {
                 for (int k = 0; k < unhandledAttributes.Length; k++)
                 {
                     XmlAttribute attribute2 = unhandledAttributes[k];
                     if ((attribute2.LocalName == "arrayType") && (attribute2.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/"))
                     {
                         string           str;
                         XmlQualifiedName name  = TypeScope.ParseWsdlArrayType(attribute2.Value, out str, item);
                         XmlSchemaType    type8 = (XmlSchemaType)this.schemas.Find(name, typeof(XmlSchemaType), false);
                         this.AddRef(refs, type8);
                     }
                 }
             }
         }
     }
 }
Example #22
0
 protected override void Visit(XmlSchemaSimpleContentRestriction restriction)
 {
     AddBaseTypeUsage(restriction.BaseTypeName);
     base.Visit(restriction);
 }
Example #23
0
 protected override void Visit(XmlSchemaSimpleContentRestriction restriction)
 {
     // Don't visit the base type. Complex Type restrictions replace
     // the base type's nodes and attributes.
 }
        internal static XmlSchema BuildSchema(DiscoveryVersion version)
        {
            var schema = new XmlSchema()
            {
                TargetNamespace = version.Namespace
            };

            var anyAttr = new XmlSchemaAnyAttribute()
            {
                Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax
            };

            var probePart = new XmlSchemaSequence();

            probePart.Items.Add(new XmlSchemaElement()
            {
                RefName = new XmlQualifiedName("Types", version.Namespace), MinOccurs = 0
            });
            probePart.Items.Add(new XmlSchemaElement()
            {
                RefName = new XmlQualifiedName("Scopes", version.Namespace), MinOccurs = 0
            });
            probePart.Items.Add(new XmlSchemaAny()
            {
                MinOccurs = 0, MaxOccursString = "unbounded", Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax
            });
            var ct = new XmlSchemaComplexType()
            {
                Name = "ProbeType", Particle = probePart, AnyAttribute = anyAttr
            };

            schema.Items.Add(ct);

            schema.Items.Add(new XmlSchemaSimpleType()
            {
                Name = "QNameListType", Content = new XmlSchemaSimpleTypeList()
                {
                    ItemTypeName = new XmlQualifiedName("QName", XmlSchema.Namespace)
                }
            });

            var scr = new XmlSchemaSimpleContentRestriction()
            {
                BaseTypeName = new XmlQualifiedName("UriListType", version.Namespace), AnyAttribute = anyAttr
            };

            scr.Attributes.Add(new XmlSchemaAttribute()
            {
                Name = "matchBy", SchemaTypeName = new XmlQualifiedName("anyURI", XmlSchema.Namespace)
            });
            schema.Items.Add(new XmlSchemaComplexType()
            {
                Name = "ScopesType", ContentModel = new XmlSchemaSimpleContent()
                {
                    Content = scr
                }
            });

            schema.Items.Add(new XmlSchemaSimpleType()
            {
                Name = "UriListType", Content = new XmlSchemaSimpleTypeList()
                {
                    ItemTypeName = new XmlQualifiedName("anyURI", XmlSchema.Namespace)
                }
            });

            schema.Items.Add(new XmlSchemaElement()
            {
                Name = "Types", SchemaTypeName = new XmlQualifiedName("QNameListType", version.Namespace)
            });
            schema.Items.Add(new XmlSchemaElement()
            {
                Name = "Scopes", SchemaTypeName = new XmlQualifiedName("ScopesType", version.Namespace)
            });

            return(schema);
        }