Quantcast
Viewing all articles
Browse latest Browse all 935

XML Reader nullable nodes

Image may be NSFW.
Clik here to view.
You cannot vote on your own post
           

Querie for C# forum.   Now posted on XML forum.  Any help welcomed...

I am updating a C# program that uses xmlreader /xmlwrite to serialise the file.

I have a lidtype that is nullable and it works okay  the inlet fails.

   ///<remarks/>

   [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]

   public System.Nullable<stormwater_pit_lid_type> LidType {

       get {

           returnthis.lidTypeField;

       }

       set {

           this.lidTypeField = value;

       }

   }

publicpartialclass Feature_StormWater_Pit : asset_abstract {

   

   

   private System.Nullable<stormwater_pit_lid_type> lidTypeField;

   privateFeature_StormWater_PitInlet inletField;

   

   privateFeature_StormWater_PitLintel lintelField;

}

Now the lidtype works fine and the null entires seem to be okay.

The inlets are structs in C++ terms…. How can I make them nullable.

publicpartialclass Feature_StormWater_PitInlet {

   

   privatestormwater_pit_inlet_config inletConfigField;

   

   privatestormwater_pit_inlet_type inletTypeField;

   

   ///<remarks/>

   publicstormwater_pit_inlet_config InletConfig {

       get {

           returnthis.inletConfigField;

       }

       set {

           this.inletConfigField = value;

       }

   }

   

   ///<remarks/>

   publicstormwater_pit_inlet_type InletType {

       get {

           returnthis.inletTypeField;

       }

       set {

           this.inletTypeField = value;

       }

   }

}

When the xmlreader serialises this the reader is okay if the fields are all included. However the inlet may not be coded and is code as

<Inletxsi:nil="true"/>

<lintel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true">

<Lintelxsi:nil="true"/>

</lintel>

Error no = Cannot add a SimpleContent column to a table containing element

columns or nested relations..

Is there any tricks in getting the structure to be nullable.

With thanks

After C# comments more background from C# post

Thanks for the comments. I am repairing code on a project and this code comes from the xmlreader generated code. The XSD that defines the schema has been defined by the ADAC committee and can't be changed. The data submitted by an external organisation fits the schema but fails in this program. There are close to 1000 fields so it maybe a duplication as you suggest.  I just have to find a solution without changing the xsd and data.

Worse is that there are two xml reader sections in this program to be repaired. One for the first file read and another for subsequent reading of an additional file(merge operation). The second treats the objectid in a different manner. The second reader works and the first fails on the null objects in the inlet node. How do I track down the XMLnode. Seems like he has used XMLDocument. So I am going back to read the initial sample xml reader code today from Microsoft.

The problem defined in the schema: If you have an inlet then you have a inlet type and a linlet material, otherwise you have no inlet (and the field is null). So the inlet can be nullable. The inlet allows water to enter the pit. If the inlet exist it must have an inlet type and property. If it is a closed pit it has no inlet and just a lid on the pit. Thats the definiton in
the schema. The definition looks okay.  So the generated xmlreader seems to set up the classes okay.

So the C# code has been generated and maybe hand massaged. I tried making the inlet nulable but it said it couldn't be nullable. So I pulled out the bit of the code to have as a talking point.

Your answer is similar to the vague answers in the microsoft help. So it is probably right. Maybe there is an inlet for stormwater and an inlet for sewerage that are similar and have been defined either as global or as a child off the tree. The stormater pipe system handles the drainage. The sewerage pipes handle the sewers. We have them as separate systems and separate object types.  The physical world and schema agree.

I have tried for a day to ferret out the changes and can see how part of the xmlreader works.  Global look for inlet and work through the locations.  Do I need to start from scratch with the XMLreader and do a simple case first....

Thanks again for your help


John Keays


John Keays


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>