Browse Source

----------------------------------------------------------------------

Modified Files:
 	Utility.py
        XMLSchema.py -- just moved SplitQName out of here and into Utility


 Added Files:
 	Namespaces.py -- WSDL, SOAP, SCHEMA, XMLNS namespaces here.  Doesn't
           require PyXml

 ----------------------------------------------------------------------
main
Joshua Boverhof 21 years ago
parent
commit
fe34384d6a
3 changed files with 61 additions and 37 deletions
  1. +31
    -0
      Namespaces.py
  2. +28
    -4
      Utility.py
  3. +2
    -33
      XMLSchema.py

+ 31
- 0
Namespaces.py View File

@@ -0,0 +1,31 @@
#! /usr/bin/env python
"""Namespace module, so you don't need PyXML
"""

try:
from xml.ns import SOAP, SCHEMA, WSDL, XMLNS
except:
class SOAP:
ENV = "http://schemas.xmlsoap.org/soap/envelope/"
ENC = "http://schemas.xmlsoap.org/soap/encoding/"
ACTOR_NEXT = "http://schemas.xmlsoap.org/soap/actor/next"

class SCHEMA:
XSD1 = "http://www.w3.org/1999/XMLSchema"
XSD2 = "http://www.w3.org/2000/10/XMLSchema"
XSD3 = "http://www.w3.org/2001/XMLSchema"
XSI1 = "http://www.w3.org/1999/XMLSchema-instance"
XSI2 = "http://www.w3.org/2000/10/XMLSchema-instance"
XSI3 = "http://www.w3.org/2001/XMLSchema-instance"
BASE = XSD3

class WSDL:
BASE = 'http://schemas.xmlsoap.org/wsdl/'
BIND_HTTP = 'http://schemas.xmlsoap.org/wsdl/http/'
BIND_MIME = 'http://schemas.xmlsoap.org/wsdl/mime/'
BIND_SOAP = 'http://schemas.xmlsoap.org/wsdl/soap/'

class XMLNS:
BASE = "http://www.w3.org/2000/xmlns/"
XML = "http://www.w3.org/XML/1998/namespace"
HTML = "http://www.w3.org/TR/REC-html40"

+ 28
- 4
Utility.py View File

@@ -10,18 +10,42 @@
ident = "$Id$"

import types
import string, httplib, smtplib, urllib, socket, weakref
import xml.dom.minidom
from string import join, strip, split
from UserDict import UserDict
from StringIO import StringIO
import xml.dom.minidom, weakref

import string, httplib, smtplib, urllib, socket
from TimeoutSocket import TimeoutSocket, TimeoutError
from StringIO import StringIO
from urlparse import urlparse
from httplib import HTTPConnection, HTTPSConnection
from exceptions import Exception

try:
from xml.dom.ext import SplitQName
except:
def SplitQName(qname):
'''SplitQName(qname) -> (string, string)
Split Qualified Name into a tuple of len 2, consisting
of the prefix and the local name.
(prefix, localName)
Special Cases:
xmlns -- (localName, 'xmlns')
None -- (None, localName)
'''
l = qname.split(':')
if len(l) == 1:
l.insert(0, None)
elif len(l) == 2:
if l[0] == 'xmlns':
l.reverse()
else:
return
return tuple(l)

class RecursionError(Exception):
"""Used to indicate a HTTP redirect recursion."""
pass


+ 2
- 33
XMLSchema.py View File

@@ -16,40 +16,9 @@ ident = "$Id$"

import types, weakref, urllib, sys
from threading import RLock
try:
from xml.ns import XMLNS
except ImportError:
# ref:
# http://cvs.sourceforge.net/viewcvs.py/pyxml/xml/xml/ns.py?view=markup
class XMLNS:
"""XMLNS, Namespaces in XML

XMLNS (14-Jan-1999) is a W3C Recommendation. It is specified in
http://www.w3.org/TR/REC-xml-names
BASE -- the basic namespace defined by the specification
XML -- the namespace for XML 1.0
HTML -- the namespace for HTML4.0
"""

BASE = "http://www.w3.org/2000/xmlns/"
XML = "http://www.w3.org/XML/1998/namespace"
HTML = "http://www.w3.org/TR/REC-html40"

from Utility import DOM, DOMException, Collection
from Namespaces import XMLNS
from Utility import DOM, DOMException, Collection, SplitQName
from StringIO import StringIO
try:
from xml.dom.ext import SplitQName
except ImportError, ex:
def SplitQName(qname):
l = qname.split(':')
if len(l) == 1:
l.insert(0, None)
elif len(l) == 2:
if l[0] == 'xmlns':
l.reverse()
else:
return
return tuple(l)

def GetSchema(component):
"""convience function for finding the parent XMLSchema instance.


Loading…
Cancel
Save