private RelaxngValue ReadValuePattern() { RelaxngValue v = new RelaxngValue(); FillLocation(v); expect("value"); if (MoveToFirstAttribute()) { do { if (NamespaceURI != String.Empty) { continue; } switch (LocalName) { case "datatypeLibrary": case "type": case "ns": break; default: throw new RelaxngException("Invalid attribute."); } } while (MoveToNextAttribute()); MoveToElement(); } if (MoveToAttribute("type")) { v.Type = Value.Trim(); v.DatatypeLibrary = DatatypeLibrary; } else { v.Type = "token"; v.DatatypeLibrary = ""; } // v.Namespace = GetSpaceStrippedAttribute ("ns", String.Empty); MoveToElement(); if (IsEmptyElement) { v.Value = String.Empty; Read(); } else { v.Value = ReadString(); expectEnd("value"); } return(v); }
private RelaxngValue ReadValuePattern () { RelaxngValue v = new RelaxngValue (); FillLocation (v); expect ("value"); if (MoveToFirstAttribute ()) { do { if (NamespaceURI != String.Empty) continue; switch (LocalName) { case "datatypeLibrary": case "type": case "ns": break; default: throw new RelaxngException ("Invalid attribute."); } } while (MoveToNextAttribute ()); MoveToElement (); } if (MoveToAttribute ("type")) { v.Type = Value.Trim (); v.DatatypeLibrary = DatatypeLibrary; } else { v.Type = "token"; v.DatatypeLibrary = ""; } // v.Namespace = GetSpaceStrippedAttribute ("ns", String.Empty); MoveToElement (); if (IsEmptyElement) { v.Value = String.Empty; Read (); } else { v.Value = ReadString (); expectEnd ("value"); } return v; }
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); }