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

Another newbie problem...

Subject: Another newbie problem...
From: "Kevin Nardi" <kevnardi@xxxxxxxxxxx>
Date: Mon, 16 Jul 2001 13:42:02 -0700
listview onclick
I hope you all don't mind...but I can't find the solution to this problem. The following documents are: source XML, XSL, result XML, in that order.

What I'm trying to do is create a table with a row of headers first, then one row for each item. However, I don't get a table at all. It jumps straight into the contents of each cell. From what I understand of XSL, it should process the itemListInfo element first, then the header elements, and then the item elements. It should then process one item child element for each header.

Can anyone help me with this?  I would very much appreciate it.
It's probably some stupid problem that I don't know enough to understand.

Thanks!

-Kevin

----------------------------------------------------

<itemListInfo xmlns="http://schema.upcast.com/content" xmlns:dc="http://purl.org/dc/elements/1.1/">
<checkInfo>
<idList/>
</checkInfo>
<headerInfo>
<sortBy>title</sortBy>
<sortOrder>ascending</sortOrder>
<headerList>
<header sort="true">
<name>title</name>
<title>Title</title>
</header>
<header sort="true">
<name>identifier</name>
<title>ID</title>
</header>
<header sort="true">
<name>coverage</name>
<title>Topics</title>
</header>
<header sort="true">
<name>type</name>
<title>Item Type</title>
</header>
<header sort="true">
<name>uri</name>
<title>Location</title>
</header>
<header sort="true">
<name>creator</name>
<title>Creator</title>
</header>
<header sort="true">
<name>lastModified</name>
<title>Last-Modified</title>
</header>
<header sort="true">
<name>numComments</name>
<title>Comments</title>
</header>
</headerList>
</headerInfo>
<itemList>
<item>
<dc:title>Item 1</dc:title>
<dc:identifier>atn</dc:identifier>
<dc:coverage>tia</dc:coverage>
<dc:type>BasicItem</dc:type>
<uri>http://10.10.9.32/DevPortal2/portal_catalog</uri>
<dc:creator>janette3</dc:creator>
<dc:date>2001-07-09 17:21:00</dc:date>
<comments>
<num>0</num>
</comments>
</item>
<item>
<dc:title>Item 2</dc:title>
<dc:identifier>atnb</dc:identifier>
<dc:coverage>tia</dc:coverage>
<dc:type>BasicItem</dc:type>
<uri>http://10.10.9.32/DevPortal2/portal_catalog</uri>
<dc:creator>janette3</dc:creator>
<dc:date>2001-07-09 17:22:00</dc:date>
<comments>
<num>0</num>
</comments>
</item>
</itemList>
</itemListInfo>


----------------------------------------------------

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns="http://www.w3.org/TR/xhtml1/strict">

<xsl:output method="html" indent="yes" />

<!-- DTML Variables -->
<xsl:variable name="bUserIsAnonymous">false</xsl:variable>
<xsl:variable name="bUserIsManager">true</xsl:variable>
<xsl:variable name="bCheckboxes">true</xsl:variable>
<xsl:variable name="bLinks">true</xsl:variable>
<xsl:variable name="urlThisPage">http://10.10.9.32/DevPortal2/User/kevin/tMyItems?whichView=listView</xsl:variable>
<xsl:variable name="urlPublishItem">mPublishItem?returnTo=<xsl:value-of select="$urlThisPage" /></xsl:variable>
<xsl:variable name="urlImagePath">http://10.10.9.32/images</xsl:variable>
<xsl:variable name="username">kevin</xsl:variable>
<!-- /DTML Variables -->


