XML plugin 1.0b1 released

Today we released the first public beta of our XML plugin.

The XML plugin allows you to do things like:

  • Create an XML document (object) from an XML file, a URL or from a Servoy record or foundset. You can also start with an empty XML document and add elements yourself.
  • Parse XML content inside Servoy
  • Support for namespaces, comments and attributes
  • Includes a recordFormatter class that will properly encode a Servoy record for XML use (formats dates, numbers and media content). The recordFormatter can also re-create an array from XML data, where the correct data type will be returned (so for example a base64 encoded media content inside the XML will be returned as a byte array)
  • Support for xsl transformation that allows you to format XML content using a style sheet and properly output the XML in HTML
    Besides the possibility to create and parse any XML document, the plugin can also create XML from Servoy records and foundsets including related data if needed. A simple call like
var vRelations = new Array('relation1', 'relation2');
var vFoundsetXml = plugins.XML.XMLDocument(foundset, vRelations);

can create an XML document like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<table name="data">
  <formatting>
    <DATE>dd.MM.yyyy</DATE>
    <DATETIME>dd.MM.yyyy HH:mm</DATETIME>
    <DATETIMESECONDS>dd.MM.yyyy HH:mm:ss</DATETIMESECONDS>
    <NUMBER>#,##0.##</NUMBER>
    <INTEGER>#,###</INTEGER>
    <MEDIA>Base64</MEDIA>
  </formatting>
  <data>
    <record dataid="62">
      <data>
        <text_field type="TEXT">This is just plain text.</text_field>
        <number_field type="NUMBER">23,45</number_field>
        <dataid type="INTEGER">62</dataid>
        <date_field type="DATE">20.05.2006</date_field>
        <integer_field type="INTEGER">1</integer_field>
      </data>
      <relation name="relation1" table="related_data">
        <record related_dataid="1">
          <data>
            <text_field type="TEXT">some text</text_field>
            <number_field type="NUMBER">24,4</number_field>
            <dataid type="INTEGER">62</dataid>
            <related_dataid type="INTEGER">1</related_dataid>
            <date_field type="DATE">20.05.2006</date_field>
          </data>
        </record>
        <record related_dataid="2">
          <data>
            <text_field type="TEXT">some more text</text_field>
            <number_field type="NUMBER">19,8</number_field>
            <dataid type="INTEGER">62</dataid>
            <related_dataid type="INTEGER">2</related_dataid>
            <date_field type="DATE">11.05.2006</date_field>
          </data>
        </record>
      </relation>
    </record>
  </data>
</table>

We use this for example to archive deleted records. When those records have to be recreated, the plugin offers a functionality that allows you the provide the above XML and get an Array with all included data transformed to the data type the field has. This can be done as easy as

// Create an XML document from XML data
var vXml = plugins.XML.XMLDocument(xml_data);
// Get the record element(s)
var vRecords = vXml.getRecordElements();
for ( var i = 0 ; i < vRecords.length ; i++ )
{
	// Get the i-th record element
	var vSingleRecord = vRecords[i];
	// Let the RecordFormatter re-create an object array, where the single fields are returned according to their type
	var vRecordObject = vRecordFormatter.getRecordObject(vSingleRecord, vFormatter);
}

the vRecordObject is a two-dimensional array that contains colum name and the field content either as Text, Integer, Number, Date or Byte Array.

As long as the plugin is in beta testing, please contact me by email if you want to test it.

I forgot to mention: of course you can easily parse RSS feeds with the plugin…

Hi Patrick,

Very nice work, this plugin. Very handy!

Paul

Did I mention that XPath expressions are also supported? :wink:

No, please explain… :D :D :D :D

Paul is doing crazy stuff as

var vXPath = '//parameter[@name=\'P_COMPANYCODE\']'
var vElements = vXml.getElementByXPath(vXPath)

and in 1.0b3 that actually works (so in case you need XPath, send me a mail for the latest version…)!

Hi Patrick,

Where can I download a trial version of this plugin?

Thanks,
Hameed

Hello Hameed,

please send a message to plugins@maison-partner.de.

I will send you a demo then.

BTW: the plugin is not beta anymore…

Hi Patrick,

Thanks for sending me the plugin.

I am trying the following code

//var fileNamePath = "D:/DATA/SERVOY/CLA/Migration/contact.xml";
//var xmlDoc = plugins.XML.XMLDocument(fileNamePath);
var xmlDoc = plugins.XML.XMLDocument(forms.contact$detail.foundset);

application.output(xmlDoc.docType)

the xmlDoc is alway null either I use fileNamePath or a foundset. Any idea?

Thanks

Servoy Developer
Version 3.0rc4-build 368
Java version 1.5.0_06-b05 (Windows XP)

Hi Patrick,

Do you have any idea on that issue? Is that because I am using the latest version of Servoy?

I am eager to get it to work. I need your help.

Thanks a lot,

Hello Hameed,

I think it is best to not use the forum for plugin questions. If you have a problem/question please contact me via plugins@maison-partner.de.

Anyway, your problem seems to be either

  • the plugin is not registered
  • the 30 minutes demo period is over (restart Servoy)

Have a look a the log. Registration issues are written to the log.

Patrick