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

Re: Extracting text

Subject: Re: Extracting text
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 25 May 2005 19:08:32 -0400
extracting text from xml
Jon,

Ordinarily, one would do this implicitly by way of the default traversal, as in simply

<xsl:template match="p">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="span | br"/>
<!-- this template suppresses the span and br -->

If you do this you'll find your text is "extracted".

In particular cases, one might be more explicit about the extraction:

<xsl:template match="p">
  <xsl:apply-templates select="text()"/>
  <!-- this instruction selects only text node children
       and processes them -->
</xsl:template>

... but not uncommonly when we see this sort of thing, it's an indication of either bad coding in the XSLT, bad design of the source XML, or both. Yet you can certainly do it, and might even have a good reason to.

I hope this helps,
Wendell

At 06:31 PM 5/25/2005, you wrote:
'lo all,

I need to extract
  'Root level text'
  'more root level text'

from:

<p>
  <span>whatever</span>
  Root level text
  <br/>
  more root level text
</p>

Any ideas?

Thanks, jon
jopaki@xxxxxxxxx





__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread
  • Extracting text
    • jpk - 25 May 2005 22:31:53 -0000
      • Wendell Piez - 25 May 2005 23:18:08 -0000 <=

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.