Re: [xsl] Start and end an anchor tag in 2 different if's?

Subject: Re: [xsl] Start and end an anchor tag in 2 different if's?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 5 Oct 2004 17:05:31 +0100
> Is there something obvious that I'm doing wrong?

yes:-)

XSLT has no access to tags in the input document and can not directly
produce tags in the result. It inputs a tree of nodes (which is
generated by parsing the tags in an xml document) and it generates a
result tree (which might, or might not, be serialised as an XML document
containing tags).

You can't have "half a node" in a tree so XSLT has no concept of having
a start tag in one place and an end tag somewhere else.

less abstractly, an XSLT file is read by an XML parser before it starts
and an xml parser knows nothing about xslt or html so

	<xsl:if test="district_active='1'">
		</a>   <!--============ Notice this ==============-->
	</xsl:if>



looks like

<zzz>
 </ccc>
</zzz>

and generates an error that the document is not well formed.


You need to move the code all inside a single test for district_active.

Also

	<a>
  <xsl:attribute name="href">LegislatorEdit.asp
				?lid=<xsl:value-of
select="legislator_id" />
				&amp;lstat=<xsl:value-of select="$lstat"
/>
				&amp;dtype=<xsl:value-of select="$dtype"
/>
				&amp;dno=<xsl:value-of select="$dno" />
			</xsl:attribute>

could be more simply written as

<a
href="LegislatorEdit.asp?lid={legislator_id}&amp;lstat={$lstat}&amp;dtype={$dtype}&amp;dno={$dno}">

(I've also removed the white space which may or may not need to be
removed, depending on whether your server accepts (and ignores) url
quoted white space between the parameters.)


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread