none
deserialize nested ref RRS feed

  • Question

  • Hello.
    I have one question, you can expand the refs  ids nested in an xml with DataContractserializer?
    It 'a life that I try and I try on google but I did not succeed.
    I created the classes with serviceutil but when deserialize the nested ref are not processed.

    <?xml version="1.0" encoding="UTF-8"?>
    <iso_10303_28 version="2.0"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns:xlink="http://www.w3.org/1999/xlink" 
    	xmlns="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" 
    	>
    
    	<iso_10303_28_header>
    		<name>Spaces.ifc</name>
    		<time_stamp>2007-06-08T19:41:10</time_stamp>
    		<author>Architect</author>
    		<organization>Building Designer Office</organization>
    		<preprocessor_version>Express Data Manager Version 4.7.065 Oct 30 2006</preprocessor_version>
    		<originating_system>Windows System</originating_system>
    		<authorization>The authorising person</authorization>
    		<documentation>ArchiCAD 10.00 Release 1.Build Number of the Ifc 2x3 interface: 63044 (18-04-2007)</documentation>
    	</iso_10303_28_header>
    	<uos id="uos_1" description="" edo="" configuration="default" xmlns="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"
    	xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" >
    		<IfcAxis2Placement3D id="i1637">
    			<Location>
    				<IfcCartesianPoint id="i1668">
    					<Coordinates cType="list">
    						<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
    						<IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
    						<IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
    					</Coordinates>
    				</IfcCartesianPoint>
    			</Location>
    		</IfcAxis2Placement3D>
    		<IfcOwnerHistory id="i1640">
    			<OwningUser>
    				<IfcPersonAndOrganization id="i1656"><!-- not expanded ignored
    					<ThePerson>
    						<IfcPerson id="i1650">
    							<FamilyName>ddddddd</FamilyName>
    							<GivenName>dddddddd</GivenName>
    						</IfcPerson>
    					</ThePerson>
    					<TheOrganization>
    						<IfcOrganization xsi:nil="true" ref="i1652"/>
    					</TheOrganization>
    				</IfcPersonAndOrganization>
    			</OwningUser>
    			<OwningApplication>
    				<IfcApplication id="i1659">
    					<ApplicationDeveloper>
    						<IfcOrganization xsi:nil="true" ref="i1652"/>
    					</ApplicationDeveloper>
    					<Version>2015.0</Version>
    					<ApplicationFullName>Allplan</ApplicationFullName>
    					<ApplicationIdentifier>Allplan</ApplicationIdentifier>
    				</IfcApplication>
    			</OwningApplication>
    			<ChangeAction>added</ChangeAction>
    			<CreationDate>1451984836</CreationDate>
    		</IfcOwnerHistory>
    		<IfcOrganization id="i1652">
    			<Name>Nemetschek Allplan GmbH</Name>
    		</IfcOrganization>
    		<IfcProject id="i1641">
    			<GlobalId>1flAB4Nyr0tfc3H9ITrNh4</GlobalId>
    			<OwnerHistory>
    				<IfcOwnerHistory xsi:nil="true" ref="i1640"/>
    			</OwnerHistory>
    			<Name>giugio</Name>
    			<RepresentationContexts cType="set">
    				<IfcGeometricRepresentationContext xsi:nil="true" ref="i1647"/>
    				<IfcGeometricRepresentationContext xsi:nil="true" ref="i1674"/>
    			</RepresentationContexts>
    			<UnitsInContext>
    				<IfcUnitAssignment id="i1678">
    					<Units cType="set">
    						<IfcSIUnit id="i1661">
    							<UnitType>lengthunit</UnitType>
    							<Prefix>milli</Prefix>
    							<Name>metre</Name>
    						</IfcSIUnit>
    						<IfcConversionBasedUnit id="i1665">
    							<Dimensions>
    								<IfcDimensionalExponents id="i1664">
    									<LengthExponent>0</LengthExponent>
    									<MassExponent>0</MassExponent>
    									<TimeExponent>0</TimeExponent>
    									<ElectricCurrentExponent>0</ElectricCurrentExponent>
    									<ThermodynamicTemperatureExponent>0</ThermodynamicTemperatureExponent>
    									<AmountOfSubstanceExponent>0</AmountOfSubstanceExponent>
    									<LuminousIntensityExponent>0</LuminousIntensityExponent>
    								</IfcDimensionalExponents>
    							</Dimensions>
    							<UnitType>planeangleunit</UnitType>
    							<Name>DEGREE</Name>
    							<ConversionFactor>
    								<IfcMeasureWithUnit id="i1663">
    									<ValueComponent>
    										<IfcPlaneAngleMeasure-wrapper>0.01745329252</IfcPlaneAngleMeasure-wrapper>
    									</ValueComponent>
    									<UnitComponent>
    										<IfcSIUnit id="i1662">
    											<UnitType>planeangleunit</UnitType>
    											<Name>radian</Name>
    										</IfcSIUnit>
    									</UnitComponent>
    								</IfcMeasureWithUnit>
    							</ConversionFactor>
    						</IfcConversionBasedUnit>
    						<IfcSIUnit xsi:nil="true" ref="i1666"/>
    						<IfcSIUnit xsi:nil="true" ref="i1667"/>
    					</Units>
    				</IfcUnitAssignment>
    			</UnitsInContext>
    		</IfcProject>
    		</uos>
    </iso_10303_28>

    Wednesday, April 20, 2016 8:07 AM

Answers

All replies

  • Hello,

    We can use the DataContractSerializer.ReadObject method do the deserialization. The DataContractSerializer.ReadObject method will read the XML stream with an XmlDictionaryReader and returns the deserialized object.

    For the detailed information and example about how to use deserialize the XML using the DataContractSerializer, please try to refer to the following articles:
    https://msdn.microsoft.com/en-us/library/ms752244(v=vs.110).aspx .
    http://www.kongsli.net/2010/02/01/parsing-xml-using-xmlserializer-or-datacontractserializer/ .
    https://dzone.com/articles/using-datacontractserializer .

    Best Regards,
    Amy Peng

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, April 22, 2016 3:16 AM
    Moderator
  • ok , thanks i reformulate the question:

    Hello.
    I have a xsd and I would like to create the related classes in c # for de-serialization and serialization.
    I would like and this is the problem that the serialization of xml espandesse REF with also nested ID.
    I tried svcutil it puts me the collection of XMLNodes and lxsd.exe ignores me the id and the ref altogether.
    how can I create the typed classes in c # and deserialize expanding the ids and the refs also nested?
    thank you.


    1) which tools should I must use svcutils or xsd.exe
    2) I tried with svcutil but causes me the collections of XMLNodes and not concrete types, maybe I should use xsd.exe and de-serialize with DataContractSerializer?
    I tried everything but I can not.
    thanks

    Tuesday, May 10, 2016 10:21 PM
  • hello.

    i repost there my question because i have some problem with english

    I would deserialize an xsd for the ifc bim industrial standard.
    I have a custom xmlreader that works fine with xsd.exe and i use it for adapt the little errors in different dialect of ifc cad exporters?but  servcutil creates me a code like:

     [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
        [System.SerializableAttribute()]
        [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
        [System.Xml.Serialization.XmlRootAttribute(IsNullable = false)]
        internal partial class uos : object, System.Xml.Serialization.IXmlSerializable, System.ComponentModel.INotifyPropertyChanged
        {
    
            private System.Xml.XmlNode[] nodesField;
    
            private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("uos", "urn:iso.org:standard:10303:part(28):version(2):xmlschema:common");
    
            internal System.Xml.XmlNode[] Nodes
            {
                get
                {
                    return this.nodesField;
                }
                set
                {
                    if ((object.ReferenceEquals(this.nodesField, value) != true))
                    {
                        this.nodesField = value;
                        this.RaisePropertyChanged("Nodes");
                    }
                }
            }
    


    it's not typized what are these XMLNODE[]?
    is possible to insert the types indeed of these xmlnode[] and why doesn't have the correct types?.
    I would use the datacontractserializer because it resolve the ids / refs with the ....

    DataContractSerializer dcs = new DataContractSerializer(typeof(ConsoleApplication31.iso_10303_28), null,
                 int.MaxValue ,
                 false ,
                 true /*preserveObjectReferences : this is where the magic happens */,
                 null );
    


    is possible to resolve the ids / refs with the xsd deserializator in some manner?
    or change the xmlnodes[] to types with srvcutils?

    thanks.

    Friday, July 8, 2016 8:29 AM