1

could anyone suggest some tools that generate code file for visiting models defined in XML schema?

Ideally it should generate a streaming XML parser that reads input XML and calls methods like visitMyModelElement() once it finds MyModelElement. Then I'd just fill blank methods and will have my "mapper" code.

It was a short version, and I'll try to describe the background. I am thinking how should we approach yet another tree-to-tree mapping problem: https://gis.stackexchange.com/questions/1879/how-to-convert-gml-to-features-in-arcobjects

-- I took a look at the 'best practices of best practicioners' just to recall that OutOfMemoryException some night at some BigCustomer will happen if we go after them. Are there bettter-than-better practices around?

(I will write more info if my question was not clear enough)

Community
  • 1
  • 1
Remigijus Pankevičius
  • 1,052
  • 1
  • 12
  • 23

1 Answers1

2

Not exactly the answer to your question, but it is definitely solveable on Java with JAXB plus JAXB plugins. JAXB has a schema compiler (XJC) which compiles XML schemas into Java classes with annotations. XJC from JAXB reference implementation can be extended with plugins which can generate some additional code. I wrote a number of plugins for XJC, so I'd state that generating visitor pattern code is not a big deal.

However I don't think that a classic visitor pattern is a right approach here. With OGC schemas you can easily land with several hundres when not thousands "visit" methods, so it might not actually help.

Next, I am really not sure if this is the right approach to your core task. I think a visitor would not really ease things but make them mor cumbersome. I'd go for manual processing of the unmarshalled objects. On .Net I'd use one of the XSD tools to create XML/Object mappings and then write processing of the unmarshalled objects into ArcObjects manually.

By the way, here's a GML parser/serializer I've implemented based on JAXB-generated code. It converts between GML and JTS geometries. (JTS stands for Java Topology Suite, one of the popular APIs for geometries.) This is almost the same thing that you want, but for Java/JTS instead of .Net/ArcObjects.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • Thanks for suggestions. I'll take a look at your parser/serializer maybe this week. – Remigijus Pankevičius Feb 27 '12 at 06:41
  • I generated that static C# classes with xsd.exe. And got 1.2 MB file. Nice. Now there is another tree: ArcObjects geometry model. It looks quite a daunting task to make this mapping (and opposite too). Therefore I wanted to check how other guys do such tasks. – Remigijus Pankevičius Feb 27 '12 at 06:43
  • I just wanted to say '@lexicore this code looks clever and kind a part of problem is solved for me. btw do you know that guy aleksei? i want to ask him a question how he manages oversee so many xsd-schemas. manually or automatically?'. But just looked at your profile. You are that guy. Right? – Remigijus Pankevičius Feb 27 '12 at 20:39
  • Yes, I am that guy. I'm not sure I got your question. I believe you mean my "OGC Schemas and Tools Project". I don't really "manage" these schemas, I just compiled them with JAXB. And yes, this was quite an effort. Feel free to contact me via valikov(#)gmx.net if there's anything specific you'd like to know. – lexicore Feb 27 '12 at 21:45
  • OK, Alexei, I saw what you mean "quite and effort" from this [dashboard](http://confluence.highsource.org/display/OGCS/Schemas). I am not interested in compiling schemas, I can read help. I am interested in estimating efforts needed on mapper code when standards change (a new version). Thanks for contact I'll contact when I'll have something to show to you. – Remigijus Pankevičius Feb 28 '12 at 08:11