Transforming xml documents to HTML from XML using XSL and XSLT in Python.
Transforming xml documents to HTML from XML using XSL and XSLT in Python.
'''
A script to generate an html file from xml and xsl using xslt
'''
import Pyana
import os
dir = os.getcwd()
logtxt = open( "xml-html.log.txt" , "w")
def transformit( file ):
f = open ( file + "_processed.html", "w")
f.write( Pyana.transform2String(source=Pyana.URI( file + ".xml" ),
style=Pyana.URI('pubmed_xslt.xsl')))
f.close()
def logwr ( string ):
logtxt.writelines( string ),
#============================================
count = 0
for item in os.listdir(dir):
if item.endswith('.xml'):
( fname , ext ) = os.path.splitext( item )
print fname
logwr ( "transforming " + fname )
print ( "transforming " + fname )
transformit( fname )
count = count + 1
logwr( "the number of documents is " + str(count) ),
print ("the number of documents is " + str(count) ),
logtxt.close()
#==============================================
Comments