[Dev OpenGP] [57] re-added xsl processing to OgpElement

[ Thread Index | Date Index | More opengp.tuxfamily.org/development Archives ]


Revision: 57
Author:   nicolaf
Date:     2009-03-18 15:12:03 +0100 (Wed, 18 Mar 2009)

Log Message:
-----------
re-added xsl processing to OgpElement

Modified Paths:
--------------
    trunk/src/lib/ogp/etree/elementmethods.py


Modified: trunk/src/lib/ogp/etree/elementmethods.py
===================================================================
--- trunk/src/lib/ogp/etree/elementmethods.py	2009-03-18 14:10:40 UTC (rev 56)
+++ trunk/src/lib/ogp/etree/elementmethods.py	2009-03-18 14:12:03 UTC (rev 57)
@@ -182,16 +182,26 @@
 				if id is not None:
 					e.set(ATTR_ID, str(int(id) + peerMaxId + 1))
 
-	def toString(self):
-		return tostring(self)
+	def toString(self, xsl=None, params=None):
+		if xsl is None:
+			return tostring(self)
+		else:
+			self.__processXsl(xsl, params)
 
+	def __processXsl(self, xsl, params):
+		transform = XSLT(xsl)
+		if params is None:
+			return str(transform(self))
+		else:
+			return str(transform(self), params)
+
 class OgpXmlError(Exception):
 	def __init__(self, value):
 		assert isinstance(value, str)
 		self.value = value
 	
 	def __str__(self):
-		return repr(self.value)
+					return repr("OgpXmlError: " + self.value)
 
 class OgpElementClassLookup(PythonElementClassLookup):
 	def lookup(self, document, element):


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/