Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second item in collection won't get deserialized #273

Open
frankhommers opened this issue Jul 26, 2021 · 7 comments
Open

Second item in collection won't get deserialized #273

frankhommers opened this issue Jul 26, 2021 · 7 comments

Comments

@frankhommers
Copy link

I have put the example code and used XSD's in this zip file:

Example.zip

XmlSchemaClassGeneratorExample.csproj is the generator for the code.
XmlSchemaClassGeneratorUseGenerated.csproj is the project which uses the generated code.

In project XmlSchemaClassGeneratorUseGenerated.csproj I deserialize:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs/2.0" version="2.0.0" service="WFS" count="300" >
   <wfs:Query typeNames="islands" srsName="EPSG:4326">
      <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">
         <fes:And>
            <fes:Or>
               <fes:PropertyIsLike escapeChar="\" singleChar="_" wildCard="%">
                  <fes:ValueReference>_key</fes:ValueReference>
                  <fes:Literal>%ISLAND</fes:Literal>
               </fes:PropertyIsLike>
               <fes:PropertyIsLike escapeChar="\" singleChar="_" wildCard="%">
                  <fes:ValueReference>_key</fes:ValueReference>
                  <fes:Literal>%ISLE</fes:Literal>
               </fes:PropertyIsLike>
            </fes:Or>
            <fes:Intersects>
               <fes:ValueReference>_geometry</fes:ValueReference>
               <gml:Polygon srsName="urn:ogc:def:crs:EPSG::4326">
                  <gml:exterior>
                     <gml:LinearRing>
                        <gml:posList srsDimension="2">51.54466944888950053 4.0634507076977302 51.5539658802964027 4.06233249515291028 51.5560068508855025 4.08334931092553965 51.54611787831689895 4.09453962326862975 51.54005270284209672 4.07558429886301976 51.54203343526010173 4.06388044468392007 51.54203343526010173 4.06388044468392007 51.54466944888950053 4.0634507076977302</gml:posList>
                     </gml:LinearRing>
                  </gml:exterior>
               </gml:Polygon>
            </fes:Intersects>
         </fes:And>
      </fes:Filter>  
   </wfs:Query>
</wfs:GetFeature>

But the second fes:PropertyIsLike (%ISLE) isn't deserialized into the object.
Setting the GenerateComplexTypesForCollections to false also results in uncompilable code.

Is it a setting or a bug?

@mganss
Copy link
Owner

mganss commented Jul 26, 2021

The latest version sort of fixes this. You'll probably have to set GenerateInterfaces to false, too. By sort of I mean there are scenarios where it doesn't work but it seems to work with this schema.

@frankhommers
Copy link
Author

This works. But I am now using a NamespaceProvider. And that seems to exclude the Intersects XmlNode. I will try to isolate the issue.

@frankhommers
Copy link
Author

I can't isolate that issue yet. But I have found another one.

Can you explain why:

        [System.Xml.Serialization.XmlElementAttribute("And", Type=typeof(BinaryLogicOpType), Namespace="http://www.opengis.net/fes/2.0")]
        [System.Xml.Serialization.XmlElementAttribute("Or", Type=typeof(Or), Namespace="http://www.opengis.net/fes/2.0")]

The Or gets the name Or. But And gets BinaryLogicOpType, which seems faulty.

Or should I open a new issue for that?

@mganss
Copy link
Owner

mganss commented Jul 27, 2021

Both Or and And are (possible) root elements. There can be only one XmlRootAttribute on a class. That's why the Or class is an empty class that derives from BinaryLogicOpType.

@frankhommers
Copy link
Author

Wouldn't it be possible to choose And as a name for And.
What would be best in this case is:

BinaryLogicOpType would become an abstract class.

And and Or would both derive from that.

There are more similar example of this happening on other classes... I can point them out if you like, hopefully this can be improved...

mganss pushed a commit that referenced this issue Aug 5, 2021
@mganss
Copy link
Owner

mganss commented Aug 5, 2021

I made And and Or both get their individual classes which derive from BinaryLogicOpType. Couldn't make it abstract because there may also be non-root elements which don't get individual classes that reference the base class.

Now your example works nicely AFAICT.

@frankhommers
Copy link
Author

I'll report back soon. I guess in a week or two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants