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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT and dynamic table creation 1

Status
Not open for further replies.

agentwalker

Programmer
Jun 10, 2007
31
GB
My xml looks something like this

Code:
<group collapse-flagged-groups="Y" collapse-flagged-datasets="Y" css-class="CarePlanProbGroup" javascript-function="highlight(this)">
		<dataset collapse-this="Y" data-cols="2">
			<data label-text="Created / Modified By:">Jim Davidson On 23 October 2007 23:10</data>
			<data label-text="Date Entered:">12 September 2006 12:14</data>
		</dataset>
		<dataset collapse-this="N">
			<data>Is clinically obese, tablet controlled diabetic - oh yeah!</data>
		</dataset>
		<dataset collapse-this="Y">
			<data label-text="Type:">Overweight</data>
		</dataset>
		<group collapse-this="Y">
			<dataset>
				<row>
					<data label-text="Goal">To ensure client has a full understanding of selected diet - oh yeah!</data>
					<data label-text="Interventions / Actions">
								Discuss diet in full, give information leaflets
								Discuss any difficulties that the client feels they may have with the diet
							</data>
					<data label-text="Person / Team Responsible">Dietition</data>
					<data label-text="Review Date">29 October 2007 29:12</data>
					<group collapse-this="N">
						<dataset collapse-this="N">
							<data label-text="Type:">Diet counselling</data>
						</dataset>
						<dataset collapse-this="N" data-cols="3">
							<data label-text="Entered Date:">12 September 2006 12:14</data>
							<data label-text="Update By:">Mike High</data>
							<data label-text="Update Date:">23 October 2007 23:10</data>
						</dataset>
					</group>
				</row>
			</dataset>
		</group>
	</group>
	<group collapse-flagged-groups="Y" collapse-flagged-datasets="Y" css-class="CarePlanProbGroup">
		<dataset collapse-this="Y" data-cols="2">
			<data label-text="Created / Modified By:">Jerry Smith On 27 September 2007 27:11</data>
			<data label-text="Date Entered:">27 September 2007 27:11</data>
		</dataset>
		<dataset collapse-this="N">
			<data>agafgkaf</data>
		</dataset>
		<dataset collapse-this="Y">
			<data label-text="Type:">Constipation</data>
		</dataset>
		<group collapse-this="Y">
			<dataset>
				<row>
					<data label-text="Goal">afkasdjfhjk</data>
					<data label-text="Interventions / Actions">hadkfhjkasd</data>
					<data label-text="Person / Team Responsible">adjkhasdjkhf</data>
					<data label-text="Review Date">29 October 2007 29:12</data>
					<group collapse-this="N">
						<dataset collapse-this="N">
							<data label-text="Type:">Goal setting</data>
						</dataset>
						<dataset collapse-this="N" data-cols="3">
							<data label-text="Entered Date:">23 October 2007 23:12</data>
							<data label-text="Update By:">Noody Burton</data>
							<data label-text="Update Date:">23 October 2007 23:12</data>
						</dataset>
					</group>
				</row>
			</dataset>
		</group>
		<group collapse-this="Y">
			<dataset>
				<row>
					<data label-text="Goal">yep</data>
					<data label-text="Interventions / Actions">yep</data>
					<data label-text="Person / Team Responsible">yep</data>
					<data label-text="Review Date">29 October 2007 29:12</data>
					<group collapse-this="N">
						<dataset collapse-this="N">
							<data label-text="Type:">Diet sheet</data>
						</dataset>
						<dataset collapse-this="N" data-cols="3">
							<data label-text="Entered Date:">27 September 2007 27:11</data>
							<data label-text="Update By:">Summer Sams</data>
							<data label-text="Update Date:">27 September 2007 27:11</data>
						</dataset>
					</group>
				</row>
			</dataset>
		</group>
	</group>

The Dataset elements can have an attribute which is data-cols. This can be any number and denoted the number of columns that should be used to display its child data elements.

So if its data-cols="2" it should be two columns for that data i.e.

<tr>
<td>data1</td><td>data2</td>
</tr>