<xsl:template match="text()" />

	<xsl:template match="itemListInfo">
		<table width="100%" cellspacing="0" cellpadding="1" class="listTable">
			<tr><xsl:apply-templates select="headerInfo/headerList/header" /></tr>
			<xsl:apply-templates select="itemList/item" />
		</table>
	</xsl:template>

	<xsl:template match="header">
		<td class="listHeader">
			<xsl:if test="ancestor::headerInfo/sortBy = name">
				<xsl:choose>
					<xsl:when test="ancestor::headerInfo/sortOrder = 'ascending'">
						<img src="{$urlImagePath}/pointer_down.gif" />
					</xsl:when>
					<xsl:otherwise>
						<img src="{$urlImagePath}/pointer_up.gif" />
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="@sort = 'true'">
					<a href="javascript:void(0)"><xsl:value-of select="title" /></a>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="title" />
				</xsl:otherwise>
			</xsl:choose>
		</td>
	</xsl:template>

	<xsl:template match="item">
		<xsl:variable name="thisItem" select="." />
		<xsl:variable name="className">
			<xsl:choose>
				<xsl:when test="position() mod 2 = 0">
					myItems1
				</xsl:when>
				<xsl:otherwise>
					myItems2
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<tr class="{$className}">
			<xsl:for-each select="//itemListInfo/headerInfo/headerList/header">
				<xsl:if test="name = 'title'">
					<td align="left" class="{$className}">
						<xsl:apply-templates select="$thisItem/dc:title" />
					</td>
				</xsl:if>
				<xsl:if test="name = 'creator'">
					<td align="center" class="{$className}">
						<xsl:apply-templates select="$thisItem/dc:creator" />
					</td>
				</xsl:if>
				<xsl:if test="name = 'lastModified'">
					<td align="center" class="{$className}">
						<xsl:apply-templates select="$thisItem/dc:date" />
					</td>
				</xsl:if>
				<xsl:if test="name = 'rating'">
					<td align="center" class="{$className}">
						<xsl:apply-templates select="$thisItem/rating/ave" />
					</td>
				</xsl:if>
				<xsl:if test="name = 'numComments'">
					<td align="center" class="{$className}">
						<xsl:apply-templates select="$thisItem/comments/num" />
					</td>
				</xsl:if>
				<xsl:if test="name = 'status'">
					<td align="center" class="{$className}">
						<xsl:apply-templates select="$thisItem/status" />
					</td>
				</xsl:if>
			</xsl:for-each>
		</tr>
	</xsl:template>

<xsl:template match="dc:title">
<xsl:variable name="docID"><xsl:value-of select="ancestor::item/dc:identifier" /></xsl:variable>
<xsl:if test="$bCheckboxes = 'true'">
<input class="smallCheckbox" type="checkbox" name="ids:list" value="{$docID}" id="cb_{$docID}">
<xsl:for-each select="//itemListInfo/checkInfo/idList/id">
<xsl:if test="$docID = .">
<xsl:attribute name="checked" />
</xsl:if>
</xsl:for-each>
</input>
</xsl:if>
<span>
<xsl:attribute name="title">
<xsl:value-of select="ancestor::item/dc:coverage" />
</xsl:attribute>
<xsl:if test="$bLinks = 'true'">
<xsl:choose>
<xsl:when test="ancestor::item/dc:type = 'Personal HomePage'">
<a href="{ancestor::item/uri}">
<xsl:value-of select="." />
</a>
</xsl:when>
<xsl:otherwise>
<a href="{$urlThisPage}" onClick="setItemLayoverCookie('{$docID}')">
<xsl:value-of select="." />
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</span>
</xsl:template>


<xsl:template match="dc:creator">
<xsl:variable name="docID"><xsl:value-of select="ancestor::item/dc:identifier" /></xsl:variable>
<xsl:choose>
<xsl:when test="$bLinks = 'true'">
<a>
<xsl:value-of select="." />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template match="status">
<xsl:choose>
<xsl:when test="($bUserIsManager = 'true') or (ancestor::item/creator = $username)">
<a href="javascript:void(0)" onClick="pop2EditItems('{ancestor::item/uri}/{$urlPublishItem}'); return false;">
<xsl:value-of select="." />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>


	<xsl:template match="dc:date">
		<span class="smallText"><i><xsl:value-of select="." /></i></span>
	</xsl:template>

	<xsl:template match="rating/ave">
		<xsl:value-of select="format-number(.,'0.0')" />
	</xsl:template>

	<xsl:template match="comments/num">
		<xsl:value-of select="." />
	</xsl:template>

</xsl:stylesheet>

----------------------------------------------------

<input class="smallCheckbox" type="checkbox" name="ids:list" value="" id="cb_" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">
</input>
<span title="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">
<a href="http://10.10.9.32/DevPortal2/pub/tia/index_html?whichView=listView" onClick="setItemLayoverCookie('')">Item 1</a>
</span>
<a xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">janette3</a>
<span class="smallText" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict"><i>2001-07-09 17:21:00</i></span>
<input class="smallCheckbox" type="checkbox" name="ids:list" value="" id="cb_" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">
</input>
<span title="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">
<a href="http://10.10.9.32/DevPortal2/pub/tia/index_html?whichView=listView" onClick="setItemLayoverCookie('')">Item 2</a>
</span>
<a xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict">janette3</a>
<span class="smallText" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/TR/xhtml1/strict"><i>2001-07-09 17:22:00</i></span>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



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.