Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outputting Columns

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi,

I have a basic XML document that contains data to use for an HTML link and the text to apply to the link. The data for the link currently can be in two languages.

This is my basic doc:

<PrimaryNav>
<NavElement>
<URLLink>press/</URLLink>
<URLText Language="En">Press Centre</URLText>
<URLText Language="Cy">Adran Canolfan Y Wasg</URLText>
</NavElement>
.
.
.
<PrimaryNav>

I need to be able to output the links in two cols down the page. I have got it so that the links are being created but i am getting duplicates, I can't figure out how to list the links in 2 cols.

this is what i want:

<tr>
<td>Link One</td>
<td>Link Two</td>
</tr>
<tr>
<td>Link Three</td>
<td>Link Four</td>
</tr>
.
.
.

This is the XSLT I have at the moment:

<xsl:template match="/">
<xsl:for-each select="//NavElement">
<tr>
<td><a xsl:use-attribute-sets="PrimaryLink"><xsl:value-of select="URLText[@Language='En']"/></a></td>
<td>This is the bit that's going wrong</td>
</tr>
</xsl:for-each>

Any ideas on a better way of structuring the XML document and to make the XSLT work would be appreciated.

TIA

Tony
 
I don't think I quite understand...

Is this what you are trying to do???
Code:
<xsl:for-each select="//NavElement">
  <tr>
    <td><a href="{URLLink}"><xsl:value-of select="URLText[@Language='En']"/></a></td>
    <td><a href="{URLLink}"><xsl:value-of select="URLText[@Language='Cy']"/></a></td>
  </tr>
</xsl:for-each>

This should show:
Code:
<tr>
  <td><a href="press/">Press Centre</a></td>
  <td><a href="press/">Adran Canolfan Y Wasg</a></td>
</tr>

If not, please give a little more description...

This:
<td>This is the bit that's going wrong</td>
Doesn't help...

What does your original XSL look like???

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks for the response, I've found what I was looking for.

What I wanted to be able to do was to list cols out of an XML doc.

Like this

Col1 Col2
Col3 Col4
Col5 Col6

This is what I found:

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
	<xsl:output method="html" encoding="Windows-1252" />
   	<xsl:variable name="NumberOfRows" select="4" />
   	<xsl:variable name="Language" select="En" />

	<xsl:template match="/">
		<html>
			<body>
			<div class="head">
			<table cellpadding="0" cellspacing="0" border="0" summary="This table generates the main navigation for the website">
			<tr>
				<td class="primaryNavDivider"><img src="laf/shim.gif" alt="" border="0" width="194" height="1" /></td>
				<td class="primaryNavSpace"><img src="laf/shim.gif" alt="" border="0" width="6" height="1" /></td>
				<td class="primaryNavDivider"><img src="laf/shim.gif" alt="" border="0" width="194" height="1" /></td>
			</tr>
        	<xsl:apply-templates select="//NavElement[position() &lt; $NumberOfRows + 1]" mode="row"/>
    	  	</table>
			</div>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="//NavElement" mode="row">
    	<tr>
        	<xsl:variable name="position" select="position()+$NumberOfRows" />
            <xsl:apply-templates select=".|following-sibling::NavElement[position() mod $NumberOfRows = 0]/." mode="cell"/>
		</tr>
		<tr>
			<td class="primaryNavDivider"><img src="laf/shim.gif" alt="" border="0" width="194" height="1" /></td>
			<td height="100%" class="primaryNavSpace"><img src="laf/shim.gif" alt="" border="0" width="6" height="1" /></td>
			<td class="primaryNavDivider"><img src="laf/shim.gif" alt="" border="0" width="194" height="1" /></td>
		</tr>
	</xsl:template>

	<xsl:template match="//NavElement" mode="cell">
		<td><a xsl:use-attribute-sets="PrimaryLink"><xsl:value-of select="URLText[@Language='En']"/></a></td>
        <td class="primaryNavSpace"><img src="laf/shim.gif" alt="" border="0" width="6" height="1" /></td>
	</xsl:template>

	<xsl:attribute-set name="PrimaryLink">
		<xsl:attribute name="href"><xsl:value-of select="URLLink"/></xsl:attribute>
	</xsl:attribute-set>
</xsl:stylesheet>

Thanks for responding though

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top