[mythtv] MythXML Changes that may/will break backward compatibility

David Blain MythTv at TheBlains.net
Fri Jan 15 16:21:46 UTC 2010

-=> Summary

The changes I'm making will add the following new support:

	* JSON responses
	* Possible use of returned data in the QT Scripting Engine (haven't
tested, but should work).

-=> The Details

I wanted to remove any XML/Rendering code from the existing MythXML
functions and turn it into a standard API library for retrieving backend
settings/content.  I wanted to maintain the existing formats and allow for
easy addition of future formats without having to modify the actual methods
or returned data classes.

The approach I've taken is to create a Data Transfer Contract (DTC) layer
that defines the way each method returns its data.  These classes are data
only classes and should never have methods added to them.  More classes can
be defined as the need arises.  I wanted to use as much QT support as
possible so I'm leveraging the QT Property System (although I'm finding it
very limited in what I can do with it).

The methods themselves, only need to return a pointer to one of the DTC
classes.  The actual formatting of the response is done by the transport

The Transport layer now uses an instance of a Serializer derived class to
iterate through the object's properties/children and render the proper
syntax. These are the existing Serializer implementations:

	* XmlSerializer
	* SOAPSerializer
	* JSONSerializer

There's no reason other serializer classes couldn't be created for other
formats.  (ie: BinarySerializer - for high performance/small size transfers,
MythSerializer - to try and be compatible with the current myth protocol,

Currently, the concrete serializer chosen for the response is based on how
the request is formatted.

JSONSerializer - if there is an HTTP header of:  "Accept: application/json"
then this class is used.

SOAPSerializer - if the header/body of the request conforms to a SOAP
request, this class is used.

XmlSerializer  - This is the default serializer. 

-=> Backward Compatibility

Since the formatting will now be performed in a generic way, the existing
XML schema was too inconsistent to recreate completely, hence the need to
break backward compatibility.

-=> Scripting

Since the returned data is contained (prior to serialization) in QObject
derived classes with Q_PROPERTY definitions, in theory it should be usable
in any QT Scripts.  Only time and testing will tell.

-=> Timeframe

I would say I'm 75% done with my changes that I would want to commit.  I was
hoping to get it in before the next release, however with the size of the
change I will be waiting until after the next release before committing

David B.

More information about the mythtv-dev mailing list