[xsl] Help! How do I find elements through text contents XSLT 1.0

Subject: [xsl] 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
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