[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

HTML text extraction

Subject: HTML text extraction
From: Myron Bennet <vbj34@xxxxxxxxx>
Date: Sun, 25 Jul 2004 22:23:15 -0700 (PDT)
html text extraction
Hello,

I am using XSL to extract text from HTML pages into
XML. I get all the text between predefined delimiter
keywords such as Heading 1 and Heading 2. The problem
I am having is the template continues matching past
the delimiter keywords (For example I want to match
between Headings 1 and 2 only, but the template
matches between Headings 1-2 plus everything else
after Heading 2). Example input/output and the
recursive template I use are shown below. I would
appreciate any input on this. Thanks.


INPUT HTML:

<p>Heading 1</p>
<p>bbb</p>
<p>aaa</p>
<p>Heading 2</p>
<p>aaa</p>
<p>ccc</p>
<p>Heading 3</p>
...


OUTPUT XML:

<Subject>
Heading 1
<content>
bbb
aaa
</content>
</Subject>
<Subject>
Heading 2
<content>
aaa
ccc
</content>
</Subject>
<Subject>
Heading 3
<content>
...
</content>
</Subject>


RECURSIVE TEMPLATE:
<xsl:template
match="//p[starts-with(normalize-space(.),'Heading')]">
<Subject>
<xsl:value-of select="."/>
<content>
<xsl:variable name="next"
select="following-sibling::*[not(starts-with(normalize-space(.),
'Heading'))]"/>
<xsl:if test="$next">
<xsl:apply-templates select="$next" mode="getContent"
/>
</xsl:if>                    
</content>          
</Subject>
</xsl:template> 
        
<xsl:template name="getContent">
<xsl:value-of select="."/>
<xsl:variable name="next"
select="following-sibling::*[not(starts-with(normalize-space(.),
'Heading'))]"/>            
<xsl:if test="$next">
<xsl:apply-templates select="$next" mode="getContent"
/>                           
</xsl:if>            
</xsl:template>



	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.