public RdpDatatype (string ns, string localName, RelaxngParamList parameters, RelaxngDatatypeProvider provider) { this.ns = ns; this.localName = localName; //this.provider = provider; if (provider == null) provider = RelaxngMergedProvider.DefaultProvider; datatype = provider.GetDatatype (localName, ns, parameters); if (datatype == null) { throw new RelaxngException (String.Format ("Invalid datatype was found for namespace '{0}' and local name '{1}'", ns, localName)); } }
public RdpDatatype(string ns, string localName, RelaxngParamList parameters, RelaxngDatatypeProvider provider) { this.ns = ns; this.localName = localName; //this.provider = provider; if (provider == null) { provider = RelaxngMergedProvider.DefaultProvider; } datatype = provider.GetDatatype(localName, ns, parameters); if (datatype == null) { throw new RelaxngException(String.Format("Invalid datatype was found for namespace '{0}' and local name '{1}'", ns, localName)); } }
public override RelaxngDatatype GetDatatype(string name, string ns, RelaxngParamList parameters) { RelaxngDatatype dt = GetPrimitiveType(name, ns); if (dt == null) { return(null); } else if (parameters == null || parameters.Count == 0) { return(dt); } else { return(new XsdSimpleRestrictionType(dt, parameters)); } }
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); }
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); }