internal SchemaType(XmlSchemaType type) { schemaType = type; IsComplex = false; DerivedByRestriction = false; thisComplexType = null; thisSchemaAttributes = new List <ISchemaAttribute>(); if (schemaType is XmlSchemaComplexType) { IsComplex = true; thisComplexType = schemaType as XmlSchemaComplexType; if (this.thisComplexType.DerivedBy == XmlSchemaDerivationMethod.Restriction) { DerivedByRestriction = true; } thisSchemaAttributes.Capacity = thisComplexType.AttributeUses.Count; foreach (System.Collections.DictionaryEntry currentEntry in thisComplexType.AttributeUses) { var newAttribute = new SchemaAttribute(currentEntry.Value as XmlSchemaAttribute); thisSchemaAttributes.Add(newAttribute); } } thisQualifiedName = null; thisBaseSchemaType = null; }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ private void SetSubstitutionGroup(IQualifiedName SubstitutionGroupValue) { this.SubstitutionGroup = ElementSubstitutionGroup.Unknown; if ((SubstitutionGroupValue.Name.Length == 0) && (SubstitutionGroupValue.Namespace.Length == 0)) { return; } if ((SubstitutionGroupValue.Namespace.Equals(XbrlDocument.XbrlNamespaceUri) == true) && (SubstitutionGroupValue.Name.Equals("item") == true)) { this.SubstitutionGroup = ElementSubstitutionGroup.Item; } else if ((SubstitutionGroupValue.Namespace.Equals(XbrlDocument.XbrlNamespaceUri) == true) && (SubstitutionGroupValue.Name.Equals("tuple") == true)) { this.SubstitutionGroup = ElementSubstitutionGroup.Tuple; } else if ((SubstitutionGroupValue.Namespace.Equals(XbrlDocument.XbrlDimensionsNamespaceUri) == true) && (SubstitutionGroupValue.Name.Equals("dimensionItem") == true)) { this.SubstitutionGroup = ElementSubstitutionGroup.DimensionItem; } else if ((SubstitutionGroupValue.Namespace.Equals(XbrlDocument.XbrlDimensionsNamespaceUri) == true) && (SubstitutionGroupValue.Name.Equals("hypercubeItem") == true)) { this.SubstitutionGroup = ElementSubstitutionGroup.HypercubeItem; } else { //// We can't identify the type, so throw an exception. //string MessageFormat = AssemblyResources.GetName("InvalidElementSubstitutionGroup"); //StringBuilder MessageFormatBuilder = new StringBuilder(); //MessageFormatBuilder.AppendFormat(MessageFormat, thisSchema.Path, SubstitutionGroupValue, thisName); //throw new XbrlException(MessageFormatBuilder.ToString()); } }
internal SchemaAttribute(XmlSchemaAttribute attribute) { this.Name = attribute.Name; this.Optional = false; this.Prohibited = false; this.Required = false; this.FixedValue = attribute.FixedValue; this.TypeName = new QualifiedName(attribute.SchemaTypeName); switch (attribute.Use) { case XmlSchemaUse.None: break; case XmlSchemaUse.Optional: this.Optional = true; break; case XmlSchemaUse.Prohibited: this.Prohibited = true; break; case XmlSchemaUse.Required: this.Required = true; break; default: var attributeUseAsString = attribute.Use.ToString(); throw new NotSupportedException($"Unsupported XmlSchemaUse enumeration '{attributeUseAsString}'."); } }
/// <summary> /// Checks for errors before applying a rule. /// </summary> /// <param name="node">The node instance to check.</param> /// <param name="dataList">Optional data collected during inspection of sources.</param> /// <param name="data">Private data to give to Apply() upon return.</param> /// <returns>True if an error occured.</returns> public override bool CheckConsistency(IAnchoredType node, IDictionary <ISourceTemplate, object> dataList, out object data) { bool Success = true; data = null; IClass EmbeddingClass = node.EmbeddingClass; IQualifiedName AnchoredName = (IQualifiedName)node.AnchoredName; Debug.Assert(AnchoredName.ValidPath.IsAssigned); IList <IIdentifier> ValidPath = AnchoredName.ValidPath.Item; Debug.Assert(dataList.Count == 1); Debug.Assert(dataList.ContainsKey(SourceTemplateList[0])); Tuple <IErrorList, ITypeName, ICompiledType> SourceData = dataList[SourceTemplateList[0]] as Tuple <IErrorList, ITypeName, ICompiledType>; Debug.Assert(SourceData != null); if (!SourceData.Item1.IsEmpty) { AddSourceErrorList(SourceData.Item1); Success = false; } else { data = new Tuple <ITypeName, ICompiledType>(SourceData.Item2, SourceData.Item3); } return(Success); }
/// <summary> /// Checks for errors before applying a rule. /// </summary> /// <param name="node">The node instance to check.</param> /// <param name="dataList">Optional data collected during inspection of sources.</param> /// <param name="data">Private data to give to Apply() upon return.</param> /// <returns>True if an error occured.</returns> public override bool CheckConsistency(IAssignmentInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data) { data = null; bool Success = true; // This list has been verified during the node tree check. Debug.Assert(node.DestinationList.Count > 0); IExpression SourceExpression = (IExpression)node.Source; IResultType SourceResult = SourceExpression.ResolvedResult.Item; if (node.DestinationList.Count > SourceResult.Count) { AddSourceError(new ErrorAssignmentMismatch(node)); Success = false; } else { IClass EmbeddingClass = node.EmbeddingClass; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; ISealableDictionary <IQualifiedName, ICompiledFeature> FinalFeatureTable = new SealableDictionary <IQualifiedName, ICompiledFeature>(); for (int i = 0; i < node.DestinationList.Count; i++) { IQualifiedName Destination = (QualifiedName)node.DestinationList[i]; IList <IIdentifier> ValidPath = Destination.ValidPath.Item; ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, ErrorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { Success = false; }
public static IElement GetCustomElement(IElement element, INode parent, IQualifiedName name) { if (element.CurrentNamespace != null && namespaces.ContainsKey(element.CurrentNamespace.Identifier)) { var customElement = namespaces[element.CurrentNamespace.Identifier].GetElement(parent, name); if (customElement != null) { return(customElement); } } var elementName = element.Name.LocalPart; if (!customElementFactories.ContainsKey(elementName)) { return(null); } foreach (var factory in customElementFactories[elementName]) { if (factory.IsValidFor(element)) { return(factory.Create(parent, name)); } } return(null); }
internal SchemaElement(XmlSchemaElement element) { thisSchemaElement = element; thisSchemaTypeName = null; thisSubstitutionGroup = null; thisUnhandledAttributes = null; }
public BaseAttribute(INode parent, IQualifiedName name, string value) : base(parent, name, value) { if (value == null) throw new ArgumentNullException("value"); this.value = new Uri(value, UriKind.RelativeOrAbsolute); }
public LangAttribute(INode parent, IQualifiedName name, string value) : base(parent, name, value) { if (value == null) throw new ArgumentNullException("value"); this.value = LanguageTag.Parse(value); }
public BaseAttribute(INode parent, IQualifiedName name, string value) : base(parent, name, value) { if (value == null) { throw new ArgumentNullException("value"); } this.value = new Uri(value, UriKind.RelativeOrAbsolute); }
public Element(INode parent, IQualifiedName name) : base(parent) { if (name == null) { throw new ArgumentNullException("name"); } this.name = name; }
public LangAttribute(INode parent, IQualifiedName name, string value) : base(parent, name, value) { if (value == null) { throw new ArgumentNullException("value"); } this.value = LanguageTag.Parse(value); }
public static INamespaceDeclaration ParseNamespace(INode parent, IQualifiedName name, string value) { if (name.Prefix != "xmlns" && name.LocalPart != "xmlns") { throw new ArgumentException("Either the prefix or local part of a namespace must be 'xmlns'"); } var identifier = new Uri(value, UriKind.Absolute); return(new NamespaceDeclaration(parent, name, identifier)); }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ internal Element(XbrlSchema Schema, ISchemaElement SchemaElement) { this.Schema = Schema; thisSchemaElement = SchemaElement; this.Id = SchemaElement.Id; this.Name = SchemaElement.Name; this.IsAbstract = SchemaElement.IsAbstract; this.TypeName = SchemaElement.SchemaTypeName; SetSubstitutionGroup(SchemaElement.SubstitutionGroup); SetPeriodType(); }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ private void SetItemType(IQualifiedName ItemTypeValue) { this.Type = thisSchema.GetXmlSchemaType(ItemTypeValue); if (this.Type == null) { string MessageFormat = AssemblyResources.GetName("InvalidElementItemType"); StringBuilder MessageFormatBuilder = new StringBuilder(); MessageFormatBuilder.AppendFormat(MessageFormat, thisSchema.Path, ItemTypeValue.Name, this.Name); thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString())); } }
protected Attribute(INode parent, IQualifiedName name, string value) : base(parent) { if (parent == null) throw new ArgumentNullException("parent"); if (name == null) throw new ArgumentNullException("name"); this.name = name; this.value = value; }
//------------------------------------------------------------------------------- //------------------------------------------------------------------------------- internal ISchemaType GetXmlSchemaType(IQualifiedName ItemTypeValue) { foreach (var CurrentEntry in thisXmlSchemaSet.GlobalTypes) { ISchemaType CurrentType = CurrentEntry.Value as ISchemaType; if (CurrentType.QualifiedName.FullyQualifiedName.Equals(ItemTypeValue.FullyQualifiedName) == true) { return(CurrentType); } } return(null); }
private static int FitsOnOneLine(IQualifiedName expression, int remainingSpace) { var space = remainingSpace; space = FitsOnOneLine(expression.Left, space); space -= 1; // dot if (space > 0) { space = FitsOnOneLine(expression.Right, space); } return(space); }
internal SchemaType(XmlSchemaType type) { schemaType = type; IsComplex = false; DerivedByRestriction = false; thisComplexType = null; thisSchemaAttributes = new List <ISchemaAttribute>(); if (schemaType is XmlSchemaComplexType) { InitializeFromComplexType(); } thisQualifiedName = null; thisBaseSchemaType = null; }
public IElement GetElement(INode parent, IQualifiedName name) { if (parent == null) { throw new ArgumentNullException("parent"); } if (name == null) { throw new ArgumentNullException("name"); } return((elementConstructors.ContainsKey(name.LocalPart)) ? elementConstructors[name.LocalPart](parent, name) : null); }
/// <summary> /// Compares two qualified names. /// </summary> /// <param name="qualifiedName1">The first qualified name.</param> /// <param name="qualifiedName2">The second qualified name.</param> public static bool IsQualifiedNameEqual(IQualifiedName qualifiedName1, IQualifiedName qualifiedName2) { bool Result = true; Result &= qualifiedName1.Path.Count == qualifiedName2.Path.Count; for (int i = 0; i < qualifiedName1.Path.Count && i < qualifiedName2.Path.Count; i++) { IIdentifier Path1 = (IIdentifier)qualifiedName1.Path[i]; IIdentifier Path2 = (IIdentifier)qualifiedName2.Path[i]; Result &= Path1.ValidText.Item != Path2.ValidText.Item; } return(Result); }
public static IAttribute GetCustomAttribute(IAttribute attribute, INode parent, IQualifiedName name, string value) { var attributeName = attribute.Name.ToString(); if (!customAttributeFactories.ContainsKey(attributeName)) return null; foreach (var factory in customAttributeFactories[attributeName]) { if (factory.IsValidFor(attribute)) return factory.Create(parent, name, value); } return null; }
/// <summary> /// Finds the matching nodes of a <see cref="IOldExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedExpression">The result of the search.</param> public static bool ResolveCompilerReferences(IOldExpression node, IErrorList errorList, out ResolvedExpression resolvedExpression) { resolvedExpression = new ResolvedExpression(); IClass EmbeddingClass = node.EmbeddingClass; IQualifiedName Query = (IQualifiedName)node.Query; IList <IIdentifier> ValidPath = Query.ValidPath.Item; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType)) { errorList.AddError(new ErrorBooleanTypeMissing(node)); return(false); } ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); Debug.Assert(LocalScope != null); if (node.EmbeddingBody == null && node.EmbeddingAssertion == null) { errorList.AddError(new ErrorInvalidOldExpression(node)); return(false); } if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } if (FinalFeature == null) { errorList.AddError(new ErrorInvalidOldExpression(node)); return(false); } ObjectType.FillResultPath(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, Query.ValidResultTypePath.Item); resolvedExpression.ResolvedFinalFeature = FinalFeature; resolvedExpression.ResolvedResult = new ResultType(FinalTypeName, FinalType, string.Empty); resolvedExpression.ResolvedException = new ResultException(); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
protected Attribute(INode parent, IQualifiedName name, string value) : base(parent) { if (parent == null) { throw new ArgumentNullException("parent"); } if (name == null) { throw new ArgumentNullException("name"); } this.name = name; this.value = value; }
/// <summary> /// Finds the matching nodes of a <see cref="INewExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedResult">The expression result types upon return.</param> /// <param name="resolvedException">Exceptions the expression can throw upon return.</param> /// <param name="constantSourceList">Sources of the constant expression upon return, if any.</param> /// <param name="expressionConstant">The expression constant upon return.</param> /// <param name="resolvedFinalFeature">The matching feature upon return.</param> public static bool ResolveCompilerReferences(INewExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out ICompiledFeature resolvedFinalFeature) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; resolvedFinalFeature = null; IClass EmbeddingClass = node.EmbeddingClass; IQualifiedName Object = (IQualifiedName)node.Object; IList <IIdentifier> ValidPath = Object.ValidPath.Item; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType)) { errorList.AddError(new ErrorBooleanTypeMissing(node)); return(false); } ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } if (FinalFeature == null) { errorList.AddError(new ErrorConstantNewExpression(node)); return(false); } ObjectType.FillResultPath(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, Object.ValidResultTypePath.Item); resolvedResult = new ResultType(BooleanTypeName, BooleanType, string.Empty); resolvedException = new ResultException(); resolvedFinalFeature = FinalFeature; #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
public static IElement GetCustomElement(IElement element, INode parent, IQualifiedName name) { if (element.CurrentNamespace != null && namespaces.ContainsKey(element.CurrentNamespace.Identifier)) { var customElement = namespaces[element.CurrentNamespace.Identifier].GetElement(parent, name); if (customElement != null) return customElement; } var elementName = element.Name.LocalPart; if (!customElementFactories.ContainsKey(elementName)) return null; foreach (var factory in customElementFactories[elementName]) { if (factory.IsValidFor(element)) return factory.Create(parent, name); } return null; }
/// <summary> /// Finds the matching nodes of a <see cref="IQueryExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedExpression">The result of the search.</param> public static bool ResolveCompilerReferences(IQueryExpression node, IErrorList errorList, out ResolvedExpression resolvedExpression) { resolvedExpression = new ResolvedExpression(); IQualifiedName Query = (IQualifiedName)node.Query; IList <IArgument> ArgumentList = node.ArgumentList; IClass EmbeddingClass = node.EmbeddingClass; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; IList <IIdentifier> ValidPath = Query.ValidPath.Item; ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } Debug.Assert(FinalFeature != null || FinalDiscrete != null); #if COVERAGE Debug.Assert(!node.IsComplex); #endif if (FinalFeature != null) { resolvedExpression.ResolvedFinalFeature = FinalFeature; return(ResolveFeature(node, errorList, FinalFeature, FinalTypeName, FinalType, ref resolvedExpression)); } else { Debug.Assert(FinalDiscrete != null); resolvedExpression.ResolvedFinalDiscrete = FinalDiscrete; return(ResolveDiscrete(node, errorList, FinalDiscrete, ref resolvedExpression)); } }
public YouTubeRecorded(INode parent, IQualifiedName name) : base(parent, name) { }
public RssSource(INode parent, IQualifiedName name) : base(parent, name) { }
public MediaTitle(INode parent, IQualifiedName name) : base(parent, name) { }
public OpenSearchTotalResults(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomGenerator(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomRights(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomLogo(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomEntry(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubeStatistics(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubeOccupation(INode parent, IQualifiedName name) : base(parent, name) { }
protected YouTubeSimpleContentElement(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubeEpisode(INode parent, IQualifiedName name) : base(parent, name) { }
public DcAccrualPeriodicity(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubePrivate(INode parent, IQualifiedName name) : base(parent, name) { }
public RssSkipHours(INode parent, IQualifiedName name) : base(parent, name) { }
public MediaAdult(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomCategory(INode parent, IQualifiedName name) : base(parent, name) { }
public XspfInfo(INode parent, IQualifiedName name) : base(parent, name) { }
public HtmlAnchor(INode parent, IQualifiedName name) : base(parent, name) { }
public XspfCreator(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubeWhen(INode parent, IQualifiedName name) : base(parent, name) { }
public XspfExtension(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomTitle(INode parent, IQualifiedName name) : base(parent, name) { }
public XspfIdentifier(INode parent, IQualifiedName name) : base(parent, name) { }
public YouTubeDerived(INode parent, IQualifiedName name) : base(parent, name) { }
protected AtomDateConstruct(INode parent, IQualifiedName name) : base(parent, name) { }
public XspfTrack(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomPublished(INode parent, IQualifiedName name) : base(parent, name) { }
public AtomContributor(INode parent, IQualifiedName name) : base(parent, name) { }
public RssItem(INode parent, IQualifiedName name) : base(parent, name) { }