internal XSWhitespaceFacet(XmlSchemaWhiteSpaceFacet whitespaceFacet)
        {
            _facet = whitespaceFacet;

            if (_facet.Annotation is XmlSchemaAnnotation annotation)
            {
                _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation);
                _annotation.BindToContainer(RootContainer, this);
            }
        }
Beispiel #2
0
    public static void Main()
    {
        XmlSchema schema = new XmlSchema();

        // <xs:simpleType name="NameType">
        XmlSchemaSimpleType NameType = new XmlSchemaSimpleType();

        NameType.Name = "NameType";

        // <xs:restriction base="xs:string">
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();

        restriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        // <xs:whiteSpace value="collapse"/>
        XmlSchemaWhiteSpaceFacet whiteSpace = new XmlSchemaWhiteSpaceFacet();

        whiteSpace.Value = "collapse";
        restriction.Facets.Add(whiteSpace);

        NameType.Content = restriction;

        schema.Items.Add(NameType);

        // <xs:element name="LastName" type="NameType"/>
        XmlSchemaElement element = new XmlSchemaElement();

        element.Name           = "LastName";
        element.SchemaTypeName = new XmlQualifiedName("NameType", "");

        schema.Items.Add(element);

        XmlSchemaSet schemaSet = new XmlSchemaSet();

        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
        schemaSet.Add(schema);
        schemaSet.Compile();

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
        {
            compiledSchema = schema1;
        }


        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);
    }
Beispiel #3
0
    private void method_3(XmlNode A_0, ModeType A_1)
    {
        int num = 5;
        XmlSchemaSimpleType item = new XmlSchemaSimpleType {
            Name = A_0.Attributes[BookmarkStart.b("䔪䰬䈮吰", 5)].Value
        };
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
            BaseTypeName = new XmlQualifiedName(BookmarkStart.b("堪夬崮堰崲刴", 5), BookmarkStart.b("䌪夬嬮䄰लᨴᠶ丸䰺䨼ᄾ㙀灂歄⡆㭈ⱊ扌絎慐捒摔硖Řᙚᅜ౞ɠୢd੦ࡨ", 5))
        };

        item.Content = restriction;
        switch (A_1)
        {
        case ModeType.Enum:
            foreach (XmlNode node2 in A_0.SelectNodes(BookmarkStart.b("䘪ᜬ䨮弰䘲場", num), this.xmlNamespaceManager_0))
            {
                XmlSchemaEnumerationFacet facet2 = new XmlSchemaEnumerationFacet {
                    Value = node2.Attributes[BookmarkStart.b("崪䰬䌮䐰嘲", num)].Value
                };
                restriction.Facets.Add(facet2);
            }
            break;

        case ModeType.Pattern:
        {
            XmlNode node = A_0.SelectSingleNode(BookmarkStart.b("䘪ᜬ弮倰䜲䄴制䬸唺", num), this.xmlNamespaceManager_0);
            XmlSchemaPatternFacet facet = new XmlSchemaPatternFacet {
                Value = node.Attributes[BookmarkStart.b("崪䰬䌮䐰嘲", num)].Value
            };
            restriction.Facets.Add(facet);
            break;
        }

        case ModeType.Space:
        {
            XmlNode node3 = A_0.SelectSingleNode(BookmarkStart.b("䘪ᜬ堮夰娲䄴制䨸䬺尼尾⑀", num), this.xmlNamespaceManager_0);
            XmlSchemaWhiteSpaceFacet facet3 = new XmlSchemaWhiteSpaceFacet {
                Value = node3.Attributes[BookmarkStart.b("崪䰬䌮䐰嘲", num)].Value
            };
            restriction.Facets.Add(facet3);
            break;
        }
        }
        this.xmlSchema_0.Items.Add(item);
    }
