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

XSLT Stylesheet Exclude Parental Search Results?

  • From: Jack Bush <netbeansfan@y...>
  • To: xml-dev@l...
  • Date: Thu, 22 Jan 2009 05:01:10 -0800 (PST)

XSLT Stylesheet Exclude Parental Search Results?

Hi All,


I would like to extract only the content of the following mixed XML document converted from XHTML format:


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html (View Source for full doctype...)>

- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">

- <head>

- <body


- ><div id="container">

+ <div id="header">

<div id="postmark" />

- <div id="content">

+ <div id="as1">


<h1>Employee Detail</h1>

- <p>


<a >John</a>


- <p>


<a >Smith</a>


- <p>

<strong>Date of birth:</strong>



- <p>




- <p>


<br />


<br />


<br />




<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"




<xsl:template match="/">


<xsl:if test="/ns:html/ns:body/ns:div[@id='content']/ns:p/ns:strong">


<xsl:when test="contains(.,'Firstname:')">

<firstname><xsl:value-of select="."/></firstname>











Not only did XSLT returned all the correct employee data but also included a lot of irrelvant data from the parental nodes as well. In other word, it return the contents from ns:html, ns:body, ns:div[@id='content'], ns:p, ns:strong which I don't want. Is there a way to prevent (exclude/mask) all these ancestral data from being included and only pick up the data in /ns:html/ns:body/ns:div[@id='content']/ns:p/ns:strong cleanly?


Many thanks,


Stay connected to the people that matter most with a smarter inbox. http://au.rd.yahoo.com/galaxy/mail/tagline2/*http://au.docs.yahoo.com/mail/smarterinbox.

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.