XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 16th, 2004, 04:39 AM
Phrenetical Phrenetical is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 156 Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 sec
Reputation Power: 9
Exclamation XML for each (TWO seperate columns of XML data)

OK guys, this one has got me stumped.

Im using
- <xsl:for-each select="TYRE">
then do what my XSL tells you to do

then it prints out my html, but i can only print out one column of data, for example please view
http://www.theshadownest.com.au/tyr...stock/tyres.xml

What i want to be able to do, is print out two columns of data from my XML, so the table you see there would have a companion table next to it, with more tyre stock in it.

So far all i can do is make is print out a second identical table next to it, i dont want this, i want it to read the XML elements, like

tyre 1 - - tyre 2
tyre 3 - - tyre 4
tyre 5 - - tyre 6
tyre 7 - - tyre 8

as apposed to

tyre 1 - - tyre 1
tyre 2 - - tyre 2
tyre 3 - - tyre 3
tyre 4 - - tyre 4

heres a link to my XSL

XSL tyre express

most of the top part is just HTML, scroll down to where u see
<xsl:template match="EQUUS">
<xsl:for-each select="TYRE">
thats where the XSL really is

thanks guys

Reply With Quote
  #2  
Old August 16th, 2004, 08:16 AM
Teflon's Avatar
Teflon Teflon is offline
Teflon The Black
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Woodbridge VA
Posts: 246 Teflon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 28 m 14 sec
Reputation Power: 5
Send a message via AIM to Teflon
This is what I used to solve this problem on my sites.

You would have to set a container to the size of the two columns so that they do not go into more than 2 columns.


http://www.htmlhelp.com/reference/css/box/float.html
__________________
Teflon - The Black <desc>Mark This Up</desc>

Reply With Quote
  #3  
Old August 16th, 2004, 08:34 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I'd rather go to a solution like this one, ie: displaying tag having an odd position() into column 1, and those having an even position() into column 2.

Code:
...
<tr>
  <td>
    <xsl:apply-templates select="//yourtag[(position() mod 2) = 1]" />
  </td>
  <td>
    <xsl:apply-templates select="//yourtag[(position() mod 2) = 0]" />
  </td>
</tr>
...


Not tested, but that should work.

Reply With Quote
  #4  
Old August 17th, 2004, 12:25 AM
Phrenetical Phrenetical is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 156 Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 sec
Reputation Power: 9
No sorry bro no luck with your above code, instead of displaying tables in two seperate columns, it was formatting them one under the other in one column

eg..

tyre 1 -
tyre 2 -
tyre 3 -

Iv been trying to use the mod position command as well, it should work, i dont understand why it doesnt, iv also tried using a choose staement, with position mod command, but still no luck.

Any more help u could offer would be most appreciated.

here is what my code looked like after adding in yours, just for your scrutiny

<tr>
<td>
<xsl:apply-templates select="EQUUS[(position() mod 2) = 1]" />
</td>
<td>
<xsl:apply-templates select="EQUUS[(position() mod 2) = 0]" />
</td>
</tr>
if i missed something, or applied it worng, please let me know

Reply With Quote
  #5  
Old August 17th, 2004, 12:34 AM
Phrenetical Phrenetical is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 156 Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 sec
Reputation Power: 9
Also if i use the code

<tr>
<td>
<xsl:apply-templates select="EQUUS[(position() mod 2) = 1]" />
</td>
<td>
<xsl:apply-templates select="EQUUS[(position() mod 2) = 1]" />
</td>
</tr>

It keeps my formatting of the tables, and prints out two columns but both identical, as soon as i change the second position mod to = 2 it reformats it one column again.

so im assuming the xml doesnt understand the second mod position, because my TD cells still remain there, but it just doesnt write anything into them when it it is set to = 2.

any ideas

Reply With Quote
  #6  
Old August 17th, 2004, 05:48 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
That's right.. if you don't need to have one table row per actual row, then my solution is still fine, I just tested it, and I have two TD's with all the right values below one another.