Beispiel #4
0
        public static IEnumerable <XmlSchemaFacet> createXmlFacets(IEnumerable <ICctsFacet> facets)
        {
            var xmlFacets = new List <XmlSchemaFacet>();

            foreach (var facet in facets)
            {
                XmlSchemaFacet xmlFacet = null;
                switch (facet.name)
                {
                case "fractionDigit":
                    xmlFacet = new XmlSchemaFractionDigitsFacet();
                    break;

                case "length":
                    xmlFacet = new XmlSchemaLengthFacet();
                    break;

                case "maxExclusive":
                    xmlFacet = new XmlSchemaMaxExclusiveFacet();
                    break;

                case "maxInclusive":
                    xmlFacet = new XmlSchemaMaxInclusiveFacet();
                    break;

                case "maxLength":
                    xmlFacet = new XmlSchemaMaxLengthFacet();
                    break;

                case "minExclusive":
                    xmlFacet = new XmlSchemaMinExclusiveFacet();
                    break;

                case "minInclusive":
                    xmlFacet = new XmlSchemaMinInclusiveFacet();
                    break;

                case "minLength":
                    xmlFacet = new XmlSchemaMinLengthFacet();
                    break;

                case "pattern":
                    xmlFacet = new XmlSchemaPatternFacet();
                    break;

                case "totalDigits":
                    xmlFacet = new XmlSchemaTotalDigitsFacet();
                    break;

                case "whiteSpace":
                    xmlFacet = new XmlSchemaWhiteSpaceFacet();
                    break;

                case "enumeration":
                    foreach (var enumValue in facet.content.Split('|'))
                    {
                        var enumerationFacet = new XmlSchemaEnumerationFacet();
                        enumerationFacet.Value = enumValue;
                        xmlFacets.Add(enumerationFacet);
                    }
                    break;
                }
                if (xmlFacet != null)
                {
                    xmlFacet.Value = facet.content;
                    xmlFacets.Add(xmlFacet);
                }
            }
            return(xmlFacets);
        }
 protected override void Visit(XmlSchemaWhiteSpaceFacet facet)
 {
     AddLeaf(SimpleTypeStructureNodeType.FacetWhiteSpace, facet);
 }
 protected virtual void Visit(XmlSchemaWhiteSpaceFacet facet)
 {
 }
Beispiel #7
0
        public XsdSimpleRestrictionType(RelaxngDatatype primitive, RelaxngParamList parameters)
        {
            type = new XmlSchemaSimpleType();
            XmlSchemaSimpleTypeRestriction r =
                new XmlSchemaSimpleTypeRestriction();

            type.Content = r;
            string ns = primitive.NamespaceURI;

            // Remap XML Schema datatypes namespace -> XML Schema namespace.
            if (ns == "http://www.w3.org/2001/XMLSchema-datatypes")
            {
                ns = XSchema.Namespace;
            }
            r.BaseTypeName = new XmlQualifiedName(primitive.Name, ns);
            foreach (RelaxngParam p in parameters)
            {
                XmlSchemaFacet f     = null;
                string         value = p.Value;
                switch (p.Name)
                {
                case "maxExclusive":
                    f = new XmlSchemaMaxExclusiveFacet();
                    break;

                case "maxInclusive":
                    f = new XmlSchemaMaxInclusiveFacet();
                    break;

                case "minExclusive":
                    f = new XmlSchemaMinExclusiveFacet();
                    break;

                case "minInclusive":
                    f = new XmlSchemaMinInclusiveFacet();
                    break;

                case "pattern":
                    f = new XmlSchemaPatternFacet();
                    // .NET/Mono Regex has a bug that it does not support "IsLatin-1Supplement"
                    // (it somehow breaks at '-').
                    value = value.Replace("\\p{IsLatin-1Supplement}", "[\\x80-\\xFF]");
                    break;

                case "whiteSpace":
                    f = new XmlSchemaWhiteSpaceFacet();
                    break;

                case "length":
                    f = new XmlSchemaLengthFacet();
                    break;

                case "maxLength":
                    f = new XmlSchemaMaxLengthFacet();
                    break;

                case "minLength":
                    f = new XmlSchemaMinLengthFacet();
                    break;

                case "fractionDigits":
                    f = new XmlSchemaFractionDigitsFacet();
                    break;

                case "totalDigits":
                    f = new XmlSchemaTotalDigitsFacet();
                    break;

                default:
                    throw new RelaxngException(String.Format("XML Schema facet {0} is not recognized or not supported.", p.Name));
                }
                f.Value = value;
                r.Facets.Add(f);
            }

            // Now we create XmlSchema to handle simple-type
            // based validation (since there is no other way,
            // because of sucky XmlSchemaSimpleType design).
            schema = new XSchema();
            XmlSchemaElement el = new XmlSchemaElement();

            el.Name       = "root";
            el.SchemaType = type;
            schema.Items.Add(el);
            schema.Compile(null);
        }