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

Re: Mixed content: selecting current context w/out child

Subject: Re: Mixed content: selecting current context w/out child
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Sat, 13 Mar 1999 12:12:17 -0500
xsl for each current context
I asked the list a bit ago:

>This has got to be a fairly elementary question.... What's the proper
select expression to retrieve *only* the PCDATA portion of a mixed-content
element, *not* the contents of its children?

As a member of the list kindly reminded me off-list, the answer is to use
one or more text() nodes.

Given:
    <name>Candace Hilligoss<role>Mary Henry</role></name>
to produce the following HTML:
    <tr>
      <td>Candace Hilligoss</td>
      <td>Mary Henry</td>
    </tr>
use:
    <xsl:for-each select="name">
      <tr>
         <td><xsl:value-of select="text()"/></td>
	   <td><xsl:value-of select="./role"/></td>
      </tr>
    </xsl:for-each>
The text() gets just the first PCDATA portion of the <name> element. If
there were more than one, I could get them all by replacing the first
value-of with a nested for-each, like so:
    <xsl:for-each select="name">
      <tr>
	    <xsl:for-each select="text()">
      	  <td><xsl:value-of select="."/></td>
	    </xsl:for-each>
	   <td><xsl:value-of select="./role"/></td>
	</tr>
    </xsl:for-each>

<slappingforehead/>

Thanks!

==========================================================
John E. Simpson            | The secret of eternal youth
simpson@xxxxxxxxxxx        | is arrested development.
http://www.flixml.org      |  -- Alice Roosevelt Longworth


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.