Recovered and moving on

Well, the weekend was enough time for me to recover from the extreme frustration I experienced on Friday, and I’m happy to say that my xforms are now being called by a password protected xquery.

As mentioned in my last post the big hang up was the mime type (declared in the HTTP header) for the xforms, it has to be application/xhtml+xml (which by the way IE 6 does not support). I had already written a very simple xquery and then transformed the data with an XSL stylesheet. However when I tried the transform:stream-transform using this xquery and stylesheet I had no luck forcing the HTTP header to output the correct mime type. So, much to my disappointment, I ended up having to write the entire xform in xquery. There really isn’t any drawback to this other than that I’m much more comfortable coding with XSL than xquery. The forms are working and are now password protected, so I’m feeling pretty good about that. I can continue research into the problematic mime types at a later date if I really want to go back to using XSL.

So what I have ended up with is one long xquery that authenticates the user and then initiates the various pieces of the metadata processing interface. All portions of the interface are called by different functions in this xquery, which has allowed me to learn user defined xquery functions without to much pain, as I had originaly written all of these as separate xqueries. For this xquery I defined each action (for example: view metadata queue, create new collection and edit records) as a separate function and then call them from a main function which first tests for session authentication and if it doesn’t find it presents the user with a log-on screen.

I’m feeling pretty good about my new understanding of user created functions, and may be ready to try something a little more complex, like recursive functions.

Here is the short list of resources I found most useful for learning functions, and also for writing and troubleshooting my xforms:

Xquery Functions (

A “how to” for xforms (

WC3 intro to xforms (

And the eXist listserv archives (actually there seems to be a lot of talk on the listserv just in the past few weeks about eXist and xforms).

I also have a rudimentary page turning application up and running, more about that later.

Update:  I just wanted to clarify where the problem with the mime-type was cropping up. As one commenter noted it is possible to change the mime type in eXist with declare option exist:serialize “method=xhtml media-type=application/xhtml+xml”; which is what I ended up using for my xquery based xform. I had originally tried to transform the output from this xquery this with an xsl stylesheet, and this is where I “lost” the application/xhtml+xml mime type. I also had an xsl:output statement in my xsl stylesheet that looked like this: <xsl:output omit-xml-declaration=”yes” encoding=”UTF-8″ method=”xhtml” indent=”yes” media-type=”application/xhtml+xml”>. I retrieved two different results. When I used transform:transform which goes through eXist I returned the correct mime type, but could not get my namspace declarations into the html tag and when I used transform:stream-transform, which bypasses eXist, I had all the correct namespaces in my html tags but the mime type was text/html. I’m guessing the problem lies in a default output for eXist and perhaps Tomcat.


4 Responses to “Recovered and moving on”

  1. Erik Bruchez Says:

    I assume you mean that the type has to be “application/xhtml+xml”.



  2. wsalesky Says:

    Thanks for catching that typo Erik. The mime type is indeed supposed to be application/xhtml+xml.

  3. Chris Wallace Says:

    I’ve been using eXist for over a year now on a faculty information system and am still learning how to do things – the main public site is over at and there is a growing set of documented examples at

    I’ve not got as far with Xforms as you but I do generate output with different MIME types – for example GoogleEarth’s kml – sometimes these include XML which has been generated by transform() but in any case, the mime type is set in the XQuery declare option serialize statement, so there is no reason why you shouldn’t use XSL for xforms generation that I can see. e.g.

    declare option exist:serialize “method=xhtml media-type=application/xhtml+xml”;


  4. wsalesky Says:

    Hi Chris,
    I did try using the declare option exist:serialize “method=xhtml media-type=application/xhtml+xml”; (and this is what I do with my xquery based xforms). However, when I transformed this using xsl I was getting an html mime type as output, inspite of declareing the correct mime type in the xsl output element as well. Perhaps I will need to revisit my code.

Comments are closed.

%d bloggers like this: