Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:59:32+00:00 2026-06-14T01:59:32+00:00

I am trying to validate some XML via lxml and an xsd (ogckml22.xsd). This

  • 0

I am trying to validate some XML via lxml and an xsd
(ogckml22.xsd). This is happening OFFLINE. I read ther
file via a straight open/read

For the record, http://www.opengis.net/kml/2.2 is not valid.

from another article:
(clarified due to comment request..)

from lxml import etree
import os
import sys
import StringIO
file=open('ogckml22.xsd')
data=file.read()
str=StringIO.StringIO(data)
try:
     xmlschema_doc=etree.parse(data)
except IOError as ex:
    print "oops {0}".format(ex.strerror)
except:
    print "Unexpected error:", sys.exc_info()[0]

xmlschema=etree.XMLSchema(xmlschema_doc)  

All I get is a “connection refused”.
With the try/except, I get the xmlschema_doc is not defined.

File "<stdin>", line 1, in <module>  
File "<xmlschema.pxi",line 105, in lxml.etree.XMLSchema.__init__ (src/lxml/lxml.etree.c:132748  
   self.error_log)  
lxml.etree.XMLSchemaParseError: connection refused  

I know it can read the xsd file above and another xsd file that
gets included.

OK maybe the xsd gets read? I downloaded the source for lxml and in src/lxml/xmlschema.pxi,

if self._c_schema is NULL:
    raise XMLSchemaParseError(
        self.error_log._buildExceptionMessage(
            u"Document is not valid XML Schema"),
        self._error_log)

I never see the “Document is not valid XML Schema” message. I can only assume that “Connection Refused” is used in place of the “Document message” (a default?) but
a more thorough reading of _error_log (outside of recompilation) evades me….

Sincerely,

ArrowInTree

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:59:33+00:00Added an answer on June 14, 2026 at 1:59 am

    ogckml22.xsd imports two other schema documents (atom-author-link.xsd and xAL.xsd):

    <!-- import atom:author and atom:link -->
    <import namespace="http://www.w3.org/2005/Atom" 
            schemaLocation="atom-author-link.xsd"/>
    
    <!-- import xAL:Address -->
    <import namespace="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" 
            schemaLocation="http://docs.oasis-open.org/election/external/xAL.xsd"/>
    

    If you want to parse the schema offline, you need to have both these documents available locally and he paths given by schemaLocation must be correct.

    The parsing and loading of the schema can be simplified (there is no need for StringIO):

    from lxml import etree
    
    xmlschema_doc = etree.parse("ogckml22.xsd") 
    xmlschema = etree.XMLSchema(xmlschema_doc)
    
    print xmlschema
    

    Output:

    <lxml.etree.XMLSchema object at 0x00D25120>
    

    I don’t understand what you mean by “For the record, http://www.opengis.net/kml/2.2 is not valid”.

    If you have internet access, you can use the URL as argument to etree.parse():

    xmlschema_doc = etree.parse("http://www.opengis.net/kml/2.2")
    

    At least this works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to validate this XML file ... where if <tag1> is Y
I'm trying to validate a simple XML file against an XML schema using the
I'm trying to develop a schema that will validate some existing XML files I've
I'm trying to create an xml-schema (xsd) to validate an xmlfile. <a> <b> <c>...</c>
I'm trying to fully validate an xml file which may be published by a
I am trying to use Python and LXML to create an XML file from
I'm trying to validate some form data before adding it to a database however
I'm trying to validate some of the field in my form. and I want
I am trying to validate email using javascript but for some reason it is
I'm trying to validate one xml that I create with a local schema, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.