RE: [xsl] <xsl:for-each> not working...

Subject: RE: [xsl] <xsl:for-each> not working...
From: "John Liebermann" <ahsan_hussain@xxxxxxxxxxxxx>
Date: Fri, 15 Aug 2003 15:52:26 -0700
Sir, let me explain since i can't attach the full XSL file. I have a few
fields in with parents Inputs and Outputs. The Inputs and Outputs are of
<HSDataContainerType> wherweas the fields can be <HSString> or <HSDecimal>
or <HSInteger> etc. First i display them is an indented form kinda like a
tree.
Output looks like this now:
--------------------------------------------------------
Inputs
	textField1
	integerField1
	DataContainer1
		integerField11
		decimalField11
Outputs
	integerField2
	DataContainer2
		decimalField2
..
		<-----wanna put "Inputs" here and link it up to the top Input heading.
textField1
Description: None
Required: Yes

integerField1
Description: None
Required: Yes

DataContainer1/integerField11
Description: None
Required: No

DataContainer1/decimalField11
Description: None
Required: No
		<-----wanna put "Outputs" here and link it up to the top Output heading.
integerField2
Description: None
Required: No

DataContainer2/decimalField2
Description: None
Required: No

..
--------------------------------------------------------------------
All these fields (all those with names ending in 'field') are links to their
descriptions, which i display at the bottom with the field name as heading
and then other info. extracted out of their attributes etc. What i would
like to do is to make links out of Inputs and Outputs and then be able to
link them up to headings(don't exist, would like to put) in between the
descriptions at the bottom. This would clearly demark the Inputs from
Outputs. So i just need one heading for 'Inputs' and one heading for
'Outputs' to show the user where they start.

I was using a for-each loop with ancestor::* to clearly display the path to
each field. That works perfect. The problem is that i don't process Inputs
and Outputs separetely. They are both of <HSDataContainer> type so i use :
--------------------------------------------
<xsl:template match="HSDataContainerType">
  <xsl:choose>
	<xsl:when test="contains(@name, 'Inputs')">
		<img src="dcopenicon.gif">
		<a href="#in"><b><xsl:value-of select="@name"/></b></a></img>
		<div style="margin-left: 3em;">
		<xsl:apply-templates select="*"/></div>
	</xsl:when>

.. exactly the same for 'Outputs'
--------------------------------------------

So it is very hard for me to be able to display a heading and then all the
field in it. Thank you for any help.

-John

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of David
Carlisle
Sent: Tuesday, July 15, 2003 3:02 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] <xsl:for-each> not working...



> Sir, your recommended piece of code doesn't do much different from what my
> code was doing.

well it added a test so that it would only output the <a name="out"
anchor for one of the ancestors that had the string "Outputs" in its
name attribute, which was what I thought you asked for. Your test file
as posted later though only had one element with such an attribute so
the extra test would do nothing in that case, so probably I didn't
understand the question.

By the way do you really mean contains(@name,'Outputs') here (and
similarly your other tests) your test file had the attribute equal to
this string, if a test of @name='Outputs' is acceptable you could
probably simplify greatly as with = you can do existential
quantification as in ancestor::*/@name='Outputs'  which tests if any
ancestor has that attribute, a form that you can't do so easily with
contains().

David

 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