if it was data-cols="1" then the child data elements need to be 1 col each so would end up like so, over two rows.

<tr>
<td>data1</td>
</tr>
<tr>
<td>data2</td>
</tr>

I'm trying to write the xslt to do that be not getting very far. Any ideas hpw to go about this ?

Cheers
 
if it was data-cols="1"
But this does not appear in your example. Is this to be the default behaviour in the absence of data-cols attribute?

Is there some significance to the fact that only some dataset elements have a subordinate row element. Is this related to the fact that group elements can be embedded in row elements.

Is there some significance to the fact that there seem to be an identical number of data elements as the value of data-cols attribute, when the latter is specified?

The answer to these questions (and maybe even some more questions raised by those answers) will direct us to either a simple xsl:for-each or a recursive solution. An example of your intended output might also be helpful, though probably not mandatory.

Tom Morrison
 
The data-cols attribute can be present on any dataset element and can have any numerical value. By default it is 1.

The best way to describe things is

Group = think of this like a holding table, like a table with one row and one column (really should be a div).

Dataset = think of this like a table with x ammount of columns (set by the 'data-cols' attribute) one col be default. And x ammount of rows. if theres no <row> then its just one row. (i think there could be some <row>'s missing from the example XML will try and clear this up tomorrow).

however from what i've been told the data-col attribute stands from the following:

For non-tabular data, the number of columns to split data elements over.

Hope that helps







 
Hope that helps
Not too much, really. However, I understand that you yourself may be working from rather vague specifications and must muddle through.

I await tomorrow's clarifications. Probably a little too late to draw something out on a napkin at the pub, but I am the type that prefers maps to a list of driving directions. [bigsmile]

Tom Morrison
 
Back again, managed to sort the above problem out once I understood things a little better. But here's a new problem.

Code:
<?xml version="1.0" encoding="utf-8"?>
<now2now xmlns="[URL unfurl="true"]http://www.cse-servelec.com/now2now/genericrenderer"[/URL] xmlns:now2now="[URL unfurl="true"]http://www.cse-servelec.com/now2now/webservice/careplanretrieve"[/URL] id="cpview" rioversion="6" stylesheet="r2rStyles.css">
	<group collapse-flagged-groups="Y" collapse-flagged-datasets="Y" css-class="CarePlanProbGroup">
		<group collapse-this="N" css-class="CarePlanProbDetailsGroup">
			<dataset collapse-this="Y" data-cols="2" css-class="CarePlanProblemHeader">
				<data label-text="Created / Modified By:" label-css-class="CarePlanProblemLabel">Tariq Davidson On 12 September 2006 12:14</data>
				<data label-text="Date Entered:" label-css-class="CarePlanProblemLabel">12 September 2006 12:14</data>
			</dataset>
			<dataset collapse-this="N" css-class="CarePlanProblemHolder">
				<data>Is clinically obese, tablet controlled diabetic</data>
			</dataset>
			<dataset collapse-this="Y" css-class="CarePlanProblemText">
				<data label-text="Type:" label-css-class="CarePlanProblemText">Overweight</data>
			</dataset>
		</group>
		<group collapse-this="Y" css-class="CarePlanGoalGroup">
			<dataset>
				<row css-class="CarePlanGoalHolder">
					<data label-text="Description">To ensure client has a full understanding of selected diet</data>
					<data label-text="Detail">Discuss diet in full, give information leaflets Discuss any difficulties that the client feels they may have with the diet</data>
					<data label-text="Type">Dietition</data>
					<data label-text="Another Field">adasdas</data>
					<data label-text="Yet Another Field">dadasd</data>
					<data label-text="Final Field">adasda</data>
					<data label-text="Client Name">RAMIREZ,James (1000014)</data>
					<data label-text="HCP">ALL</data>
					<data label-text="Start Date">06 November 2007 06:11</data>
					<data label-text="End Date">06 November 2007 06:11</data>
					<group collapse-this="N" css-class="NotSure">
						<dataset collapse-this="N">
							<data label-text="Type:">Diet counselling</data>
						</dataset>
						<dataset collapse-this="N" data-cols="3">
							<data label-text="Entered Date:">12 September 2006 12:14</data>
							<data label-text="Update By:">Nigel Martin</data>
							<data label-text="Update Date:">06 November 2007 06:11</data>
						</dataset>
					</group>
				</row>
			</dataset>
		</group>
	</group>
	<group collapse-flagged-groups="Y" collapse-flagged-datasets="Y" css-class="CarePlanProbGroup">
		<group collapse-this="N" css-class="CarePlanProbDetailsGroup">
			<dataset collapse-this="Y" data-cols="2" css-class="CarePlanProblemHeader">
				<data label-text="Created / Modified By:" label-css-class="CarePlanProblemLabel">Nigel Martin On 29 October 2007 29:16</data>
				<data label-text="Date Entered:" label-css-class="CarePlanProblemLabel">29 October 2007 29:16</data>
			</dataset>
			<dataset collapse-this="N" css-class="CarePlanProblemHolder">
				<data>Oooh, nasty...</data>
			</dataset>
			<dataset collapse-this="Y" css-class="CarePlanProblemText">
				<data label-text="Type:" label-css-class="CarePlanProblemText">Inflammatory bowel</data>
			</dataset>
		</group>
		<group collapse-this="Y" css-class="CarePlanGoalGroup">
			<dataset>
				<row css-class="CarePlanGoalHolder">
					<data label-text="Description">asdasd</data>
					<data label-text="Detail">adasd</data>
					<data label-text="Type">adasdad</data>
					<data label-text="Start Date">29 October 2007 29:16</data>
					<group collapse-this="N" css-class="NotSure">
						<dataset collapse-this="N">
							<data label-text="Type:">Goal setting</data>
						</dataset>
						<dataset collapse-this="N" data-cols="3">
							<data label-text="Entered Date:">29 October 2007 29:16</data>
							<data label-text="Update By:">Nigel Martin</data>
							<data label-text="Update Date:">29 October 2007 29:16</data>
						</dataset>
					</group>
				</row>
			</dataset>
		</group>
	</group>
</now2now>

This is the XML i'm working with at the moment, It's a sort of generic XML which has been generated from more specific XML.

What i'm tryng to do at the moment is add some javascript to hide and show datasets which have the collapse-this="Y" attribute.

Little background on the XML.
The XML represents problems and within the problems are goals. The first group element with the attribute css-class="carePlanProbGroup" represent a problem
theres crrently 2 problems in the XML but potentially there could be many.

Within this problem group theres a group with the following attribute css-class="CarePlanGoalGroup". This represents the problem within the group.
Again there could be many problems per problem.

The bit i'm focusing on is the datasets with the collapse-this="Y" directly within the problem node.
I'm currently checking for the presence of the collapse-flagged-datasets="Y" in the group node and if this is 'Y' then i'm calling a template which will
create a table with an icon, i'm going to attach some javascript to this icon which will hide or show the dataset elements with the collapse-this="Y".

My problem is that in order to hide and show the datasets (which get turned in to indvidual html table) I need to say at an id="#####" to each table so I can uniquly identify them. Then also add the nessesary ID's to the javascript call. e.g.
Code:
<table class="CarePlanProblemHeader" id="g1d1">
<tr>
	<td><label class="CarePlanProblemLabel">Created / Modified By:</label><span class="">Tariq Davidson On 12 September 2006 12:14</span></td>
	<td><label class="CarePlanProblemLabel">Date Entered:</label><span class="">12 September 2006 12:14</span></td>
</tr>
</table>
<table class="CarePlanProblemHolder">
<tr>
	<td><label class=""></label><span class="">Is clinically obese, tablet controlled diabetic</span></td>
</tr>
</table>
<table class="CarePlanProblemText" id="g1d3">
<tr>
	<td><label class="CarePlanProblemText">Type:</label><span class="">Overweight</span></td>
</tr>
</table>
Then the javascript call
<img src="/images/expand-left.gif" title="Expand/Collapse Problem" onClick="hideTables(g1d1, g1d3)">

The Id's above represent g1 = group1 d1 = dataset1, so for the 2nd problem the id's would be g2d1 , g2d3 etc and for the 3rd problem g3d1, g3d3

Not sure if this is the best way to go about things, but doing it this way i'm having problems working out how to generate the g*d* id's . I can do the d* bit by doing a substring on the current node (assuming i'm using a template which is cycling through the dataset nodes within the group) then position(). e.g.

<xsl:param name="currentNode" select="name(.)"/>
<xsl:param name="currentNodeConcat" select="substring($currentNode,1, 1)"/>
<xsl:param name="CombinedData" select="concat($currentNodeConcat,position())"/>

But I can't seem to get the correct position for the groups as it always returns 1 even if i'm in the elements for problem 2 (group2).

I know this is a long shot with regards understanding what the hell is going on but hopefully someone out there might :)

Any questions to clear things up ask away.
 
It depends very much on how you set up the data-set. Having no idea on it, do this.
><xsl:param name="CombinedData" select="concat($currentNodeConcat,position())"/>
[tt]<xsl:param name="CombinedData" select="concat($currentNodeConcat,[blue]count(preceding-sibling::group)+1[/blue])"/>[/tt]
 
just tried that and getting d1 for all the ID's now :(

heres the xslt i've got so far. The line with your change is on about 83

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:now2now="[URL unfurl="true"]http://www.testnow.com/now2now/webservice/care"[/URL] xmlns:gr="[URL unfurl="true"]http://www.testurl.com"[/URL] exclude-result-prefixes="now2now gr">
	<xsl:output method="html" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
	
	<xsl:template match="/">
		<xsl:apply-templates />
	</xsl:template>
	
	<!-- Template to match the now2now element -->
	<xsl:template match="gr:now2now">
			<html>
				<head>
					<title>Test page</title>
					<link href="{@stylesheet}" rel="stylesheet" type="text/css" />
				</head>
				<body>
					<div class="holder">
						<xsl:apply-templates />
					</div>
				</body>
			</html>
	</xsl:template>
		
	<!-- This is the template to handle group elements -->
	<xsl:template match="gr:group">
		<xsl:choose>
			<xsl:when  test="name(..) = 'row'">
			<tr>
			<td>
				<table class="{@css-class}">
					<tr>
						<td>
							<xsl:apply-templates />
						</td>
					</tr>
				</table>
			</td>
			</tr>
			</xsl:when>
			<xsl:otherwise>
				<table class="{@css-class}">
					<tr>
						<td>
							<xsl:apply-templates />
						</td>
						<xsl:if test="(../@collapse-flagged-groups='Y' or ../@collapse-flagged-datasets='Y' ) and @collapse-this='N'">
							<td width="10%">
								<xsl:if test="../@collapse-flagged-groups='Y' ">
									<xsl:call-template name="displayDatasetCollapse"/>
								</xsl:if>
								<xsl:if test="../@collapse-flagged-datasets='Y'">
									<xsl:call-template name="displayGroupCollapse"/>
								</xsl:if>
							</td>
						</xsl:if>
					</tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>	
	
		<xsl:template name="displayDatasetCollapse">
			<img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test"></img>
		</xsl:template>
		
		<xsl:template name="displayGroupCollapse">
			<img src="../common/images/expand-down.gif" height="25" width="25" title="Expand/Collapse Intervention"></img>
		</xsl:template>
	<!-- 
		This is the template for a dataset
		 A Dataset is basically a table with X number of columns defined by  the
		attribute data-cols, i data-cols doesn't exists the col number is 1
	 -->
	<xsl:template match="gr:dataset">
		<xsl:param name="parentNode" select="name(..)"/>
		<xsl:param name="currentNode" select="name(.)"/>
		<xsl:param name="currentPosition" select="position()"/>
		
		<xsl:param name="parentNodeConcat" select="substring($parentNode,1, 1)"/>
		<xsl:param name="currentNodeConcat" select="substring($currentNode,1, 1)"/>

		<!--<xsl:param name="CombinedData" select="concat($parentNodeConcat,$currentNodeConcat,position())"/>-->
		<xsl:param name="CombinedData" select="concat($currentNodeConcat,count(preceding-sibling::group)+1)"/>
		<xsl:value-of select="$CombinedData"/>

		<xsl:choose>
			<xsl:when test="@collapse-this='Y'">
				<table class="{@css-class}" id="{$CombinedData}">
						<xsl:apply-templates />
				</table>
			</xsl:when>
			<xsl:otherwise>
				<table class="{@css-class}">
					
						<xsl:apply-templates />
					
				</table>
			</xsl:otherwise>
		</xsl:choose>
		
		
	</xsl:template>
	
	<xsl:template name="multiColDataset">
	
		
		
			<!--
				 If the position() is less than orequal to the 
				@data-cols value display col , else it need to be on
				 a new row.
			-->
			<xsl:choose>
				<xsl:when test="position() &lt;= ../@data-cols">
				<td>
					<xsl:value-of select="position()"/>
					<xsl:text>9909</xsl:text>
					<xsl:call-template name="standdata"/>
				</td>
				</xsl:when>
				<xsl:otherwise>
					<tr>
						<td>
							<xsl:value-of select="position()"/>
							<xsl:text>9909</xsl:text>
							<xsl:call-template name="standdata"/>
						</td>
					</tr>
				</xsl:otherwise>
			</xsl:choose>
		
		
	</xsl:template>
	
	<xsl:template name="singleColDataset">
			<tr>
				<td>
					<xsl:for-each select=".">
						<xsl:call-template name="standdata"/>
					</xsl:for-each>
				</td>
			</tr>
	</xsl:template>
	
	<xsl:template match="gr:data">
			<!-- Get the data-cols attrbute and decide what to do 	-->
				<xsl:choose>
					<xsl:when test="../@data-cols &gt; 1">
						<xsl:call-template name="multiColDataset" />
					</xsl:when>
					<xsl:when test="name(..) = 'row' ">
					
						<xsl:call-template name="rowdata" />
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="singleColDataset" />
					</xsl:otherwise>
				</xsl:choose>		
	</xsl:template>
	
	<xsl:template name="standdata">
		<label class="{@label-css-class}"><xsl:value-of select="@label-text"/></label><span class="{@css-class}"><xsl:value-of select="."/></span>
	</xsl:template>
	
	<xsl:template match="gr:row">
		<tr>
			<td>
				<xsl:call-template name="rowdataheaders"/>
				<table class="{@css-class}">
					<tr>
						<td>
							<table>
								<tr>
									<xsl:apply-templates select="gr:data"/>
								</tr>
							</table>
						</td>
					</tr>
						<xsl:apply-templates select="gr:group" />
				</table>
			</td>
		</tr>
	</xsl:template>
	
	
	<!-- 
		This is the template for the rowheaders,  
		here data elements which are direct children of
		the row element are used for headers of tables
	 -->
	<xsl:template name="rowdataheaders">
	
		<xsl:param name="tableCellWidth"><xsl:value-of select="100 div count(gr:data[@label-text])"/></xsl:param>
		
			<table class="{@css-class}">
					<tr>
						<xsl:for-each select="gr:data">
							<th width="{$tableCellWidth}%"><xsl:value-of select="@label-text"/></th>
						</xsl:for-each>
					</tr>
			</table>
	</xsl:template>
	
	<xsl:template name="rowdata">
	
		<xsl:param name="tableCellWidth"><xsl:value-of select="100 div count(../gr:data)"/></xsl:param>
		<td width="{$tableCellWidth}%"><xsl:value-of select="."/></td>
	</xsl:template>
	
</xsl:stylesheet>
 
Perhaps this will help?
Code:
        <xsl:param name="CombinedData" select="concat($currentNodeConcat,count(preceding-sibling::[COLOR=white blue]gr:dataset[/color])+1)"/>
<group> is an ancestor, and you need the namespace too.

Tom Morrison
 
tried the change with a slight alteration as I need the group now the dataset.

<xsl:param name="CombinedData" select="concat($parentNodeConcat,count(ancestor::gr:group)+1)"/>

But its just giving me the number of ancestors which will always be 3 as you can see from the XML theres always 2 group elements and the now2row element. Which is the same for both problem groups.

I need a way of uniquely identifying the group that there in.

i.e. for the first problem I need the id to be smething like G1D1 amd G1D2 then for the 2nd problem the ID's will be G2D1 and G2D2.

Bit how do I get it to tell me that the group i'm in is X position relative to the root element as I assume that would make it unique if I get this value ?
 
Code:
        <xsl:param name="parentNodeConcat" select="concat(substring($parentNode,1, 1),count(../preceding-sibling::gr:group)+1)"/>
        <xsl:param name="currentNodeConcat" select="concat(substring($currentNode,1, 1),count(preceding-sibling::gr:dataset)+1)"/>

        <xsl:param name="CombinedData" select="concat($parentNodeConcat,$currentNodeConcat)"/>
Consider the XPath expression
Code:
../preceding-sibling::gr:group
Interpretation: return the set of <gr:group> sibling elements preceding my parent. Once you eliminate the confusion of count(), and think in terms of the node set returned by an XPath expression, perhaps it becomes clearer.

Tom Morrison
 
thanks mate for the reply.
just tried the code and was still display the G1** for all, i've added an extr ../ onto the parentNodeParameter and that now seems to be calculating the number correctly :)

is there now a way I can collate the id's for seperate problems and pass them to the displayDatasetCollapse template as in the template I need to add a javascript onClick call on the image to a function to hide and show the id's

e.g. onClick="hidetables(G1D1, G1D3)"

Thanks again for the help
 
Now that we have a change to see when the named template will be called - under what context, I think the modified line is largely insufficient.

[1] It is now with $currentNodeConcat whereas before it is $parentNodeConcat. Why is that?

[2] Furthermore, to obtain the declared intention of g(m)d(n), you need four components, but there is only two!

[3] With the nested "group" tag, it is only by fortune that the g in the g(m)d(n) be obtained from the parent of dataset, which is by fortune be a group tag. The g should be obtained from the parent (group)/parent (row)/parent (dataset)/parent (group with @cssPlanGoalGroup attribute).

[4] In any case, try this see if it results to a temporarily satisfactory id.

><xsl:param name="CombinedData" select="concat($currentNodeConcat,count(preceding-sibling::group)+1)"/>

[tt]<xsl:param name="CombinedData"
select="concat(
$parentNodeConcat,
count(parent::*/parent::*/parent::*/parent::*/preceding-sibling::gr:group)+1,
$currentNodeConcat,
position())"
/>[/tt]

[5] Your design with proliferation of "group" tag is rendering quick the xml unmanageable.
 
Further note:

I don't know if it should enter this as an amendment... but there is such a tag soup of "data" and "group"... that it can only cause trouble sooner or later.

[4[red]-alt[/red]] Since the context of dataset can be coming from problem and goal, the parental structure are very different. Hence, it is not impossible to get what op seems intended, it has to be treated separately. Hence, if the intention is properly assessed, the [4] could be revised to this alternative.
[tt]
<xsl:param name="CombinedData">
<xsl:if test="../../@css-class='CarePlanProbGroup'">
<xsl:value-of select="concat(
$parentNodeConcat,
count(../../..preceding-sibling::*[local-name()='group'])+1,
$currentNodeConcat,
position())"
/>
</xsl:if>
<xsl:if test="../../@css-class != 'CarePlanProbGroup'">
<xsl:value-of select="concat(
$parentNodeConcat,
count(../../../../preceding-sibling::*[local-name()='group'])+1,
$currentNodeConcat,
position())"
/>
</xsl:if>
</xsl:param>
[/tt]
ps: Since "parent::*" starts to annoy, I use here its abbreviated form "..".
 
thanks mate will work through your suggestion later tonight or tomorrow as i'm in the middle of a format :(

just a little note that might alter your suggestion.

I wouldn't rely of the css-class='CarePlanProbGroup' attribute as this might not be in the xml. same with any other css-class attribute.

This xslt has got to be very generic as the structure of the XML can change would it help if I posted the schema for this generic xml document as it'll explain the group / dataset / data combinations.
 
Further notes (2)

[4.a.2] The idea to obtain the m in g(m)d(n) is to properly get to the ProbGroup, whereas the param whenever it is being called is when the context is dataset. However, in the GoalGroup, there are two sorts of dataset of different depth. That is the idea for the two if. If the use of css-class is not generic signature of ProbGroup, you can use the fact that the grand-parent of the 2nd (deeper) dataset in GoalGroup is "row" not "group" as a generic signature. The param CombinedData (eventually appeared as id of tables) can be calculated like this.
[tt]
<xsl:param name="CombinedData">
<xsl:if test="[blue]local-name(../..)='group'[/blue]">
<xsl:value-of select="concat(
$parentNodeConcat,
count(../..[highlight]/[/highlight]preceding-sibling::*[local-name()='group'])+1,
$currentNodeConcat,
position())"
/>
</xsl:if>
<xsl:if test="[blue]local-name(../..)='row'[/blue]"> <!-- or [blue]!='group'[/blue] -->
<xsl:value-of select="concat(
$parentNodeConcat,
count(../../../../preceding-sibling::*[local-name()='group'])+1,
$currentNodeConcat,
position())"
/>
</xsl:if>
</xsl:param>
[/tt]
ps: Just a note that I had a ".." left out in the [4.a] at the highlighted part here which should not be there.
 
