[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|