Google Maps API V3, XSD XML Response

I am trying to parse the google maps XML response using JAXB. It will be very nice to have an XSD file provided by Google. Does anyone know where to get it?

In the absence of an existing xsd, does anyone know why Google will not offer this scheme officially? They themselves probably also use this file at the same time.

thanks user1146450

+4
source share
3 answers

Most likely, my educated guess is that there is no official XSD for what you are looking for; the reason is how the API documentation is written, in particular, that it comes with a preferred processing model that is based on XPath for XML responses.

Google XML is also not typical of a traditional web service described using a combination of WSDL + XSD; it lacks XML namespaces, which violates the WS-I R1014 core profile rule.

As for why, I think your question is ready to get quite personal views on this topic, if you are not lucky to get an answer from an insider ... At that moment I will immediately delete my answer ... Until then, this is my view on that using XSD might not be such a bright idea.

If there was a world in which only a clean XML processing stack would be available for development (e.g. XML, XSLT, etc., XML devices such as Datapower, Forum, Layer 7, etc.), then I I would think an XML schema (XSD or something else) is almost a "crime."

If you use strong typed languages ​​like Java and C #, then you lose the great flexibility that XML brings to the table. XSD was used as the main artifact to facilitate these binding methods; this helped with the implementation of XML, and prevented what I call XML-based processing models, one of which is Google XPath.

If the semantics are tied to XPaths, changes to the existing XML structure needed to accommodate new functions should not matter to the existing processor. But this is where the JAXB and .NET bindings throttle ...

To make this easier, people are starting to use the XSD functions, which are too complex for the average developer, or create XSDs that describe very abstract models. So, now you have a high burning rate, trying to maintain all this ...

It may turn out that for simple structures this can be cheaper in terms of support in order to skip the XSD all together; most people (anyway) want to see a sample XML to understand what XSD is. If the specification owner decides to add new tags wherever he finds it necessary, no one can scream, because extracting XPath-based data will always be impervious to such changes ... Attempting to do this with XSD will either be impossible or very ugly .. .

And in the case of Googles, if most of them are browser-oriented, why worry about β€œhow can I validate XML with javascript?” ... And no one wants server applications to crash every time you need to add a new one tag for XML ... For those who believe that xsd characters are the answer, I argue that this is not always possible (see UPA), or that it affects the clarity of the XSD, or that it actually returns a good XmlNode to the image. ..

To summarize, I believe that the XSD + code bindings (your language is here) in the long run caused more hassle and employment;) - than anything else!

+3
source

I think this will help you. it shows how to use XPath to work with XML in the Google Maps API https://developers.google.com/maps/documentation/webservices/index#ParsingXML

0
source

(for example) You can get the XML request from the geocode, and then paste it into the online XML for the XSD creator. Finally, you need to edit the result to fit different answers (I needed to add the target namespace and minOccurs = "0" maxOccurs = "unbounded" to the element to fit multiple places).

You should get something like this (XSD for the above example)

`https://pastebin.com/iV6w41ye` 
-2
source

Source: https://habr.com/ru/post/1397448/


All Articles