00001 # 00002 # genxmlif, Release 0.9.0 00003 # file: __init__.py 00004 # 00005 # genxmlif package file 00006 # 00007 # history: 00008 # 2005-04-25 rl created 00009 # 00010 # Copyright (c) 2005-2008 by Roland Leuthe. All rights reserved. 00011 # 00012 # -------------------------------------------------------------------- 00013 # The generic XML interface is 00014 # 00015 # Copyright (c) 2005-2008 by Roland Leuthe 00016 # 00017 # By obtaining, using, and/or copying this software and/or its 00018 # associated documentation, you agree that you have read, understood, 00019 # and will comply with the following terms and conditions: 00020 # 00021 # Permission to use, copy, modify, and distribute this software and 00022 # its associated documentation for any purpose and without fee is 00023 # hereby granted, provided that the above copyright notice appears in 00024 # all copies, and that both that copyright notice and this permission 00025 # notice appear in supporting documentation, and that the name of 00026 # the author not be used in advertising or publicity 00027 # pertaining to distribution of the software without specific, written 00028 # prior permission. 00029 # 00030 # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD 00031 # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- 00032 # ABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 00033 # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 00034 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 00035 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 00036 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 00037 # OF THIS SOFTWARE. 00038 # -------------------------------------------------------------------- 00039 00040 00041 ###################################################################### 00042 # PUBLIC DEFINITIONS 00043 ###################################################################### 00044 00045 00046 # supported XML interfaces 00047 00048 XMLIF_MINIDOM = "XMLIF_MINIDOM" 00049 XMLIF_4DOM = "XMLIF_4DOM" 00050 XMLIF_ELEMENTTREE = "XMLIF_ELEMENTTREE" 00051 00052 # namespace definitions 00053 00054 XINC_NAMESPACE = "http://www.w3.org/2001/XInclude" 00055 00056 00057 # definition of genxmlif path 00058 00059 import os 00060 GENXMLIF_DIR = os.path.dirname(__file__) 00061 00062 00063 ######################################## 00064 # central function to choose the XML interface to be used 00065 # 00066 00067 def chooseXmlIf (xmlIf, verbose=0, useCaching=1, processXInclude=1): 00068 if xmlIf == XMLIF_MINIDOM: 00069 import xmlifMinidom 00070 return xmlifMinidom.XmlInterfaceMinidom(verbose, useCaching, processXInclude) 00071 00072 elif xmlIf == XMLIF_4DOM: 00073 import xmlif4Dom 00074 return xmlif4Dom.XmlInterface4Dom(verbose, useCaching, processXInclude) 00075 00076 elif xmlIf == XMLIF_ELEMENTTREE: 00077 import xmlifElementTree 00078 return xmlifElementTree.XmlInterfaceElementTree(verbose, useCaching, processXInclude) 00079 00080 else: 00081 raise AttributeError, "Unknown XML interface: %s" %(xmlIf) 00082 00083 00084 ######################################## 00085 # define own exception for GenXmlIf errors 00086 # The following errors/exceptions are mapped to a GenxmlIf exception: 00087 # - Expat errors 00088 # - XInclude errors 00089 # 00090 class GenXmlIfError (StandardError): 00091 pass 00092