upgrade to RYOML (roll your own markup language)
It's recently come to my attention that I may have ADD, which comes as no surprise to the few people I've already mentioned this to. Case in point: back in September of '07 I posted an article about "rolling your own" markup - in essence, taking a more structured approach to bypassing Domino's rendering than just cobbling together a single string variable. I'd meant to develop the idea further, demonstrating how the same approach is applicable not only to generating XHTML, but any XML format. Something distracted me (though I've forgotten now what that was... seems the blog went through a bit of a technical dry spell after that) and I never revisited it - until a couple weeks ago, when I was asked whatever became of the framework.
I went back and restructured the existing classes somewhat and added a few new ones. In addition to some basic examples of generating very basic XML structures, the downloadable database (the LSDoc is available here) now contains an example agent demonstrating how to use this framework to programmatically generate entire design elements via DXL with a tiny amount of code:
Dim session As New NotesSession()
Dim library As RyoLSLibrary
Set library = New RyoLSLibrary("importedLibrary")
'Base 1, Compare NoCase, Declare and Public... and 2 Use statements
Call library.setOptions(1, "NoCase", True, True, "RyoXML,RyoDxl")
'Declare some global variables:
Call library.setDeclarations(|Dim session As NotesSession
Dim dbCurrent As NotesDatabase|)
'Create a top-level function:
Call library.appendRoutine("helloworld", |Public Function helloWorld()
Msgbox "Hello World!"
End Function|)
'Import the library into a target database
Call library.save(session.currentDatabase)
I leave the creation of similar class extensions - for the time being, at least - as an exercise for the reader. However, I do want to mention one reason that this demonstrates why constructing XML with a parser is often preferable to simple string concatenation: as mentioned in the comments of the full agent excerpted above, DXL is very sensitive to element order... we can't simply throw a bunch of code nodes out there in any order and expect the result to be a correctly compiled script library; the Options must come first, then Declarations, then any top-level functions. With more complex design element types, like forms, this gets even messier. A framework like this one allows us to more easily keep track of such things, not only allowing us the flexibility of specifying content in any order we desire, but also replacing and moving things around later without mucking up the rest of the content.
Comments
Thanks for all your work. Your previous Ryo code was a great help and pointed me in the right direction. Before that I had never really used the DOM Parser classes since I considered them only for use with DXL.
-- Jeff
Posted by Jeff Byrd At 10:48:45 AM On 03/03/2009 | - Website - |