[Web-SIG] DOM Implementation

Timothy Soehnlin tsoehnli at gmu.edu
Fri Jun 3 23:59:19 CEST 2005


What if instead of intersplicing node commands, such as iterating through lists, into
 the actual document, you were to operate on a different idea.

What if you were to parse an xml file, and then manipulate the entire
 page as through a system of blocks. i.e.

----------------------
<page>			
	<data id='eItem'>
		<div class='blogEntry'>
			<div class='heading'>%(heading)s</div>
			<div class='day'>%(day)s</div>
		</div>
	</data>
	
	<data id='updated'>
		<h2>Updated, click <a href='/admin/'>here</a> to return</h2>
	</data>
</page>
------------------------
via the id tags, you could modify the output without ever knowing what it is. 

Assuming there is a wrapper around the xml file, to be indexed as a dictionary given 'id' tags,
if you successfully deleted something, you would return as output, xmlObject['deleted'], and
with string splicing, you could merge data, as with xmlObject['blogEntry'] % blogData, where
blogData is a dictionary of data that could be generated by another xml file, or a database query.
This would then would return a fully constructed html block, without the script ever knowing or
touching any html. 

This orientation has some drawbacks, but allows for complete separation of code from 
content. 

This may happen to be too verbose for certain things, as it seems to add a lot of extra code
for doing simple things, but with some simple coding, you could easily build a module that works
around that.

I do know that this works quite well for a system I have built, and keeps people who are editing
the xml files from seeing any control structure, or any indication of python.  Which means you 
could have people who know only html build the xml files, and then coders manipulate it, neither
of the two would need to interact minus the definition of the variables for interpolation. Also, to
hide python even more, the %( )s is normally replaced with [[ ]], as to make it seem more
variable like, but that is superficial.
-- 
I would rather be known as a Christian
	and despised, than to be overlooked,
		and thought of as one of the world.


More information about the Web-SIG mailing list