|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
n00b having problems with the output display
having problems displaying this table correctly (after XSL/XML)
here is the original HTML (excluding addition of 1 HR, and an IMG tag...): PHP Code:
here is the XSL: PHP Code:
and here is the XML (for demo only): PHP Code:
All help appreciated.. |
|
#2
|
|||
|
|||
|
um, what's the display problem? i.e. is there a row not rendering, or the images don't match up or something? what browser have you tried this in?
|
|
#3
|
|||
|
|||
|
Instead of using
<xsl:template match="/"> Which is lazy try something like <xsl:template match="posts"> ... ... <xsl:for-each select="post"> That will help you a little but as stated above i have no idea whats going wrong because you didnt specify. ALSO, format your coding tags properly, its in rules if you read them, im talking about your huge line of the XSL display code, next time Code:
<tr>
<td width="20" height="20" style="width:20px;height:20px;background:url('lefttop.gif');background-repeat:no-repeat;"/>
<td colspan="1" rowspan="4" width="120" valign="top" style="padding-top:2px;background:url('border-horiz-repeat.gif');background-repeat:repeat-x;background-position:top;">
<img>
<xsl:attribute name="src">
<xsl:value-of select="@imgpath"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="@user"/>
</xsl:attribute>
</img><br/>
<xsl:value-of select="@inf"/><hr/>
<xsl:value-of select="@date"/></td>
<td colspan="1" width="4" rowspan="5" bgcolor="#808080"/>
<td colspan="1" rowspan="2" height="20" width="311" valign="top" style="height:20px;padding-top:2px;background:url('border-horiz-repeat.gif');background-repeat:repeat-x;background-position:top;">
<xsl:value-of select="@title"/></td>
<td width="20" height="20" style="width:20px;height:20px;background:url('righttop.gif');background-repeat:no-repeat;"> </td>
</tr>
Would be better, thats just a rough indentation of your code, learn to use proper style syntax, it will save your *** in the future. Also i dont think your supposed to use <img> in the XSL try something like this to diplay your image Code:
<xsl:element name="img"> <xsl:attribute name="src"> <xsl:value-of select="PICTURE" /> </xsl:attribute> <xsl:attribute name="width"> <xsl:value-of select="80" /> </xsl:attribute> <xsl:attribute name="height"> <xsl:value-of select="80" /> </xsl:attribute> <xsl:attribute name="border"> <xsl:value-of select="0"/> </xsl:attribute> </xsl:element> ![]() |
|
#4
|
|||
|
|||
|
The <img> tag will actually work, at least it does for me. You just have to make sure the tag is closed. Usually I just copy it straight from the html in and close the tag.
Currently I am using <xsl:attribute> as well but only because the attributes are in the xml. But whether using the <img> tag in xsl is 'proper xsl', well that's another question I suppose but I haven't come across anywhere against this kind of programming....yet! |
|
#5
|
|||
|
|||
|
Im assuming the <img> wont work in strict xml, probably only transitional and loose doctypes will allow it, i havnt tested this, but i cant imagine that <img> counts as proper xsl.
|
|
#6
|
|||
|
|||
|
Its just his code is similar to what I use, same declarations on top etc so if that is followed it should work. I suppose it is something worth asking though, should html code be broken up to be more of an xsl format like that way you have mentioned or should it be left as it is when its inside a html tag. Most other things are being forced into strict html before being accepted so surely if it is strict html within a html tag and its not using any values in the xml, is it not right?
On a side issue I did notice that the first line is <?xml version="1.0" encoding="ISO-8859-1"?> and as mentioned on a previous post by me, I found that I still got an encoding of utf8. Might be something to watch out for and if it does happen use <xsl: output encoding> to set the encoding either instead of that line or as well as. |
|
#7
|
|||
|
|||
|
thank you, you're imput did solve my problem
the main problem was that a whole section of the tabe (row, column, whatever) wasn't rendering correctly, creating a white-space in the border using posts instead of / helped a bit it solved a problem that could also be solved by adding <msg></msg> inside each post, and using the xsl:value-of select="msg"/> inside the post area of the table... All is well and working now.. just a few more things to do and get good at before the new layout is completely finished ![]() thanks again ~Zero |
|
#8
|
|||
|
|||
|
Glad i helped Zero, gl with your xml journey.
IvanE, yeah im not saying one is right over the other, its just the way i learnt to do it, which i consider to be something that will be more scalable in the future, as xsl progresses. Also i didnt quite understand what you ment by "I found that I still got an encoding of utf8. Might be something to watch out for and if it does happen use <xsl: output encoding> to set the encoding either instead of that line or as well as." My problem is as a very very busy web designer i have pre built micro templates for my xsl, just the bare bone skeleton, and as i develop i add more to the xsl to cover my xml and so'on. So if my encoding thing is wrong, can you please give me either the code i should be using, or point me to a web site that explains what i should be doing. ![]() |
|
#9
|
|||
|
|||
|
Phrenetical, I tend to do the same in terms of putting together one file and reusing it then for everything making the necessary changes where needed. Its just when different requirements come up, you tend to question things you haven't questioned before.
Please don't assume that I am right in what I am saying and that you are doing things wrong in any way. Its just that I noticed one of two things that may be worth noting or may be things that I am using wrongly. What I was talking about, was that in the first post by zero there is the following line, <?xml version="1.0" encoding="ISO-8859-1"?> Currently some of the xsl pages I am using output different encodings. The default is 'utf8'. Previously I just used the default as it suited me but now I needed to output different ones. What I noticed is that by using the line above on its own, I kept getting 'utf8' no matter what the encoding was set to. However if I added the following line <xsl utput encoding="iso8859-1"/>and either left the first line or took it out completely, then I got the required encoding. It may mean nothing to you, but it may be worth having a look at your output encoding to see if its what you specified. Remember 'utf8' is the default and will always come up so try something else. Because you didn't have this line in your post it may not be an issue at all for you and remember it could be some sort of error I've managed to get myself.... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > n00b having problems with the output display |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|