Goya Blog
BaseElements on the iPad
Submitted by Nicholas Orr on 20 July 2010 - 9:12amI haven't seen a notice yet about this on FileMaker's site, but I found FileMaker Go for iPhone and iPad in the iTunes store this morning. And what else do I do but test BaseElements 3 on it. First impressions are that it looks good.

There are some font issues and some other formatting strangeness, but it does load and I can click around on things. I did also get some dialogs to display which looked neat.
More to the point though is what we can do with this for clients and remote access to solutions. There is a lot to like, even if this is just the beginning. There is going to be a bit to catch up on about the differences between a full FMP app and the iPhone/iPad app, I'm looking forward to that. I've already got staff saying they need an iPad for testing now :)
Way to make things slow Nick...
Submitted by Nicholas Orr on 16 July 2010 - 3:30pmWho would have thought, recursive XSLT is not only hard to program and make sense of, it's also awful slow.
If you had a play with BaseElements 3 beta 2 in the last few days, grab a copy of b3 today, it's much faster :)
BaseElements_Mac.dmg - fp7 files.
BaseElements_Mac_MU.dmg - Sharing enabled version.
BaseElements_Mac_Runtime.dmg - Runtime.
I've addressed some of the of the processing of filenames which gets me one step closer to a windows release as well.
The only issue to be aware of in this build is that variables used in Calculations aren't being referenced yet. I'm working on some non-recursive xslt instead to make that faster. Also I fixed an issue in calculations where you'd get an error when there was an empty calculation - thanks Doug Rowe for reporting that.
Thanks to all those who sent me notes about their times with b2, if you've got the patience to re-run this now with b3, and compare it to 2.6.7, that would be great. Send any details to
BaseElements 3 Beta 2
Submitted by Nicholas Orr on 14 July 2010 - 9:42pmI've uploaded another beta version of BaseElements 3. I was hoping to have a windows build available as well this time, but it's not to be. There are a whole bunch of path related issues inside the xslt that are causing me grief so I've got to sort out those before it's ready for prime time. In the mean time for those on the mac :
BaseElements 3 Beta 2
Changes since b1
- Fixed display issues on the Variables and File layouts - thanks Steve Wright.
- Fixed an issues with File References used on the right side of Relationships.
- Fixed an issue where processing of items wasn't always happening.
- Fixed an issue where the right field in Join Predicates was missing.
- Fixed an issue where quotes in comments would cause problems - thanks Doug Rowe.
- Fixed a bunch of issues related to the processing of files and file paths.
- Sorted out some privilege related issues that stopped you doing reports and importing more than one DDR - thanks Gordon Cox and others :)
- Added some processing for TO Groups back in.
The links you need are :
BaseElements_Mac.dmg - fp7 files.
BaseElements_Mac_MU.dmg - Sharing enabled version.
BaseElements_Mac_Runtime.dmg - Runtime.
Also this has the xslt code built in for the plugins and variables although only variables is working at the moment. This means I'm not adding any more processing steps to the import steps. This is as detailed as it's going to be. I'd love to hear from you about any speed differences between this version and the same DDR under BaseElements 2.x as I don't expect it to change much at all between now and final.
As always send me any feedback or issues you find : or on twitter or our contact form.
I've got slow loops.
Submitted by Nicholas Orr on 9 July 2010 - 11:10amIn my last blog post, I included a screenshot of some code from BaseElements 2. I'm always nervous exposing my code to the outside world, as there's a good chance that someone smarter than yourself will take a look and point out your weaknesses. Well, Daniel Wood from filemakerweetbix sent me a note to tell me I've been using slow looping methods in that code.
Basically I'm taking the list of variables and working through them one at a time. Each time I process the first one in the list, and then chop the list by doing a RightValues ( list, listlength -1 ). It's not the fastest method of looping and Daniel has a very good explanation of why and the various alternatives in a post on his blog, Thinking Outside the Loop. Well worth reading if you're interested in optimisations.
Looking back at my old code, I'm not sure what the reason for that looping style was, that particular bit of code was written about 2 years ago, and rarely touched since. I guess that means we should all publicise our code more often, and hope more smart people take an interest.
BaseElements has a new XSLT engine. Part 2 - Smarter XSLT.
Submitted by Nicholas Orr on 9 July 2010 - 9:53amFollowing on from part 1.
The second big change to the XSLT engine in BaseElements 3 is that we consolidated a lot of areas in the system. All of the old field, Custom Function, TO, ValueList, Variable and Plugin reference tables were all joined into a single "References" table. Although having one base table instead of 5 doesn't make things much faster inside BE, it meant we were able to do a single xslt run instead of five.
For example we're traversing the entire XML tree to find all the calculations. We do this again to find all of the references within the calculations. But if you imagine that a calculation can reference fields, CFs, TOs, variables and plugins, then repeating that traversal five times for each one is time consuming. So by putting the references into a single table we can do that just once.
But that's not all, we've brought into the xslt code some work that was previously being done as processing steps in BaseElements. If you've watched a BaseElements import, you will have seen some steps where it mentions "Processing Calculations". This was doing a few things : Digesting the calculation steps and producing plugin references and variable items, and also sorting out Indirection steps with function calls. It's a time consuming step in BaseElements 2, and can be up to a quarter of the total processing time. To give you an idea of the work being done, here is a screenshot of the code from BE2 :

