예제 #1
0
        public void TestWriteXSINill()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";
               Name name = new Name(NameType.LEGAL, "Johnson", "Steve");
               sp.Name = name;
               name.SetField( CommonDTD.NAME_TYPE, new SifString( null ) );
               name.SetField(CommonDTD.NAME_MIDDLENAME, new SifString(null));

               SIF_ExtendedElement see = new SIF_ExtendedElement("FOO", null );
               see.SetField(GlobalDTD.SIF_EXTENDEDELEMENT, new SifString(null));
               see.XsiType = "Integer";
               sp.SIFExtendedElementsContainer.Add(see);

               sp.SetField( StudentDTD.STUDENTPERSONAL_LOCALID, new SifString( null ) );

               Console.WriteLine(sp.ToXml());
               StudentPersonal copy = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.LATEST, null, true);
               Console.WriteLine(copy.ToXml());

               name = copy.Name;
               Assert.IsNull(name.Type);
               Assert.IsNull(name.MiddleName);
               Assert.IsNotNull(name.FirstName);
               Assert.IsNotNull(name.LastName);

               // Attributes cannot be represented using xs nil
               SimpleField field = name.GetField(CommonDTD.NAME_TYPE);
               Assert.IsNull(field);

               field = name.GetField(CommonDTD.NAME_MIDDLENAME);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);

               see = copy.GetSIFExtendedElement("FOO");
               field = see.GetField(GlobalDTD.SIF_EXTENDEDELEMENT);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);

               field = copy.GetField(StudentDTD.STUDENTPERSONAL_LOCALID);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);
        }
예제 #2
0
        /**
           * Sets an array of <code>SIF_ExtendedElement</code> objects. All existing
           * <code>SIF_ExtendedElement</code> instances
           * are removed and replaced with this list. Calling this method with the
           * parameter value set to null removes all <code>SIF_ExtendedElements</code>.
           * @param elements The SIF_Extended elements instances to set on this object
           *
           *  @since ADK 1.5
           */
        //public void SetSifExtendedElements(SIF_ExtendedElement[] elements)
        //{
        //   SIF_ExtendedElements = elements;
        //}
        /// <summary> 	Sets a SIF_ExtendedElement.</summary>
        /// <param name="name">The element name
        /// </param>
        /// <param name="valu">The element value
        /// 
        /// @since Adk 1.5
        /// </param>
        public virtual void AddSIFExtendedElement( string name, string valu )
        {
            if ( GlobalDTD.SIF_EXTENDEDELEMENTS == null || name == null || valu == null )
            {
                return;
            }

            SIF_ExtendedElement ele = null;

            //	Lookup existing SIF_ExtendedElements container
            SIF_ExtendedElements see = (SIF_ExtendedElements) GetChild( GlobalDTD.SIF_EXTENDEDELEMENTS );
            if ( see == null )
            {
                //	Create a new SIF_ExtendedElements container
                see = new SIF_ExtendedElements();
                AddChild( see );
            }
            else
            {
                //	Lookup existing SIF_ExtendedElement with this name
                ele = see[name];
            }

            //	Create/update SIF_ExtendedElement
            if ( ele == null )
            {
                ele = new SIF_ExtendedElement( name, valu );
                see.AddChild( ele );
            }
            else
            {
                ele.TextValue = valu;
            }
        }
예제 #3
0
        public void TestWriteXSIType()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";

               SIF_ExtendedElement see = new SIF_ExtendedElement( "FOO", "BAR" );
               see.XsiType = "Integer";
               sp.SIFExtendedElementsContainer.Add( see );

               Console.WriteLine( sp.ToXml() );

               StudentPersonal copy =
               (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.LATEST, null, true );

               see = copy.SIFExtendedElements[0];

               Assert.IsNotNull( see );
               Assert.AreEqual( "Integer", see.XsiType );
        }