0

In brief, on one hand, I expect Open GIS’s KML Schema Definition, i.e. ogckml22.xsd, to be rock solid; fully debugged. Likewise, Microsoft.Net’s XSD XML Schema Definition tool (https://docs.microsoft.com/en-us/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) should be equally as solid and fully debugged. Nonetheless, running XSD against ogckml22.xsd generates show-stopper errors. As a beginner, I depend on them to work together. Together, instead, they generate errors that are well above my pay grade! Ouch!

Now the details. In my browser, I open http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd and “save its page” as a local copy of ogckml22.xsd.

In Google Earth, I want to “Get Directions” --- its underlying KML --- for a 356 km, 3 hour 48 min, bus drive from Milan to Florence, Italy. While very nice, the KML is bulky and too big; it is filled with numerous duplicate Styles. To automate its cleanup, I want a Visual Basic.Net parsing tool to itemize all the wasteful duplication. I find an example that uses XmlSerializer and XSD-KML extracted Vb.Net classes.

So, in the .Net console command window, I enter this command

xsd ogckml22.xsd /language:vb /c /o:.

That is, XSD uses my downloaded KML V2.2 Xml Schema Definition to generate a new Vb.Net Classes file, and saves it in the local directory.

I get the errors listed below. Could someone please show me how to generate the classes file without errors? The show stopper is this error: “The element 'http://www.w3.org/2005/Atom:author' is missing.” Because they are minor features, I tried deleting Atom author, link and AddressDetails, but things only got worse. I need help.

Schema validation warning: The 'http://www.w3.org/2005/Atom:author' element is not declared. Line 311, position 12.
Schema validation warning: The 'http://www.w3.org/2005/Atom:link' element is not declared. Line 312, position 12.
Schema validation warning: The 'urn:oasis:names:tc:ciq:xsdschema:xAL:2.0:AddressDetails' element is not declared. Line 314, position 12.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema 'ogckml22'.
  - The element 'http://www.w3.org/2005/Atom:author' is missing.

[MORE Saturday] To my fellow StackExchangers

I have discovered more goodies, but I’m stuck on another bug. Thus I’ve chosen to be terse; I want to inform you just enough so you can try your debugging skills.

On checking again, I found that searching on xsd.exe’s Warning message “Warning: Schema could not be validated” yielded far more fruitful result hits than its Fatal error did.

This hit said “xsd.exe could not follow up on external references”. It recommended “specify all the required XSD files directly on the command line as follows:

 xsd.exe /c MySchema.xsd Import01.xsd Import02.xsd Include01.xsd Include02.xsd”

Another hit --- ChoXsd --- offered a combined GUI-or-command XSD testing tool. In fact, ChoXsd’s download is a Visual Studio solution file, not an exe executable.

I chose to work with ChoXsd because I assumed (naively) that it bundled the multiple xsd-file command line. Importantly, on the ChoXsd webpage, I heeded this concern

Configuration
Open ApplicationSettings.xml file (located in bin\Debug\Config or bin\Release\Config folder), adjust the below items based on your environment
xsdExeFilePath - Path to XSD.exe file. Usually found 'C:\Program      Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools' directory based on the version of VS.NET. 

I changed it to my Visual Studio verson, “NETFX 4.6.1 Tools” Sadly, ChoXsd disappeared in an infinite loop. On running the debugger in the ChoXsdClassGenerator.cs file, the bizarre disappearance occurred on the appSettings instantiation line, which should be a harmless statement:

        public void Generate()
        {
            string xmlTmpFilePath = null;
            try
        {
                ChoAppSettings appSettings = new ChoAppSettings();

I even tried setting Debug->Options->Debugging->Enable .NET Framework source stepping and, it too, disappeared into an infinite loop.

Can you fix, or teach anything more?

  • It looks like you need to fetch some more schemas – Ian Turton Feb 26 at 20:08
1

Looks like you haven't included the Atom namespace in your top KML tag. You'll want it to look something like this:

<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> 

More documentation available here: https://developers.google.com/kml/documentation/kmlreference#sampleattribution

Let us know if you still get errors after adding that.

0

[Mistake. This is Out of Order; It is the 2nd Post. I misunderstood "Add an Answer"]

Pasted below are the top 2 Xml elements of the ogckml22.xsd file. The first one is the Xml element and the second is the Schema element, continued across 7 lines. Notice that the 4th Schema line references your http://www.w3.org/2005/Atom file. There is an Oasis one too on the 5th line. So, sigh, it was already there. Thanks for trying.

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:kml="http://www.opengis.net/kml/2.2"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
  targetNamespace="http://www.opengis.net/kml/2.2"
  elementFormDefault="qualified"
  version="2.2.0">
  • Those namespace declarations need to be in the <kml...> tag, which should come right after the <?xml...> tag... and not in the <schema...> tag that you're showing. – Christiaan Adams Mar 7 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.