RelaxngPattern CreatePatternFromType(XmlSchemaType type) { XmlSchemaSimpleType st = type as XmlSchemaSimpleType; if (st == null) { throw new NotSupportedException("Complex types are not supported as an attribute type."); } XmlSchemaSimpleTypeRestriction r = st.Content as XmlSchemaSimpleTypeRestriction; if (r == null) { throw new NotSupportedException("Only simple type restriction is supported as an attribute type."); } RelaxngChoice c = new RelaxngChoice(); foreach (XmlSchemaFacet f in r.Facets) { XmlSchemaEnumerationFacet en = f as XmlSchemaEnumerationFacet; if (en == null) { throw new NotSupportedException("Only enumeration facet is supported."); } RelaxngValue v = new RelaxngValue(); v.Type = r.BaseTypeName.Name; v.DatatypeLibrary = RemapDatatypeLibrary( r.BaseTypeName.Namespace); v.Value = en.Value; c.Patterns.Add(v); } return(c); }
public void WriteValue(RelaxngValue v) { WriteQName(v.Type, v.DatatypeLibrary, datansmgr); w.Write(' '); WriteLiteral(v.Value); }