James 的个人资料James's Space照片日志网络更多 工具 帮助

日志


8月23日

Bug-fixed version of Xsltx

I've uploaded a newer, less buggy build of Xsltx to Skydrive that also has built in support for compiling different 'views' for a control, set at design time.  There's a simple use of views in the samples if you want to have a look.
 
8月17日

Xsltx - bugs and plans

We've found quite a few bugs in the last build of Xsltx and we're busy fixing them - having an increasing number of uses and test cases for this is helping drive out the errors and omissions as well as the plain simple stupid bugs :).  I'll post another build next week when it seems more stable.  In the meantime, if you use it don't trust it - just for playing and feedback atm. 
8月14日

Update to Xsltx

I had feedback recently from a few people I know who are interested in Xsltx, e.g. 'The Kid' and Rich Kennedy.  Two big things they wanted adding were:
  1. The ability to override and change the rendering at runtime, e.g. by setting a control property.  To be used typically in webpart scenarios where solution designers want to easily prototype changes and minor improvements to the UX etc. without needing any recompilation.
  2. The ability to update the original XML without having to write any code, e.g. by declaratively relating a control property to an XML node described by an XPath expression.
I've now done both of these and they make it a lot more useful - (2) in particular is really cool as you can now build a form using Xsltx and server controls without needing to write any code apart from to load and save the XML.  Looking forwards other changes that may get done include:
  • Optional validation of the source data and any updates to it against a schema.
  • Some kind of (extensible / replaceable) hash based check on the XML data when updating it to ensure it hasn't changed since the data was rendered.
  • A provider / datasource model for the loading and saving of the data to avoid needing to code this.  Obvious data sources are databases (via DataSets and SqlAdapters or similar), web services and XML files stored in SharePoint libraries.
  • Integration with SharePoint for the InfoPath style scenario of creating, storing and editing XML forms in SharePoint.  We love InfoPath for this scenario but sometimes as developers it just doesn't give us the control we'd like.  Xsltx gives us an option where we don't have to go fully bespoke if InfoPath doesn't fit.
  • A wizard to convert an InfoPath form to Xsltx.  This would probably be lossy as script and code behind forms wouldn't migrate easily, but it would give you a quick design surface with InfoPath to accelerate initially building some of the Xsl(tx).
  • Finally finishing the VS integration to support new file wizards, etc.  If only VS was easier to customise...

Files posted on skydrive.  Let me know if you want any other features or want some help.

11月22日

Updated Trinity.Xsltx

