Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Benefits of XML/XSL rules/templates
Benefits of XML/XSL rules/templates [message #1717349] Fri, 11 December 2015 23:33 Go to next message
John Cocula is currently offline John CoculaFriend
Messages: 21
Registered: June 2015
Junior Member
I see the nice new rule engine has a preference for JSON encoding, which is undoubtedly valuable (UIs for example), but I think if there were an XML schema and transport for rules, there would be benefits.

Any XML document could be a source to generate rules. Rule templates would be represented as XSL transforms to produce XML documents in the accepted rule schema. Rules could be generated from potentially complex configuration data in XML files, simplifying the process of having rules match the real world configuration.

Of course all of this could be done external to ESH and then converted to JSON as the last step, but it would have value to have a published schema and benefit from XML/XSL transformations.
Re: Benefits of XML/XSL rules/templates [message #1717535 is a reply to message #1717349] Mon, 14 December 2015 15:36 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Hi John,

I think there is a lot of dispute whether or not XML is a superior format over JSON. Smile
We have decided to go for JSON as a parser implementation, because this is what we needed for the REST API anyhow.
Note that we created an architecture that allows for other serialization formats as well - all you would have to do is to implement an implementation for this interface: https://github.com/eclipse/smarthome/blob/master/bundles/automation/org.eclipse.smarthome.automation.api/src/main/java/org/eclipse/smarthome/automation/parser/Parser.java
So yes, if anybody feels XML is important, PRs for additional parsers are always welcome!

Btw, I think neither JSON nor XML is nice for manually writing it; For authoring rule templates, we should probably rather come up with some DSL or a nice user interface (which then again is likely to directly produce JSON).

Regards,
Kai
Re: Benefits of XML/XSL rules/templates [message #1717537 is a reply to message #1717349] Mon, 14 December 2015 15:37 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 42
Registered: July 2009
Member
Hi John,

I think there is a lot of dispute whether or not XML is a superior format over JSON. :)
We have decided to go for JSON as a parser implementation, because this is what we needed for the REST API anyhow.
Note that we created an architecture that allows for other serialization formats as well - all you would have to do is to implement an implementation for this interface: https://github.com/eclipse/smarthome/blob/master/bundles/automation/org.eclipse.smarthome.automation.api/src/main/java/org/eclipse/smarthome/automation/parser/Parser.java
So yes, if anybody feels XML is important, PRs for additional parsers are always welcome!

Btw, I think neither JSON nor XML is nice for manually writing it; For authoring rule templates, we should probably rather come up with some DSL or a nice user interface (which then again is likely to directly produce JSON).

Regards,
Kai
Re: Benefits of XML/XSL rules/templates [message #1717548 is a reply to message #1717537] Mon, 14 December 2015 16:27 Go to previous messageGo to next message
John Cocula is currently offline John CoculaFriend
Messages: 21
Registered: June 2015
Junior Member
Quote:
I think there is a lot of dispute whether or not XML is a superior format over JSON. Smile

Of course the answer depends on the surrounding components, and for REST and UIs I imagine JSON is just simpler to deal with. And the last thing I want to do is flame about this format vs. that format.

I wanted to draw attention to the rich set of XML tools that have been around longer than JSON for validating and transforming structured information, and why there is value in leveraging those things instead of rolling out a custom templating/transformation engine, or hand-validating structural correctness. One could achieve a lot more openness, I believe, by using these tools instead of hand-rolling domain-specific workalikes.

Quote:

Note that we created an architecture that allows for other serialization formats as well - all you would have to do is to implement an implementation for this interface:
https://github.com/eclipse/smarthome/blob/master/bundles/automation/org.eclipse.smarthome.automation.api/src/main/java/org/eclipse/smarthome/automation/parser/Parser.java


I had read that interface and it seems some what tied to JSON already, in that this line of the interface has a hardcoded "json" constant in it. In other words, there is not full separation of the model from serialization/deserialization methods in the current code.

Quote:

So yes, if anybody feels XML is important, PRs for additional parsers are always welcome!

Btw, I think neither JSON nor XML is nice for manually writing it; For authoring rule templates, we should probably rather come up with some DSL or a nice user interface (which then again is likely to directly produce JSON).


+1
Re: Benefits of XML/XSL rules/templates [message #1717552 is a reply to message #1717548] Mon, 14 December 2015 16:42 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Quote:
in that this line of the interface has a hardcoded "json" constant in it.


Well, this line is exactly there to indicate that there can be others in future Smile
So it is waiting to be accompanied by
public static String FORMAT_XML = "xml";


Re: Benefits of XML/XSL rules/templates [message #1717555 is a reply to message #1717552] Mon, 14 December 2015 17:15 Go to previous message
John Cocula is currently offline John CoculaFriend
Messages: 21
Registered: June 2015
Junior Member
Oh, I see now; I did not expect the interface to hold that sort of information. Thanks for explaining.
Previous Topic:Channel with "advanced property"
Next Topic:Use URL to manipulate items
Goto Forum:
  


Current Time: Fri Apr 19 06:28:56 GMT 2024

Powered by FUDForum. Page generated in 0.23434 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top