In that there are lots of recursive custom functions ( great for simplifying code, not so great for massive data processing ), and lots of loops that run off and generate new records.
In BaseElements 3 this entire block of code is gone. In it's place we've built in the same functions into the References xslt file. I'm going to digress into some detailed xslt so if you're not interested, feel free to skim the technical steps or tune out :)
The first thing we needed to do was to be able to differentiate plugins from normal functions. FileMaker helpfully puts function calls in a separate part of the DDR, so we can track those, but it doesn't differentiate between plugins and other functions. To do this in xslt you build a lookup table reference :
<xsl:key name="plugin-lookup" match="PluginList/Plugin/Function" use="@name"/>
then you setup a variable to reference the external file :
<xsl:variable name="plugin-file" select="document('BE_Plugins.xml')" />
And finally when you've got a function call to lookup you look it up in your external table :
<xsl:for-each select="$plugin-file">
<xsl:if test="key('plugin-lookup', $FunctionName)">
<xsl:call-template name="RESULTSET"/>
</xsl:if>
</xsl:for-each>
We've used these key lookups in a few places other places as well and it makes a huge difference to the processing time.
The second part of that long script was the processing of variables used. FileMaker doesn't even distinguish variables from other parts of the text, and so they're just lumped in with text, math symbols and other whitespace as a "NoRef" type. As well as that, variables are now also in the text on layout objects, inside file references, perform find steps and set variable steps. Each one is slightly different, but essentially the process is the same for all of them : sort through the text and find the variables. This is actually harder than it seems. First, you don't want to find variables inside comments, so you need to remove those. Then you need to remove anything inside quote marks, but you need to first strip out any escaped quotes. Then you need to split the remaining text into dividers. Because a variable name can have spaces, the only way to tell when it ends is to just find the next non-variable name character after the $. This could be any of of the various math symbols or other characters that end a text block. So finally you have a list of the remaining text, and you convert those to nodes and loop through them to find any that start with a $.
This process is more complex to setup inside xsl than it is to code in FileMaker, but the end result is that the process runs much faster because you're not looping through records and generating multiple new variable reference records. The entire process fits inside the main reference xslt and is included in the single import that imports those.
I won't post the code here, but if anyone is interested in how it works, let me know and I'll document it in more detail.
It's these two changes, as well as the csv imports, that constitute the bulk of the reduced import time in BaseElements 3. It's funny, I thought I'd done a good job of making things faster in BE 2, and I wasn't sure where any extra savings would come from. It was only after the v11 update broke our old xsl that I went back to the drawing board and found other optimisations with the new xsl engine. So maybe if v11 still worked with the old code BE 3 might not have been as fast as it is...
BaseElements has a new XSLT engine. Part 1 - Details.
Submitted by Nicholas Orr on 8 July 2010 - 2:48pmAs you may have known from previous notes on the website about FileMaker 11 and BaseElements, there were changes in FMP 11 to the XSLT engine inside FileMaker. The basic details are that FileMaker uses Xalan / Xerces as their XML / XSLT engines, and these were updated to the latest release with the new v11.
Normally point releases like this don't cause any issues with XSLT, except for one change which affected the way BaseElements recorded data. I've written a long post about the details in the FAQ on our website.
I'd like to detail some of how we've worked around these issues and the changes it has meant for BaseElements 3.
First of all, the big priority with BaseElements is import speed. Anything we can do to increase import time is a bonus.
In some rudimentary testing we did, we found that FileMaker imports data from csv files faster than from an XML file. It's about 20% faster on our test data sets, although real world data may be different. All except about 3 of the imports that we're doing could be transformed easily into csv imports if we have the ability to generate them from the DDR. The ones that can't be changed into csv are things like script steps and calculation, where only XML can retain formatting of things like the step text or the calculation details.
But although you can do an xsl transform on import into FileMaker, you must produce XML, the xsl must come from an external file, and you can't do a transform outside of the import step. So if we're going to do XML -> csv and then import we need to have our own xsl engine to do this. So we've written a new BaseElements plugin that incorporates the libxml2 and libxslt libraries. This means we can do the xslt processing in the plugin, generate a temp csv file and then import that. This gives us lots of control over our processing and allows us to potentially incorporate new features from future changes to the xsl libraries faster than if using the in built engine.
A bonus for anyone doing xslt work in FileMaker : we're going to release the plugin code as open source once we've got a final version. We'd love to see what others can do with this new feature in FileMaker too.
Uploading Images to Drupal with MarsEdit
Submitted by Nicholas Orr on 5 July 2010 - 4:58pmAs a follow up to my previous post about MarsEdit, I was having an issue when trying to upload images. I was getting a really useless error :
It is not possible to upload the file, because it exceeded the maximum filesize of 0 bytes
So check the prefs inside drupal :