right back in action after the format, remind me never to install a 64bit OS again.

Just tested you last bit of code and after altering my parentNodeConcat and currentNodeConcat by removing the position bits its seems to be working fine. Thanks

This xslt is now producing the following html

Code:
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Test page</title>
		<link href="r2rStyles.css" rel="stylesheet" type="text/css">
	</head>
	<body>
		<div class="holder">
			<table class="CarePlanProbGroup">
				<tr>
					<td>
						<table class="CarePlanProbDetailsGroup">
							<tr>
								<td>
									<table class="CarePlanProblemHeader" id="g1d1">
										<td><label class="CarePlanProblemLabel">Created / Modified By:</label><span class="">Tariq Davidson On 12 September 2006 12:14</span></td>
										<td><label class="CarePlanProblemLabel">Date Entered:</label><span class="">12 September 2006 12:14</span></td>
									</table>
									<table class="CarePlanProblemHolder">
										<tr>
											<td><label class=""></label><span class="">Is clinically obese, tablet controlled diabetic</span></td>
										</tr>
									</table>
									<table class="CarePlanProblemText" id="g1d3">
										<tr>
											<td><label class="CarePlanProblemText">Type:</label><span class="">Overweight</span></td>
										</tr>
									</table>
								</td>
								<td width="10%"><img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test"><img src="../common/images/expand-down.gif" height="25" width="25" title="Expand/Collapse Intervention"></td>
							</tr>
						</table>
						<table class="CarePlanGoalGroup">
							<tr>
								<td>
									<table class="">
										<tr>
											<td>
												<table class="CarePlanGoalHolder">
													<tr>
														<th width="10%">Description</th>
														<th width="10%">Detail</th>
														<th width="10%">Type</th>
														<th width="10%">Another Field</th>
														<th width="10%">Yet Another Field</th>
														<th width="10%">Final Field</th>
														<th width="10%">Client Name</th>
														<th width="10%">HCP</th>
														<th width="10%">Start Date</th>
														<th width="10%">End Date</th>
													</tr>
												</table>
												<table class="CarePlanGoalHolder">
													<tr>
														<td>
															<table>
																<tr>
																	<td width="10%">To ensure client has a full understanding of selected diet</td>
																	<td width="10%">Discuss diet in full, give information leaflets Discuss any difficulties that the client feels they may have with the diet</td>
																	<td width="10%">Dietition</td>
																	<td width="10%">adasdas</td>
																	<td width="10%">dadasd</td>
																	<td width="10%">adasda</td>
																	<td width="10%">RAMIREZ,James (1000014)</td>
																	<td width="10%">ALL</td>
																	<td width="10%">06 November 2007 06:11</td>
																	<td width="10%">06 November 2007 06:11</td>
																</tr>
															</table>
														</td>
													</tr>
													<tr>
														<td>
															<table class="NotSure">
																<tr>
																	<td>
																		<table class="">
																			<tr>
																				<td><label class="">Type:</label><span class="">Diet counselling</span></td>
																			</tr>
																		</table>
																		<table class="">
																			<td><label class="">Entered Date:</label><span class="">12 September 2006 12:14</span></td>
																			<td><label class="">Update By:</label><span class="">Jeff Hall</span></td>
																			<td><label class="">Update Date:</label><span class="">06 November 2007 06:11</span></td>
																		</table>
																	</td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<table class="CarePlanProbGroup">
				<tr>
					<td>
						<table class="CarePlanProbDetailsGroup">
							<tr>
								<td>
									<table class="CarePlanProblemHeader" id="g2d1">
										<td><label class="CarePlanProblemLabel">Created / Modified By:</label><span class="">Jeff Hall On 29 October 2007 29:16</span></td>
										<td><label class="CarePlanProblemLabel">Date Entered:</label><span class="">29 October 2007 29:16</span></td>
									</table>
									<table class="CarePlanProblemHolder">
										<tr>
											<td><label class=""></label><span class="">Oooh, nasty...</span></td>
										</tr>
									</table>
									<table class="CarePlanProblemText" id="g2d3">
										<tr>
											<td><label class="CarePlanProblemText">Type:</label><span class="">Inflammatory bowel</span></td>
										</tr>
									</table>
								</td>
								<td width="10%"><img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test"><img src="../common/images/expand-down.gif" height="25" width="25" title="Expand/Collapse Intervention"></td>
							</tr>
						</table>
						<table class="CarePlanGoalGroup">
							<tr>
								<td>
									<table class="">
										<tr>
											<td>
												<table class="CarePlanGoalHolder">
													<tr>
														<th width="25%">Description</th>
														<th width="25%">Detail</th>
														<th width="25%">Type</th>
														<th width="25%">Start Date</th>
													</tr>
												</table>
												<table class="CarePlanGoalHolder">
													<tr>
														<td>
															<table>
																<tr>
																	<td width="25%">asdasd</td>
																	<td width="25%">adasd</td>
																	<td width="25%">adasdad</td>
																	<td width="25%">29 October 2007 29:16</td>
																</tr>
															</table>
														</td>
													</tr>
													<tr>
														<td>
															<table class="NotSure">
																<tr>
																	<td>
																		<table class="">
																			<tr>
																				<td><label class="">Type:</label><span class="">Goal setting</span></td>
																			</tr>
																		</table>
																		<table class="">
																			<td><label class="">Entered Date:</label><span class="">29 October 2007 29:16</span></td>
																			<td><label class="">Update By:</label><span class="">Jeff Hall</span></td>
																			<td><label class="">Update Date:</label><span class="">29 October 2007 29:16</span></td>
																		</table>
																	</td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>

My question now is about using these ID's
in the html above for the img tabs in the problem groups

<img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test">

I need to include a javascript call so that when You click the image to hides the tables with the ID's on in that problem group only.

e.g.
for the first problem with the tables that got id's of G1D1 and G1D3 I need the img tag to look like the following.

<img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test" onclick = "hideTable('G1D1', 'G1D3)">

and for the seccond problem group the img tag needs to be
<img src="/images/expand-left.gif" height="25" width="25" title="Expand/Collapse Problem" alt="test" onClick="hideTables('G2D1', G2D3)">

Not sure how i'm going to get the id's e've just generated into the onClick function call ?

Thanks for the help so far


 
Little update:

Managed to work out the coding needed for my last bit so all good and well..

Thanks again mate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top