xsvalXmlIf.py
Go to the documentation of this file.
00001 #
00002 # minixsv, Release 0.9.0
00003 # file: xsvalXmlIf.py
00004 #
00005 # XML interface classes (derived wrapper classes)
00006 #
00007 # history:
00008 # 2007-07-04 rl   created
00009 #
00010 # Copyright (c) 2004-2008 by Roland Leuthe.  All rights reserved.
00011 #
00012 # --------------------------------------------------------------------
00013 # The minixsv XML schema validator is
00014 #
00015 # Copyright (c) 2004-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 from types import TupleType
00042 from ..genxmlif.xmlifApi   import XmlElementWrapper
00043 
00044 
00045 class XsvXmlElementWrapper (XmlElementWrapper):
00046     
00047 #++++++++++++ special XSD validation support ++++++++++++++++++++
00048     def __init__(self, element, treeWrapper, curNs=[], initAttrSeq=1):
00049         XmlElementWrapper.__init__(self, element, treeWrapper, curNs, initAttrSeq)
00050         self.schemaRootNode = None
00051         self.xsdNode = None
00052         self.xsdAttrNodes = {}
00053 
00054     
00055     def cloneNode(self, deep, cloneCallback=None):
00056         return XmlElementWrapper.cloneNode(self, deep, self.cloneCallback)
00057 
00058 
00059     def cloneCallback(self, nodeCopy):
00060         nodeCopy.schemaRootNode = self.schemaRootNode
00061         nodeCopy.xsdNode = self.xsdNode
00062         nodeCopy.xsdAttrNodes = self.xsdAttrNodes.copy()
00063 
00064 
00065     def getSchemaRootNode (self):
00066         """Retrieve XML schema root node which this element node belongs to
00067            (e.g. for accessing target namespace attribute).
00068         
00069         Returns XML schema root node which this element node belongs to
00070         """
00071         return self.schemaRootNode
00072     
00073 
00074     def setSchemaRootNode (self, schemaRootNode):
00075         """Store XML schema root node which this element node belongs to.
00076         
00077         Input parameter:
00078             schemaRootNode:    schema root node which this element node belongs to
00079         """
00080         self.schemaRootNode = schemaRootNode
00081 
00082 
00083     def getXsdNode (self):
00084         """Retrieve XML schema node responsible for this element node.
00085         
00086         Returns XML schema node responsible for this element node.
00087         """
00088         return self.xsdNode
00089     
00090 
00091     def setXsdNode (self, xsdNode):
00092         """Store XML schema node responsible for this element node.
00093         
00094         Input parameter:
00095             xsdNode:    responsible XML schema ElementWrapper
00096         """
00097         self.xsdNode = xsdNode
00098 
00099 
00100     def getXsdAttrNode (self, tupleOrAttrName):
00101         """Retrieve XML schema node responsible for the requested attribute.
00102 
00103         Input parameter:
00104             tupleOrAttrName:  tuple '(namespace, attributeName)' or 'attributeName' if no namespace is used
00105         Returns XML schema node responsible for the requested attribute.
00106         """
00107         try:
00108             return self.xsdAttrNodes[tupleOrAttrName]
00109         except:
00110             if isinstance(tupleOrAttrName, TupleType):
00111                 if tupleOrAttrName[1] == '*' and len(self.xsdAttrNodes) == 1:
00112                     return self.xsdAttrNodes.values()[0]
00113             return None
00114     
00115 
00116     def setXsdAttrNode (self, tupleOrAttrName, xsdAttrNode):
00117         """Store XML schema node responsible for the given attribute.
00118         
00119         Input parameter:
00120             tupleOrAttrName:  tuple '(namespace, attributeName)' or 'attributeName' if no namespace is used
00121             xsdAttrNode:      responsible XML schema ElementWrapper
00122         """
00123         self.xsdAttrNodes[tupleOrAttrName] = xsdAttrNode
00124 
00125 


mavlink
Author(s): Lorenz Meier
autogenerated on Thu Jun 6 2019 19:01:57