Right. Something's not quite talking there. It turns out the problem was in permissions. Although I'm logged in as user 1, which on the site has every privilege, the blog api uses the proper roles and won't allow you to upload if the permissions for your role doesn't have it explicitly set. When I turned on the correct privileges all was good again.
Posting to Drupal with MarsEdit
Submitted by Nicholas Orr on 5 July 2010 - 4:30pmI've been wanting for ages to use something like MarsEdit to draft and upload content to this blog. Bits of it work well, but other bits either had me confused or didn't quite work right.
For example, I no longer have comments turned on for blog posts (more on that later) and I still haven't bothered to investigate the utility or otherwise of Trackbacks. But MarsEdit has options for both when drafting a blog, and I can't turn them off. Plus I can't choose text filters other than "None" or "Filtered HTML" - the one I used most is "Full HTML".
Also I can have "Local Drafts" that have a server side "Post Status: Published" and published posts that are "Post Status: Draft". It's confused me more often than not.
I think what I'd like to see :
- Ability to remove all of the options for TrackBacks, Comments and Text Filter on a per blog basis.
- Auto updating of server side content on load or updates.
- Change "Local Drafts" to just "Drafts" and then make a decision for each blog about local or server side. It could then store them against each blog directly and would save you the hassle of thinking about where a blog is. You could still force a draft to be local by not assigning it a blog in the first place. But if you have a draft post it should appear on only one place. If I save a "published" post, then it should save to the server, not locally.
Also these days I'm using screens other than my main work machine more and more, and so an interface that allows you to store drafts more easily server side, and edit and upload from more places than one would suit me much more.
New Payment Processing Engine
Submitted by Nicholas Orr on 5 July 2010 - 3:09pmAs of today we have a new payment processing engine on the website. We used to use a combination of Ubercart, Paypal and WorldPay before today. All of these have been fine and have worked well for their relative strengths.
Ubercart is evolving quickly and has a good following in drupal land, although what we're doing, selling two products, doesn't really warrant or justify a "shopping cart" type solution. It's not yet flexible enough for us to do more (like invoicing consultant work via ubercart), so in lots of ways is overkill.
Worldpay has been very good, and is quite reasonably priced. It may seem odd to have a company in Australia, selling products in US dollars via a subsidiary of Bank of Scotland, but there isn't any local bank who will let us sell in US dollars without charging huge fees. I'm not particularly fussed about buying in overseas currency myself, but 90% of our sales are to the US, so it makes sense to have a fixed rate for that currency. I think this is becoming less of an issue though as time goes on, people are becoming more attuned to buying on the web from overseas companies.
Paypal has been good for us, you do hear stories about people who have had paypal issues before and we've had none of that. However we did get a recent email with a warning about Instant Payment Notifications. This is part of paypal processing that sends the data back to our site after a transaction completes. I have no idea what went wrong, nothing changed on our end, so I've no idea what caused the warning. It worries me that included in the email is the phrase
"If this problem continues, IPNs may be disabled for your account."
. Seeing as I can't find a reason for the issue, nor does the email contain any details, I'd hate for something to just stop working. I think this is the sort of thing people get concerned about with paypal, as the issue isn't clear and there is no place in the email to follow up or find out why or what is happening, and no contact details either.
The big issue in all of this for me though, is that I have to manage all of this myself. Keeping all of the various parts updated (especially ubercart and the various modules) and making sure it's all configured properly to work how it needs to work is not something I need to be doing. I'd prefer to be spending my time coding on BaseElements or UpdateManager and turning those into better products. I seem to come to that conclusion more and more these days.
So far we've outsourced timesheets to WorkFlowMax (works well but doesn't 100% suit our workflows, we work around that), our accounting to Xero (love it), and now our payments to FastSpring.
I'm yet to see how well FastSpring will work for us. I took it on because I've seen other developers using it, so it already has some sort of a reputation. Plus it offers features that are simple to add that would be complex in ubercart. At this point we have a very plain vanilla store, although we'll add more in the future.
In the mean time we still have the paypal and worldpay accounts, and we even have an old Kagi one. Worldpay is the only one of those that costs us money to keep open, although we still use it for taking credit cards at DevCon and will probably do that again this year. After that though, I'm not sure if it's worth keeping.
If you have any issues with purchasing or questions when buying a product, please contact us.
BaseElements Plugin to go open source
Submitted by Nicholas Orr on 2 July 2010 - 2:32pmIn order to make BaseElements the best DDR import tool available, we've written our own plugin. There are a couple of reasons for this. First we wanted to keep it simple for end users, and have a single plugin that does file functions as well as dialogs. Plus after much wrangling I found that the fastest import times were when importing csv. So we also needed an external XSLT engine that could process from XML to csv outside of FMP.
So BaseElements 3 now includes the BaseElements.fmx or BaseElements.fmplugin plugin.
Potentially we could onsell this to other developers (the file and dialog stuff is old hat, plenty of plugins do that, but the XSLT stuff is new), but I thought it would be best to try something different and open source it instead.
The nature of FMP means I haven't worked much in the development of open source products. I've used a lot of them myself, but never coded for one or worked on the development of one. I have setup SVN servers before, and I hear a lot about distributed version control systems like git. I used to see a lot of code hosted at sourceforge, but their site annoys me more than anything else these days with half a dozen clicks and lots of ads just to download anything.
At this point I'm sort of leaning towards GitHub for hosting, for no reason other than it seems popular and is free for open source.
If you've got a suggestion or recommendation, or are interested in helping with the code, please contact us or send us a note on twitter, we'd love your ideas.