The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: xAP and XML


  • Subject: Re: xAP and XML
  • From: Michael McSharry
  • Date: Wed, 17 Mar 2004 18:31:00 +0000

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<DIV><FONT face="Arial" size="2">I'm on
board.&nbsp; I agree that the simple schema accomplishes its
objectives.&nbsp; I also agree that the middleware idea is excellent as
well.&nbsp;</FONT></DIV>
<BLOCKQUOTE>
<DIV>----- Original Message ----- </DIV>
<DIV><B>From:</B> <A title="mph@xxxxxxx"
href="mailto:mph@xxxxxxx";>Mark
Harrison (Yahoo!)</A> </DIV>
<DIV><B>To:</B> <A
title="xAP_developer@xxxxxxx" href="mailto:xAP_developer@xxxxxxx";>xAP_developer@xxxxxxx</A>
</DIV>
<DIV><B>Sent:</B> Wednesday, March 17, 2004 10:11
AM</DIV>
<DIV><B>Subject:</B> Re: [xAP_developer] xAP and
XML</DIV>
<DIV></DIV>
<DIV><FONT face="Arial"
size="2">Michael,</FONT></DIV>
<DIV><FONT face="Arial"
size="2"></FONT>&nbsp;</DIV>
<DIV><FONT face="Arial" size="2">Quite the
opposite.</FONT></DIV><FONT face="Arial"
size="2">
<DIV>The very earliest version of xAP (0.9b) written by yours truly
WAS in XML.... it was quickly abandoned as being too heavyweight a problem
for serial devices.</DIV>
<DIV>&nbsp;</DIV>
<DIV>What we're trying to do is come up with a piece of
"middleware" that will map from xAP to XML and back. The reason
for doing this is to leverage the existing tools that will massage one XML
message into another, and integrate with other things.</DIV>
<DIV>&nbsp;</DIV>
<DIV>There will always be a place for an ultra-light, generic,
open,&nbsp;protocol like xAP...</DIV>
<DIV>&nbsp;</DIV>
<DIV>M.</DIV>
<DIV></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir="ltr">
<DIV>----- Original Message ----- </DIV>
<DIV><B>From:</B> <A
title="mcs101main@xxxxxxx" href="mailto:mcs101main@xxxxxxx";>Michael
McSharry</A> </DIV>
<DIV><B>To:</B> <A
title="xAP_developer@xxxxxxx" href="mailto:xAP_developer@xxxxxxx";>xAP_developer@xxxxxxx</A>
</DIV>
<DIV><B>Sent:</B> Wednesday, March 17, 2004 4:12
PM</DIV>
<DIV><B>Subject:</B> Re: [xAP_developer] xAP and
XML</DIV>
<DIV></DIV>
<DIV><FONT face="Arial" size="2">When I
first looked at XAP a few months back my initial though that for the most
part XAP was a document (message) exchange definition and it would seem
that use of XML would be more mainstream and flexible.&nbsp; I like the
idea of using XML.</FONT></DIV>
<DIV><FONT face="Arial"
size="2"></FONT>&nbsp;</DIV>
<DIV><FONT face="Arial"
size="2">Does&nbsp;the proposal that is being foreshadowed
change the&nbsp;header/body structure of an XAP message or is it one
where tools are being introduced&nbsp; so an XAP
node&nbsp;can&nbsp;translate between XAP schema using&nbsp;XML
technologies?</FONT></DIV>
<BLOCKQUOTE>
<DIV>----- Original Message ----- </DIV>
<DIV><B>From:</B> <A title="patrick@xxxxxxx"
href="mailto:patrick@xxxxxxx";>Patrick
Lidstone (Personal E-mail)</A> </DIV>
<DIV><B>To:</B> <A
title="xAP_developer@xxxxxxx" href="mailto:xAP_developer@xxxxxxx";>xAP_developer@xxxxxxx</A>
</DIV>
<DIV><B>Sent:</B> Wednesday, March 17, 2004 6:44
AM</DIV>
<DIV><B>Subject:</B> [xAP_developer] xAP and
XML</DIV>
<DIV></DIV><TT>Edward and myself have had a bit of
discussion off-list about the use ofXML, XSDs and XSLTs with xAP, and the
results are quite interesting so Ithought it might be worth a post here.
For those not familiar with thetechnology, XML is basically a
"document" (message), XSD's are a grammarfor documents, allowing
validation or composition of a document in agiven structure (schema), and
XSLT's can be applied to XML to changetheir appearance (make a mapping).xAP
control often seems to centre around receiving a message from onedevice,
extracting a value (perhaps conditionally), and then passingthat on in a
different schema to another device. XML and XSLT make thisparticularly
easy, without the need to write "real" code, and thevarious
framework developers (OK Stuart, and me, to a lesser extent)could
potentially expose a transformation framework to third party usersif there
was sufficient interest.Edward has also invested a whole lot of time in
writing an XSD toval
idate xAP messages. I'll leave it to him to upload this to the filesarea.In
the meantime, here is a quick summary of how you can use the processto do
mapping from one form to another. Although not included in thisexample,
it's possible to make individual mappings conditional, and todo basic
formatting/processing on them at mapping time. I'm quiteexcited by the
potential of this technology!Any comments/feeback/thoughts most
welcome!Patrick--- XSLT example ---The first thing I have done is written a
simple parser which convertsany xAP message into XML. Nice and easy. For
example, this message:xap-header { v=12 hop=1 uid=FF123400
class=xap-x10.request source=acme.my.controller target=rocket.cm12u.home
}xap-x10.request { command=off device=E1 } Looks like this in XML:<?xml
version="1.0"?><xapmsg> <section
name="xap-header">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <item
name="v"
value="12"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
; <item name="hop"
value="1"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="uid"
value="FF123400"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="class"
value="xap-x10.request"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="source"
value="acme.my.controller"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="target"
value="rocket.cm12u.home"/></section><section
name="xap-x10.request">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="command"
value="off"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<item name="device"
value="E1"/></section></xapmsg>By applying a
stylesheet to this XML, we can transform the originaldocument (message)
into anything we want. This is really nice - it'srelatively easy to apply
complex lo
gic to the message, and could formthe basis of a nice rules engine - but in
this case all we want to do ismap my X10 schema to another
"random" schema message.Here is a simple example XSLT just to
give a flavour. The first bitcopies the header verbatim, the second bit
remaps the "command=off" bitto a new field called value which is
represented numerically (0=off).------------------<?xml
version="1.0"?><xsl:stylesheet xmlns:xsl="<A
href="http://www.w3.org/1999/XSL/Transform";>http://www.w3.org/1999/XSL/Transform</A>"version="1.0"><xsl:template
match="/"><xapmsg><xsl:copy-of select=
"/xapmsg/section[@name='xap-header']" /><section
name="another-message"><xsl:if
test="//section[@name='xap-x10.request']/item[@name='command']/@value=
'off'"><xsl:element
name = "item"
>name='value'value='0'</xsl:element></xsl:if><xsl:if
test="//section[@name='xap-x10.request']/item[@name='command']/@value=
'on'"><xsl:element name = "item"
>name='value'value='1'</xsl:element></xsl:if></section></xapmsg></xsl:template>--------------------The
bits with // and @'s in them are xpath expressions. They selectvalues from
the original document, in much the same way you navigate adirectory
structure. For example //section[@name='xyz'] searches for anyoccurence of
an element called "section" which has an attribute
"name"of value "xyz" (ie. <section
name='xyz'>)The resulting XML output looks like this:<?xml
version="1.0"
encoding="UTF-16"?><xapmsg><section
name="xap-header"><item name="v"
value="12" /><item name="hop" value="1"
/><item name="uid" value=&
quot;FF123400" /><item name="class"
value="xap-x10.request" /><item name="source"
value="acme.my.controller" /><item name="target"
value="rocket.cm12u.home" /></section><section
name="another-message"><item>name='value'value='0'</item></section></xapmsg>This
can in turn be translated back into a "real" xAP message
(usingXSLT again, but that's not really important)xap-header { v=12 hop=1
uid=FF123400 class=xap-x10.request source=acme.my.controller
target=rocket.cm12u.home }another-message{ value=0}
</TT></BLOCKQUOTE></BLOCKQUOTE>




xAP_Development Main Index | xAP_Development Thread Index | xAP_Development Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.