xsl-list
[Top] [All Lists]

Re: Extracting text

2005-05-25 16:08:32
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(_at_)yahoo(_dot_)com





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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>