xml:
Code:
<MyRoot> 
	<MyTag Value="001" />
	<MyTag Value="002" />
	<MyTag Value="003" />
	<MyTag Value="004" />
	<MyTag Value="005" />
	<MyTag Value="006" />
	<MyTag Value="007" />
	<MyTag Value="008" />
</MyRoot>


xsl:
Code:
<table border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td class="left">
      <xsl:apply-templates select="MyTag[(position() mod 2) = 1]" />
    </td>
    <td class="right">
      <xsl:apply-templates select="MyTag[(position() mod 2) = 0]" />
    </td>
  </tr>
</table>

+ this template:

<xsl:template match="MyTag">
  <xsl:value-of select="@Value" /><br />
</xsl:template>


Don't forget the <br> at the end.

This produces the following output:
001 002
003 004
005 006
007 008

But as one HTML row. I'm still checking if doing the same over multiple rows is feasible, I'm not too sure it is.

Reply With Quote
  #7  
Old August 17th, 2004, 10:01 AM
Phrenetical Phrenetical is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 156 Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 sec
Reputation Power: 9
Hey dude thanks for the help, but i still cant get it to work

i copied your above code and made a new xml/xsl file using your code only, and absolutly nothing appeared when i opened the xml, dont worry i have the files linked correctly,

I dont know hey, im stumped, am i using the wrong namespace?, or doctype?? but yeah i couldnt get even your simple code there to work on my end.

I then changed your code to

Code:
<table border="1" cellpadding="0" cellspacing="0" width ="200" height="200">
  <tr>
    <td class="left">
      <xsl:apply-templates select="MyRoot[(position() mod 2) = 1]" />
    </td>
    <td class="right">
      <xsl:apply-templates select="MyRoot[(position() mod 2) = 0]" />
    </td>
  </tr>
</table>


and it outputed the xml values but again one under the other,
eg..
value 1
value 2
value 3
etc..

why is it not formatting it properly, again, thanks for the help so far

Reply With Quote
  #8  
Old August 17th, 2004, 04:32 PM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
weird.. wouldn't you have forgotten a few stuff ? just to be sure, here's the full code of my xsl file:

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"               xmlns="http://www.w3.org/1999/xhtml">

<xsl:template match="MyRoot">
 <html>
  <head>
   <title>Test</title>
   <style type="text/css">
     .left	{ color: #FF0000; }
     .right	{ color: #0000FF; }
   </style>
  </head>
  <body>    
   <table border="1" cellpadding="0" cellspacing="0">
    <tr>
     <td class="left">
      <xsl:apply-templates select="MyTag[(position() mod 2) = 1]" />
     </td>
     <td class="right">
      <xsl:apply-templates select="MyTag[(position() mod 2) = 0]" />
     </td>
    </tr>
   </table>
  </body>
 </html>
</xsl:template>

<xsl:template match="MyTag">
  <xsl:value-of select="@Value" /><br />
</xsl:template>

</xsl:stylesheet>


That works on my machine.

Reply With Quote
  #9  
Old August 17th, 2004, 10:23 PM
Phrenetical Phrenetical is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 156 Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level)Phrenetical User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 sec
Reputation Power: 9
Dude you are a legend, champion, xml guru.

Ok i got it to work perfect, heres what i did, couldnt have done it without u.

OK, first, if you look in my XSL, iv been lazy and used

Code:
<xsl:template match="/">


To match the top element of my XML, i should have used the name of the top element (EQUUS) not the /

SO then i put your code back into my XSL, eg
Code:
<tr>
<td>
<xsl:apply-templates select="TYRE[position() mod 2 = 1]" />
</td>
<td>
<xsl:apply-templates select="TYRE[position() mod 2 = 0]" />
</td>
</tr>


But was still not working, so i thought, wait, if the position tag is now selecting my TYRE 's i dont need the XSL for:each command anymore, so i removed that from my TYRE template.

And bang!, works, thanks heaps man, you saved me programming this all again in java. If i could buy you a beer i would, damit wheres that little emoticon with the beer!, not here, oh well.

Later and thanks again

Reply With Quote
  #10  
Old August 18th, 2004, 08:13 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Glad you like it

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML for each (TWO seperate columns of XML data)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT