Jump to content

xsl:value-of select


zezu10

Recommended Posts

hey guys. in need of some help. obviously :)I've been handed a half done task and asked to fix it, obviously some of you may know the problems of trying to fix other peoples problems but I hope you can do it for me.More or less, what I have is a stylesheet to help output invoice data, and what seems to be happening is in this part of the code

  <xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<td class="style16"> <xsl:value-of select="C[27]"/></td>	<td class="style16"> <xsl:value-of select="C[28]"/></td>	<td class="style16"> <xsl:value-of select="C[29]"/></td>	<td class="style16"> <xsl:value-of select="C[30]"/></td>	<td class="style16"> <xsl:value-of select="C[31]"/></td>	<td class="style16"> <xsl:value-of select="C[32]"/></td>	<td class="style16"> <xsl:value-of select="C[33]"/></td>	<td class="style16"> <xsl:value-of select="C[34]"/></td>	<td class="style16"> <xsl:value-of select="C[35]"/></td>  </tr>

The problem is that there are multiple lines of data, as in more than one record but what seems to be happening is that in each table of the output, the data is all looped.For example what should look like;ItemItemItemlooks like Item Item ItemIs there anyway around this, I've looked at the properties of value-of select and having found much.This is probably very unclear :/Apoligies.

Link to comment
Share on other sites

That's not value-of's fault. It's the <td>'s fault.A <tr> defines a data to be on a single row. A <td> defines a cell on that row. Cells on one row are of course displayed on one row.There are few things you can do here, but it really doesn't involve the XSLT namespace. Only the XHTML it will output.Side note. Instead of repeating value-of 9 times, you could do a ranged selection:

  <xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<xsl:for-each select="C[position() >= 27 and postion() <= 35"> 	  <td class="style16"> <xsl:value-of select="."/></td>	</xsl:for-each>  </tr>

Link to comment
Share on other sites

so what would be the best way to work around that then? as I've tried to tinker with the coding but the system either doesn't like it or hikes the data all over the page :/I also tried to enter the ranged selection code but it doesn't display that either.I'm using a software program that is specifically for the company, and doesn't display what errors are actually there, which isn't very helpful.As I said I've just been handed this half done code, which supposedly worked when the last person wrote it, but obv, she deleted the file and only left a really bad document.If anyone could help me, I'll buy them a cyber pint :)

Link to comment
Share on other sites

Sorry. I had a typo and I missed a "]" just before the quotes:

  <xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<xsl:for-each select="C[position() >= 27 and position() <= 35]"> 	  <td class="style16"> <xsl:value-of select="."/></td>	</xsl:for-each>  </tr>

Well, as I said, you could do many things but it really depends on what the complete output looks like and what would be nice for it. For example, one thing you could do is put a list in a single table cell to hold all of the items:

<xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<td class="style16">	  <ul>		<xsl:for-each select="C[position() >= 27 and position() <= 35]"> 		  <li><xsl:value-of select="."/></li>		</xsl:for-each>	  </ul>	</td>  </tr>

If you could show me what are those cells actually having, I might give you a more sematical code for that.

Link to comment
Share on other sites

Ok, so is the above list solution working for you or not? And... no offence, but don't you know HTML? Everything that doesn't begin with "xsl:" is plain HTML here.

Link to comment
Share on other sites

Ok, so is the above list solution working for you or not? And... no offence, but don't you know HTML? Everything that doesn't begin with "xsl:" is plain HTML here.
no offence takenmy html knowedge is limited, I'm off the dreamweaver and frontpage generation. sorry heh.
  <xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<xsl:for-each select="C[position() >= 27 and position() <= 35]"> 	  <td class="style16"> <xsl:value-of select="."/></td>	</xsl:for-each>  </tr>

that at the moment is working, but it's obviously pushing out exactly the same data as I had before.

<xsl:for-each select="key('DATA',C[6])">   <tr class="style16">	<td class="style16">	  <ul>		<xsl:for-each select="C[position() >= 27 and position() <= 35]"> 		  <li><xsl:value-of select="."/></li>		</xsl:for-each>	  </ul>	</td>  </tr>

That however, just placed all the grouped data I have in a one large list, which obviously isn't what is needed.I need 9 columns of data, and all the seperate records in a new line.Sorry if I'm being an utter goon here :)

Link to comment
Share on other sites

I was afraid you'll say that.Well, isn't there a chance you could reverse the data from getting in columns to getting in rows? Like instead of:QTY ----- 125325325You do:Q|133T|222Y|555Working across rows for the sake of columns is just a disaster waiting to happen.If you accept the inversion and can present the whole table's code, I could invert it for you.

Link to comment
Share on other sites

I was afraid you'll say that.Well, isn't there a chance you could reverse the data from getting in columns to getting in rows? Like instead of:QTY ----- 125325325You do:Q|133T|222Y|555Working across rows for the sake of columns is just a disaster waiting to happen.If you accept the inversion and can present the whole table's code, I could invert it for you.
no am afraid I can't do that.the output of the stylesheet needs to replicate company invoices, therefore the data must be in columns.I'll tinker with it.I seem to have got some columns to place the data veritically into rows, but for some reason it's not working on the very first column.all the stylesheets I've ever written have been for formatting purposes for websites, never to position database data into a PDF replica type software lol, so am working as I go am afraid :/
Link to comment
Share on other sites

Could I...edit the Templates to help with this?For example there are Templates like...

<xsl:template match="TABLE/DATA"><xsl:call-template name="Style"/><xsl:for-each select="//R[generate-id(.)=generate-id(key('DATA',C[6]))]"><table border="0" cellpadding="0" cellspacing="0" width="80%" align="centre"><tr>

Would that help? or am I currently holding a load of straws?

Link to comment
Share on other sites

The XSLT template is good. There's no need to touch it on the levels above. Only on theese levels.OK. I think I have a solution, but it's not something I encourage as a good practice and it's not a straight forward way either. It's called "Nested tables":

<tr class="style16">   <xsl:for-each select="key('DATA',C[6])">	<td class="style16">	  <table>		<xsl:for-each select="C[position() >= 27 and position() <= 35]">		  <tr>			<td><xsl:value-of select="."/></td>		  </tr>		</xsl:for-each>	  </table>	</td>  </xsl:for-each></tr>

I repeat: IT'S NOT A GOOD CODING PRACTICE! But it does have the visual effect you're looking for.

Edited by boen_robot
Link to comment
Share on other sites

Hey. Well, being the eager young man I am I started asking questions, and have more or less discovered that the database that the stylesheet is taking the information from is at fault for the grouped data, therefore the stylesheet is correct, as I tested it on another group of data.But once I get the database fixed I'll give ye all a shout if I have anymore problems.Thanks for your help, MUCH APPRECIATED!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...