#!/usr/bin/python ## Namespace Tutorial ## Copyright (C) 2000 Miloslav Nic (nicmila@idoox.com) ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License ## as published by the Free Software Foundation; either version 2 ## of the License, or (at your option) any later version. ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os,re,sys xmlid=str(13) xmlsource = "../XML/source" + str(xmlid) + ".xml" xml=open(xmlsource).read() xmlnsAttrs= re.compile('xmlns.*?=".*?"').findall(xml) xmlnsAttrs.sort() try: last="" while 1: this=xmlnsAttrs.pop() if last==this: continue last=this at=re.compile("xmlns").sub("amlns",this) at=re.compile("amlns:").sub(" amlns___",at) xml=re.compile(this).sub(at+" "+this,xml) except IndexError: pass xmlfile=open("../WorkDir/source.xml","w") xmlfile.write(xml) xmlfile.close() os.system('saxon -o ../WorkDir/output.html ../WorkDir/source.xml ../XSLT/example.xslt') html=open("../WorkDir/output.html").read() html=re.compile("___").sub(":",html) html=re.compile("amlns").sub("xmlns",html) out = open("../Output/example"+xmlid+".html","w") out.write(html) out.close()