I've updated my Trinity.Xsltx framework, primarily to fix a few bugs.  Other changes:
  • The default execution behaviour is now 'DataBindAndRender' rather than 'SinglePass', which although slightly slower is much easier to work with, fits with the normal ASP.NET page rendering lifecycle and should work in all scenarios.
  • Embedding user controls in xsltx files is now possible (there's examples in the updated sample project) by using xsltx:use-control.
  • xsltx:register is now a synonym for xsltx:register-namespace.  I just felt it was more concise and more similar to the equivalent Aspx directive.  You can use either - I haven't decided whether to deprecate the longer one.
  • I've removed all use of reflection at execution time, which should make it faster in some scenarios.  There wasn't much use of reflection before (just OnInit during postbacks I think) but there is none whatsoever now.
  • The xsltx controls serialise some data on child controls created, which allows the control hierarchy to be recreated on postback, and hence events handled.  Previously, the serialised data included all variable parameters and data used to intialise all the controls created, so could be quite large.  This was/is essential when using the 'SinglePass' approach as the controls weren't created until the Render method was called, so viewstate had already been saved and without outputting my own equivalent of viewstate after rendering, the controls couldn't have been recreated and appropriately initialised.

    However, for 'DataBindAndRender', the control hierarchy exists and is initialised before SaveViewState is called, so I'm making an assumption that controls will save any information that needs to be saved in there.  As a result I've changed the serialisation of control information for that scenario, so that the only data serialised is (more or less) the control type and id, i.e. the basic information I need to re-create the controls and their ids appropriately, to allow ViewState and events to work.  There's a chance I've got this slightly wrong and may need to serialise more info than I am doing, but in my own testing it seems to work.  Let me know about this.  FYI I am planning in future releases to change the format of the serialised information to make it more compact again (same info, but probably not serialised as B64 encoded XML ).  I might also need to consider signing the serialised data and may just (for DataBindAndRender anyway) move it into the viewstate... more thought needed by me here.

The updated version is available at the same link as before, at http://www.tesl.com/NR/rdonlyres/10DFD5E6-2D28-4F8B-A468-AA71E85A1684/0/TrinityXsltx.zip.

10月31日

XSLTX v1 available

I've spent the last two days tidying up my 'XSLTX' framework for using xslt with embedded server controls, postback event handling etc. which I originally mentioned in my previous blog entry.
 
A 'v1' release of the framework is up on the web and you can download it at http://www.tesl.com/NR/rdonlyres/10DFD5E6-2D28-4F8B-A468-AA71E85A1684/0/TrinityXsltx.zip.  It's an installer which will do the following:
  • Copy the Trinity.Xsltx.dll assembly and accompanying CHM file into c:\Program Files\Trinity Expert Systems\Trinity.Xsltx.
  • Copies two sample projects and a solution file into c:\Program Files\Trinity Expert Systems\Samples.
  • Copy the Trinity.Xsltx.dll assembly into the GAC.
  • Backup and modify C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.CSharp.targets to add a build task into the C# compilation process.  If you don't want this, just copy the backup back over the modified version.
  • Backup and modify C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config to add support for the new build provider and handler factory.  Again, if you don't want this, just copy the backup back over the modified version.

Uninstalling from add/remove programs will undo all the above steps - with the config files it re-edits them to remove the relevant entries rather than just copying the backup back over the modified file, so if you (or Microsoft) make any further changes after installing this framework and then uninstall, you won't lose them.

I'm not going to blog extensively today about how to use it - the samples and CHM file should be enough to start having a play.  Let me know if there's any problems, with the installer or otherwise, and I'll try and sort them out.

Have fun!

10月29日

XSLT, ASP.NET Server Controls and ASP.NET 2 Build Providers

I don't get to do much development any more - too many solutions to design, bids to respond to and difficult projects to sort out.  But sometimes I get bored with all that and long for the fun life of .NET development .  And then sometimes I even have some spare time to go with that urge and get round to indulging myself...
 
That's pretty much what happened last Christmas, when work wound down temporarily for a couple of days.  I'd just been reading about ASP.NET 2 build providers at the time and it made me think about a long standing desire of mine: to merge the ease of data postback and event handling that you get with server controls with the elegance of XML data rendering that XSLT gives you.  I've always loved XSLT (sure if you're used to imperative API based programming it takes a while to get used to the more declarative approach of XSLT) because I find for most non-trivial XML transformations it is more concise and much more readable and maintainable than .NET code.  Even with a complex XSLT it's quick to work out what the target output is going to look like.  Contrast that with relatively simple XML processing written using XmlDocuments/XmlTextReaders + XmlTextWriters (etc.) and personally for me it's 'no contest'.
 
Of course with what you get out of the box today, using XSLT to produce forms that will postback data, and then handle that on the server, is a pain in the neck that quickly puts you off touching XSLT in those scenarios.  Solving this problem by giving XSLT developers the same control capabilities as ASPX developers is something I long for - if this worked and your data is in XML then this should be the only thing you'd use - far more appropriate than ASPX.  I'm sure someone will argue with me about that - a good discussion to have :).  Basically though my interpretation of XSLT + Server controls + postbacks makes it pretty much an improved superset of ASPX so I don't see that as a controversial statement.
 
There's lots of ways you could start to do that in ASP.NET 1.1 and much of the problem is the same.  Build Providers just add some new possibilities and makes adding processing of new file types into the ASP.NET build process much easier.  MSBuild potentially gives similar new opportunities for non-web projects as well (e.g. controls libraries).  Another great advantage of .NET 2 is partial classes - it makes any such solution of declarative UI + code-behind much neater.  Enthused by my new knowledge I set out to create the answer I wanted... XSLTX!   Yes that's right - XSLT with server controls, event wireup and codebehind!
 
This was, as I mentioned, 11 months ago... I finished a draft working solution in a couple of days but was too busy to fully test it and soon got busy again.  Since getting this space (mostly, I admit, to have somewhere to put my photos) I figured I might as well put a little effort into blogging stuff like that because otherwise it'll get lost and not used.  Maybe, just maybe, someone will find it useful.  Anyway, I'm going to tidy it up a bit and put it on gotdotnet or similar and then blog a bit more on what I've done and how to use it.  What I'd really like to do is use VS extensibility features to make the developer experience much more seamless and feel like working with ASPX but that's a project for another week .
 
I should mention that I'm not the only one to have had thoughts along these lines (though I didn't know that till today, when I bothered looking...).  Have a look at the article Creating Dynamic ASP.NET Server Controls Using XML - it's not quite the same as what I've done but it's similar in concept, though on .NET 1.1.  Back with .NET 1.1 XSLT was also significanly slower (XsltTransform has now been replaced by XsltCompiledTransform)... so maybe this is an idea who's time has come.