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

RE: Is this a legal XPath Expression?

Subject: RE: Is this a legal XPath Expression?
From: "Phil Gooch" <phil.gooch@xxxxxxxxx>
Date: Thu, 15 Mar 2001 11:56:32 -0000
phil gooch
Thanks for that Mike.

Basically what I am doing is trying to find unique occurrences of the
contents of cells in column 15 of an HTML table, e.g

<td>Working conditions</td>
...
<td>Living conditions</td>
...
<td>Working conditions</td>
...
<td>Industrial relations</td>
...
<td>Living conditions</td>
...

, then, for each of these, pick out unique occurrences of the contents of
cells in column 28, and for each of those, pick out the contents of cell 3.
Looks like a job for <saxon:group>, but I couldn't figure out how to do it,
so my code looks like this: (it works, but its v. inefficient!)

<xsl:template match="TD[15]">
		<!-- subject is in cell 15 -->
		<xsl:variable name="subject"
select="node()[not(.=preceding::TR/TD[15]/node())]"/>
		<xsl:if test="$subject !=''">
			<xsl:variable name="link" select="generate-id()"/>
			<tr>
				<td>
					<a href="{$link}.html"><xsl:value-of select="$subject"/></a>
				</td>
			</tr>

			<!-- for each subject, output the project title to a sep. file-->
			<saxon:output file="{concat($link, '.html')}">
				<html><head></head>
				<body><table>
				<xsl:for-each select="//TR">
					<xsl:apply-templates select="TD[28]">
						<xsl:with-param name="subj" select="$subject"/>
					</xsl:apply-templates>
				</xsl:for-each>
				</table>
				</body>
				</html>
			</saxon:output>
		</xsl:if>
	</xsl:template>

	<!-- project title is in cell 28 -->
	<xsl:template match="TD[28]">
			<xsl:param name="subj"/>
			<xsl:if test="../TD[15]/node()=$subj">
				<xsl:variable name="projecttitle"
select="node()[not(.=preceding::TR/TD[28]/node())]"/>
				<xsl:if test="$projecttitle!=''">
					<xsl:variable name="link" select="generate-id()"/>
					<tr>
						<td>
							<a href="{$link}.html"><xsl:value-of select="$projecttitle"/></a>
						</td>
					</tr>

					<!-- for each project, output the filename to a sep. file-->
					<saxon:output file="{concat($link, '.html')}">
						<html><head></head>
						<body><table>
						<xsl:for-each select="//TR">
							<xsl:apply-templates select="TD[3]">
								<xsl:with-param name="proj" select="$projecttitle"/>
							</xsl:apply-templates>
						</xsl:for-each>
						</table>
						</body>
						</html>
					</saxon:output>

				</xsl:if>
			</xsl:if>
	</xsl:template>

	<xsl:template match="TD[3]">
		<xsl:param name="proj"/>
			<xsl:if test="../TD[28]/node()=$proj">
				<xsl:variable name="fn"  select="."/>
					<tr>
						<td>
							<a href="{$fn}">Download <xsl:value-of select="$fn"/></a>
						</td>
					</tr>
			</xsl:if>
	</xsl:template>

Phil

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Michael Kay
> Sent: Wednesday, March 14, 2001 9:31 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Is this a legal XPath Expression?
>
>
> > Subject:  Is this a legal XPath Expression?
>
> > select=".[not(.=preceding::TR/TD[15]/node())]"
> >
>
> No, it isn't legal. "." is an AbbreviatedStep, as such it is a Step, and a
> Step cannot be followed by a Predicate.
>
> Write select="self::node()[not(.=preceding::TR/TD[15]/node())]"
>
> Or in the context where you are using it,
>
> <xsl:template match="TR/TD[15]">
> 		<xsl:variable name="subject"
>                            select="not(.=preceding::TR/TD[15]/node())"/>
> 		<xsl:if test="$subject">
> 		<tr>
> 			<td>
> 				<a href="{.}.html"><xsl:value-of
> select="."/></a>
> 			</td>
> 		</tr>
> 		</xsl:if>
> </xsl:template>
>
> I'm suspicious about that TR[15]/node() as well: what if it's a comment?
>
> Mike Kay
> Software AG
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>



 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.