XForms/Debugging XForms

(Redirected from XForms/Debugging Tips)

If you are a newcomer to XForms and you are having problems debugging XForms you are not alone. XForms debugging can be tricky especially for newcomers. If you follow the newsgroups on XForms you will see several problems come up frequently.

Common Problems

edit

These problems, roughly sorted in terms of frequency include the following:

  1. Make sure to name your files with the .xhtml extension. Many browsers including FireFox do not look for XML tags in files with the .htm or .html extension.
  2. Problems related to forgetting to associate instance data with a namespace or the default namespace. This can be fixed by adding the xmlns="" parameter to your instance variable
  3. Incorrect or missing namespaces in the body of a document. For example, if the default namespace is html the tag <input> is valid but the browser will look at it as <html:input> not <xf:input>. This happens frequently when users copy XForms example code from places that use XForms as the default namespace. This is a good reason that tutorial and training developers should not use XForms as the default namespace.
  4. Incorrect binding between the model and the view. This usually occurs because the "ref" or "nodeset" attributes are not correctly defined or that the group or repeat changes the path prefix of a data element.
  5. Failure to bind to the form to the instance because the XForms processor cannot find one or more instance specific namespaces. If you have customised your XForm with an XSLT or an XQuery before streaming it to your user, the processor might relegated the declaration of some of your namespaces to the instance where they first occur because it treats the contents of the ref and bind attributes on your xform as just content. However, your XForms processor probably expects the definition of the namespaces in your ref attributes to be on the parent axis and may not look in the model instances for any declarations. When this happens you will need to manually construct the root xhtml:html node, explicitly declaring any namespaces that appear in your form.

Using an XForms Validator

edit

Some people have found this XForms validator helpful:

http://xformsinstitute.com/validator

This program will find common errors in XForms examples.

Using Eclipse to validate XPath

edit

There is a nice eclipse plugin for XSLT providing also an XPath validation "view". See: http://wiki.eclipse.org/XSLT_Project

Debugging Tools for Firefox

edit

One of the most useful Firefox extensions is the XForms Buddy debugger. This tool allows you to visually inspect all of the instances in the model while the XForms are running in the Firefox browser. This is especially useful for ensuring that instance values that are dynamically configured are correctly set by the XForms. The link to the site is: here

Printing your Bindings Using JavaScript

edit

There is also a way to visually view your binding from within your JavaScript code.

These interfaces are documented here:

nsIXFormsAccessors

Mozilla Debugging Tips

edit

Here are some suggestions for people that are debugging XForms:

Mozilla XForms Troubleshooting page

Testing Submissions

edit

Sometimes when you are creating complex submissions to web services you need to make sure that what the XForms application is generating is exactly what the web service is expecting. Sometimes a web service vendor will provide a sample web forms client that correctly calls their service but the documentation on calling that service is somewhat lacking. One solution to this problem it to watch the HTTP packets leave the working application and compare them with the HTTP packets with your XForms. This can be done using an HTTP proxy tools such as Charles which also runs as a Firefox extension.

The "network" tab of standard web development debuggers, like Firebug and Google Chrome Javascript Console can be used to watch incoming and outgoing network traffic to and from the browser, allowing you to verify that the content of submissions, their methods, and HTTP error codes are what would be expected.

Using an HTTP Proxy With Firefox

edit

A Proxy is a tools that "stands in" for a web server. It puts itself in between your web browser and the server and tells you what the browser just sent to the web server. To do this you have to set your web browser to use the proxy (by telling it to forward everything to another IP address) and the proxy then forwards it to the service.

When you are finished using the proxy, make sure you remember to disable the proxy by going to the Firefox Tools/Options/General/Connection Settings and click the Direction Connection to the Internet. If you do not your web browser will no longer function when Charles or Tamper Data shuts down.

Debugging WebDAV and Subversion

edit

There are some XForms that are designed to use HTTP put, HTTP post and [w:WebDAV:WebDAV]. The WebDAV allows you to store not just the first version of a form but go back and see prior versions. Subversion FAQ [1] suggests you run the Wireshark packet sniffer and look at the data in the HTTP messages.

Verifiying that a file is well-formed

edit

To verify that a data file is well formed, you can use the RUWF (Are you well-formed)? The XML Syntax Checker

Setting Mime-type in Internet Explorer Version 6.0

edit

Some versions of IE 6.0 do not have the correct mime-type set for IE6. TO fix this you must add an entry to the Microsoft Windows Registry:

Open the Command Shell Enter the command "regedit"

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/xhtml+xml]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
"Extension"=".xhtml"

Discussion

edit
Next Page: XForms | Previous Page: Intalio Form Designer
Home: XForms