Subject: RE: [xsl] element to root From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Tue, 31 May 2005 20:44:33 +0000 |
<p> <span style="style a"> span a text 1 <span style="style b"> span b pre br text <br name="b"/> span b post br text </span> span a text 2 </span> </p>
<p> <span style="style a"> span a text 1 <span style="style b"> span b pre br text </span> </span>
<span style="style a"> <span style="style b"> span b post br text </span> span a text 2 </span> </p>
------ <p> <span style="style a"> span a text 1 <span style="style b"> span b pre br text </span> </span> <span style="style a"/> <br name="b"/> <span style="style a"> <span style="style b"> span b post br text </span> span a text 2 </span> </p> ------
<p> <strong> strong:text(top) <br/> prefix <span style="a style"> span a <span style="rgb();"> span b <br/> text </span> text </span> strong:text(btm) <br/> suffix <br/> </strong> Root level text with <br/> tag. </p>
<p> <strong> strong:text(top) </strong>
<strong> prefix <span style="a style"> span a <span style="rgb();"> span b </span> </span> </strong>
<strong> <span style="a style"> <span style="rgb();"> text </span> text </span> strong:text(btm) </strong>
<strong> suffix </strong>
<strong> </strong> Root level text with
tag. </p>
stack, b, linecount = [], 0, 0 f = open(r'e:\temp\test.xml')
try: while 1: line = f.readline( ).rstrip() if not line: break
if linecount == 1: pass elif re.match("\s*<br.+>$", line): b = 1 elif re.match("\s*<?\w+[^>]*>$", line): # start-tag stack.append( line ) elif re.match("\s*</\w+[^>]*>$", line): # end-tag stack = stack[:len(stack)-1]
if b: # write closing tags stack.reverse() for t in stack: m = re.match("(?P<TAB>\s*)<(?P<NAME>\w+)", t) print "%s</%s>" % ( m.group('TAB'), m.group('NAME') )
if b: # write opening tags again stack.reverse() for t in stack: print t b = 0
finally: f.close( )
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] element to root, David Carlisle | Thread | [xsl] pre/post text, jpk |
[xsl] How do i put whitespace chara, Frequent Fliers | Date | RE: [xsl] How do i put whitespace c, Jaime Stuardo |
Month |