// get attribute definition table. private Hashtable CollectAttrTable(RelaxngInterleave attList) { Hashtable table = new Hashtable(); if (attList == null) { return(table); } foreach (RelaxngPattern p in attList.Patterns) { RelaxngAttribute a = p as RelaxngAttribute; if (a == null) { a = (RelaxngAttribute) ((RelaxngOptional)p) .Patterns [0]; } RelaxngName rn = a.NameClass as RelaxngName; table.Add(new QName( rn.LocalName, rn.Namespace), a); } return(table); }
private void InferAttributes(RelaxngElement ct, bool isNew) { RelaxngInterleave attList = null; Hashtable table = null; do { if (source.NamespaceURI == NamespaceXmlns) { continue; } if (table == null) { attList = GetAttributes(ct); table = CollectAttrTable(attList); } QName attrName = new QName( source.LocalName, source.NamespaceURI); RelaxngPattern attr = table [attrName] as RelaxngPattern; if (attr == null) { if (attList == null) { attList = new RelaxngInterleave(); ct.Patterns.Insert(0, attList); } attList.Patterns.Add( InferNewAttribute( attrName, isNew)); } else { table.Remove(attrName); if (attrName.Namespace.Length > 0) { RelaxngDefine ga = GetGlobalAttribute(attrName); InferMergedAttribute( ga.Patterns [0]); } else { InferMergedAttribute(attr); } } } while (source.MoveToNextAttribute()); // mark all attr definitions that did not appear // as optional. if (table != null) { foreach (RelaxngPattern attr in table.Values) { if (attr is RelaxngOptional) { continue; } attList.Patterns.Remove(attr); RelaxngOptional opt = new RelaxngOptional(); opt.Patterns.Add(attr); attList.Patterns.Add(opt); } } }
public void WriteInterleave(RelaxngInterleave p) { WritePatterns(p.Patterns, '&', false); }