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

Help! How do I find elements through text contents XSL

Subject: Help! How do I find elements through text contents XSLT 1.0
From: "Marroc" <marrocdanderfluff@xxxxxxxxxxx>
Date: Thu, 24 Jan 2008 12:32:44 -0000
 Help! How do I find elements through text contents XSL
Hi all,

I've been pulling my hair out over this and I'm sure it has to be simple.

I'm converting HTML to XML (why do all the textbooks only go the other way?)
and I need to identify, say for instance, tables by the contents in the
header row. So, in the inconsistent input file I might have:

<table>
	<tbody>
		<tr>
			<th>Keyword
...

Or I might equally have:

<table>
	<tr>
		<td><b><i>Keyword
...

Or any combination in between. The question is, how do I consistently
identify this table based on the heading text without knowing the exact node
path. I think I've tried all combinations of contains(), text(), ancestor::
etc.

My original transform which works was limited to two cases and looked like
this: 

	<xsl:template match="body/table">
		<xsl:choose>
			<xsl:when test="contains(tr[1]/th[1],'Keyword')">
				<properties>
					<xsl:apply-templates select="tr"
mode="prop"/>
				</properties>
			</xsl:when>
			<xsl:when test="contains(tr[1]/td[1],'Keyword')">
				<properties>
					<xsl:apply-templates select="tr"
mode="prop"/>
				</properties>
			</xsl:when>

Do I really need to create all possible combinations of hierarchies in order
to pick these tables up?

Thanks in advance for any help or advice you can give,
Richard

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.