Example #1
0
        protected void SetUnionValue(object value,
                                    string propertyName,
                                    XTypedElement container,
                                    SimpleTypeValidator typeDef)
        {
            SetUnionCatchAll(value, propertyName, this, null, typeDef, SchemaOrigin.Text);

        }
	    /**
	     * Writes the schema location(s) to the XML Document
	     * @param doc the XML document to write the schema location(s) to
	     * @param schemaVersion the version of the schema to write in
	     * @param namespaceUri the URI of the namespace to write
	     */
	    public void WriteSchemaLocation(XTypedElement doc, string[] namespaceUri) 
        {
		    if(namespaceUri == null) 
			    return;

		    SdmxSchema schemaVersion;
		    StringBuilder schemaLocation = new StringBuilder();

		    string concat = "";
		    foreach (string currentNamespaceUri in namespaceUri) 
            {
			    schemaVersion = SdmxConstants.GetSchemaVersion(currentNamespaceUri);
			    //Base location of schema for version e.g. http://www.sss.sss/schema/
			    string schemaBaseLocation = GetSchemaLocation(schemaVersion);
			    string schemaName = SdmxConstants.GetSchemaName(currentNamespaceUri);
			    schemaLocation.Append(concat+currentNamespaceUri + " " + concat+schemaBaseLocation+schemaName);
			    concat = "\r\n";// System.getProperty("line.separator");
		    }

            doc.Untyped.SetAttributeValue(XName.Get("http://www.w3.org/2001/XMLSchema-instance","schemaLocation"),schemaLocation.ToString());
	    }
	    protected void WriteSchemaLocation(XTypedElement doc, SdmxSchemaEnumType schemaVersion) 
        {
		    if (schemaLocationWriter != null)
            {
                List<string> schemaUri = new List<string>();
			    switch(schemaVersion) 
                {
			        case SdmxSchemaEnumType.VersionOne :  
                        schemaUri.Add(SdmxConstants.MessageNs10);
			            break;
			        case SdmxSchemaEnumType.VersionTwo:  
                        schemaUri.Add(SdmxConstants.MessageNs20);
			            break;
			        case SdmxSchemaEnumType.VersionTwoPointOne :  
                        schemaUri.Add(SdmxConstants.MessageNs21);
			            break;
			        default : 
                        throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "Schema Version " + schemaVersion);
			    }
			    schemaLocationWriter.WriteSchemaLocation(doc, schemaUri.ToArray());
		    }
	    }
 public XRootNamespace(queryparam root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XRootNamespace(returndiscriminator root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XRootNamespace(nestedcompositeelement root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XRootNamespace(primitivearray root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XTypedSubstitutedList(XTypedElement container, ILinqToXsdTypeManager typeManager,
                              params XName[] itemXNames) : base(container, itemXNames)
 {
     this.typeManager = typeManager;
 }
Example #9
0
 public XRootNamespace(EntityContainer root)
 {
     _xDocument = new XDocument(root.Untyped);
       _rootObject = root;
 }
Example #10
0
 public XRoot(global::Xml.Schema.Linq.Deanonymize root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #11
0
 public XRootNamespace(sqlinsert root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #12
0
 public XRoot(global::Xml.Schema.Linq.@Namespace root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #13
0
 public XRoot(global::Xml.Schema.Linq.Transformation root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #14
0
 public XRootNamespace(VerifyRequired root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #15
0
 public XRootNamespace(Deanonymize root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #16
0
 public XRootNamespace(Transformation root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #17
0
 public XRootNamespace(synchronize root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #18
0
 public XRoot(global::Xml.Schema.Linq.VerifyRequired root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #19
0
 public XRootNamespace(version root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #20
0
 public XRootNamespace(Configuration root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #21
0
 protected void SetUnionElement(
     object value,
     string propertyName,
     XTypedElement container,
     XName itemXName,
     SimpleTypeValidator typeDef)
 {
     SetUnionCatchAll(
         value,
         propertyName,
         container,
         itemXName,
         typeDef,
         SchemaOrigin.Element);
 }
Example #22
0
 public XRootNamespace(Namespaces root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XRoot(global::https.www.veracode.com.schema.reports.export.Item1.Item0.detailedreport root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
        internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj, Type elementBaseType)
        {
            NamedContentModelEntity namedEntity = GetNamedEntity(name);

            if (namedEntity == null)
            {
                // See http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3542
                throw new LinqToXsdException(
                          "Name does not belong in content model. Cannot set value for child " +
                          name.LocalName);
            }

            EditAction editAction    = EditAction.None;
            XElement   elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction);

            XElement newElement = XTypedServices.GetXElement(xObj, name, elementBaseType);

            Debug.Assert(xObj != null);

            switch (editAction)
            {
            case EditAction.Append:
                parentElement.Add(newElement);
                break;

            case EditAction.Update:
                elementMarker.AddBeforeSelf(newElement);
                elementMarker.Remove();
                break;

            case EditAction.AddBefore:
                elementMarker.AddBeforeSelf(newElement);
                break;
            }
        }
 public static XSimpleList <T> CopyFromWithValidation(IEnumerable <T> values, XTypedElement container, XName itemXName, XmlSchemaDatatype dataType, string propertyName, SimpleTypeValidator typeDef)
 {
     return(XSimpleList <T> .Initialize(container, dataType, values, itemXName));
 }
Example #26
0
        //XML Query axes
        IEnumerable <T> IXTyped.Descendants <T>()
        {
            XTypedElement currentObject = this as XTypedElement;
            Type          lookupType    = typeof(T);

            //Metadata
            IXMetaData schemaMetaData = currentObject as IXMetaData;
            Dictionary <XName, System.Type> localElementsDict = null;
            ILinqToXsdTypeManager           typeManager       = schemaMetaData.TypeManager;
            Dictionary <XName, Type>        typeDictionary    = typeManager.GlobalTypeDictionary;

            //FSM
            XName    matchingName     = null;
            WildCard matchingWildCard = null;
            int      currentState     = FSM.InvalidState;

            XElement parentElement             = null;
            Stack <XTypedElement> elementStack = new Stack <XTypedElement>();

            while (true)
            {
                schemaMetaData = currentObject as IXMetaData;
                FSM fsm = currentObject.ValidationStates;
                if (fsm != null)
                {
                    StartFsm();
                    currentState = fsm.Start;
                }

                Debug.Assert(schemaMetaData != null);
                localElementsDict = schemaMetaData.LocalElementsDictionary;
                parentElement     = currentObject.Untyped;

                matchingName     = null;
                matchingWildCard = null;

                XTypedElement childObject  = null;
                bool          validContent = true;

                foreach (XElement childElement in parentElement.Elements())
                {
                    bool isTypeT = IsAnnoatedElemTypeOf <T>(childElement, out childObject);

                    if (isTypeT && fsm != null)  //Do not execute FSM if we do not find an element of type T
                    {
                        currentState = FsmMakeTransition(currentState, childElement.Name, out matchingName, out matchingWildCard);
                        if (currentState == FSM.InvalidState)
                        {
                            validContent = false;
                            break;
                        }
                    }

                    if (!isTypeT)  //check dictionary
                    {
                        if (fsm != null && matchingWildCard != null)
                        {
                            childObject = XTypedServices.ToXTypedElement(childElement, typeManager); //Auto-typing
                        }
                        else
                        {
                            childObject = TypeChildElement(childElement, localElementsDict, typeManager);
                        }
                        if (childObject != null)
                        {
                            Type runtimeType = childObject.GetType();
                            if (lookupType.IsAssignableFrom(runtimeType))
                            {
                                isTypeT = true;
                            }
                            else   //Check content type
                            {
                                Type contentType = null;
                                if (typeManager.RootContentTypeMapping.TryGetValue(runtimeType, out contentType) && lookupType.IsAssignableFrom(contentType))
                                {
                                    childObject = GetContentType(childObject);
                                    isTypeT     = true;
                                }
                            }
                        }
                    }
                    if (isTypeT)
                    {
                        yield return((T)childObject);
                    }
                    if (childObject != null)
                    {
                        elementStack.Push(childObject);
                    }
                }
                if (validContent && elementStack.Count > 0)
                {
                    currentObject = elementStack.Pop();
                }
                else
                {
                    break;
                }
            }
        }
Example #27
0
 public XRootNamespace(onetomany root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 internal XTypedElementWrapperAnnotation(XTypedElement typedElement)
 {
     this.typedElement = typedElement;
 }
Example #29
0
 public XRootNamespace(property root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #30
0
        private void SetUnionCatchAll(object value,
                                      string propertyName,
                                      XTypedElement container,
                                      XName itemXName,
                                      SimpleTypeValidator typeDef,
                                      SchemaOrigin origin)
        {
            UnionSimpleTypeValidator unionDef = typeDef as UnionSimpleTypeValidator;

            Debug.Assert(unionDef != null);
            SimpleTypeValidator matchingType = null;
            object    typedValue;
            Exception e = unionDef.TryParseValue(value,
                                                 XTypedServices.NameTable,
                                                 new XNamespaceResolver(container.GetUntyped()),
                                                 out matchingType,
                                                 out typedValue);

            if (e != null)
            {
                throw new LinqToXsdException(propertyName, e.Message);
            }
            else
            {
                if (matchingType is ListSimpleTypeValidator)
                {
                    ListSimpleTypeValidator listType = matchingType as ListSimpleTypeValidator;
                    switch (origin)
                    {
                    case SchemaOrigin.Element:
                        SetListElement(itemXName, value, listType.ItemType.DataType);
                        break;

                    case SchemaOrigin.Text:
                        SetListValue(value, listType.ItemType.DataType);
                        break;

                    case SchemaOrigin.Attribute:
                        SetListAttribute(itemXName, value, listType.ItemType.DataType);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (origin)
                    {
                    case SchemaOrigin.Element:
                        SetElement(itemXName, value, matchingType.DataType);
                        break;

                    case SchemaOrigin.Text:
                        SetValue(value, matchingType.DataType);
                        break;

                    case SchemaOrigin.Attribute:
                        SetAttribute(itemXName, value, matchingType.DataType);
                        break;

                    default: break;
                    }
                }
            }
        }
Example #31
0
 public XRootNamespace(resultset root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XTypedList(XTypedElement container, XName itemXName) : this(container, null, itemXName)
 {
 }
Example #33
0
 public XRootNamespace(returnscalar root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XTypedList(XTypedElement container, ILinqToXsdTypeManager typeManager, XName itemXName) : base(container, new XName[] { itemXName })
 {
     this.typeManager = typeManager;
 }
Example #35
0
 public XRootNamespace(unionsubclass root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public static XTypedList <T> CopyFromWithValidation(IEnumerable <T> typedObjects, XTypedElement container, XName itemXName, ILinqToXsdTypeManager typeManager, string propertyName, SimpleTypeValidator typeDef)
 {
     return(XTypedList <T> .Initialize(container, typeManager, typedObjects, itemXName));
 }
Example #37
0
 public XRootNamespace(sqldeleteall root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #38
0
 public XRoot(global::schemas.openehr.org.v1.template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #39
0
 public XRootNamespace(animateColor root)
 {
     this.doc=new XDocument(root.Untyped);
     this.rootObject=root;
 }
Example #40
0
 public XRootNamespace(template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #41
0
        private void SetUnionCatchAll(
            object value,
            string propertyName,
            XTypedElement container,
            XName itemXName,
            SimpleTypeValidator typeDef,
            SchemaOrigin origin)
        {
            UnionSimpleTypeValidator unionDef =
                typeDef as UnionSimpleTypeValidator;

            Debug.Assert(unionDef != null);

            SimpleTypeValidator matchingType = null;
            object typedValue;
            Exception e = unionDef.TryParseValue(
                value,
                XTypedServices.NameTable,
                new XNamespaceResolver(container.GetUntyped()),
                out matchingType,
                out typedValue);

            if (e != null)
            {
                throw new LinqToXsdException(propertyName, e.Message);
            }
            else
            {
                if (matchingType is ListSimpleTypeValidator)
                {
                    ListSimpleTypeValidator listType = matchingType as ListSimpleTypeValidator;
                    switch (origin)
                    {
                        case SchemaOrigin.Element:
                            SetListElement(itemXName, value, listType.ItemType.DataType);
                            break;
                        case SchemaOrigin.Text:
                            SetListValue(value, listType.ItemType.DataType);
                            break;
                        case SchemaOrigin.Attribute:
                            SetListAttribute(itemXName, value, listType.ItemType.DataType);
                            break;
                        default:
                            break;
                    }

                }
                else
                {
                    switch (origin)
                    {
                        case SchemaOrigin.Element: SetElement(itemXName, value, matchingType.DataType); break;
                        case SchemaOrigin.Text: SetValue(value, matchingType.DataType); break;
                        case SchemaOrigin.Attribute: SetAttribute(itemXName, value, matchingType.DataType); break;
                        default: break;
                    }
                }
            }
        }
Example #42
0
        public static XTypedElement ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager, System.Type t)
        {
            if (xe == null)
            {
                return(null);
            }

            if (!t.IsSubclassOf(typeof(XTypedElement)))
            {
                throw new InvalidOperationException("Type t is not a subtype of XTypedElement");
            }

            if (typeManager == null)
            {
                throw new ArgumentNullException("typeManager");
            }

            //Try getting back as the type first, optimized for the cases where xsi:type cannot appear
            XTypedElement xoSubType = GetAnnotation(t, xe);

            if (xoSubType == null)
            {
                //Try xsi:type and lookup in the typeDictionary
                Type clrType = GetXsiClrType(xe, typeManager);
                if (clrType != null)
                {
                    xoSubType = GetAnnotation(clrType, xe);
                    if (xoSubType != null)
                    {
                        return(xoSubType);
                    }

                    if (!t.IsAssignableFrom(clrType))
                    {
                        //xsi:type is not subtype of schema type
                        clrType = t;
                    }
                }
                else
                {
                    //xsi:type not present or CLRType not found for xsi:type name
                    clrType = t;
                }

                if (clrType.IsAbstract)
                {
                    throw new InvalidOperationException("Cannot cast XElement to an abstract type");
                }

                // get public or instance
                var             exactBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
                ConstructorInfo constrInfo   = clrType.GetConstructor(exactBinding, null, Type.EmptyTypes, null);
                if (constrInfo == null)
                {
                    throw new TypeAccessException($"There is no public/internal parameter-less constructor for type:  {clrType.FullName}");
                }

                xoSubType         = (XTypedElement)constrInfo.Invoke(null);
                xoSubType.Untyped = xe;
                xe.AddAnnotation(new XTypedElementAnnotation(xoSubType));
            }

            return(xoSubType);
        }
Example #43
0
 public XRoot(global::openEHR.v1.Template.template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #44
0
 public XRootNamespace(listindex root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
 public XRootNamespace(detailedreport root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #46
0
 public XRootNamespace(metavalue root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #47
0
        internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj) {
            NamedContentModelEntity namedEntity = GetNamedEntity(name);
            if (namedEntity == null) {
                // See http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3542
                throw new LinqToXsdException(
                    "Name does not belong in content model. Cannot set value for child " +
                    name.LocalName);
            }
            EditAction editAction = EditAction.None;
            XElement elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction);

            XElement newElement = XTypedServices.GetXElement(xObj, name);
            Debug.Assert(xObj != null);
            
            switch (editAction) {
                case EditAction.Append:
                    parentElement.Add(newElement);
                break;
                
                case EditAction.Update:
                    elementMarker.AddBeforeSelf(newElement);
                    elementMarker.Remove();
                break;
                
                case EditAction.AddBefore:
                    elementMarker.AddBeforeSelf(newElement);
                break;
            }
        }
Example #48
0
 public XRootNamespace(naturalid root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #49
0
 public XRootNamespace(StorageSchema root)
 {
     _xDocument = new XDocument(root.Untyped);
       _rootObject = root;
 }
 public XSimpleList(XTypedElement container, XmlSchemaDatatype dataType, XName itemXName) : base(container, new XName[] { itemXName })
 {
     this.schemaDatatype = dataType;
 }