|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how can I put html tags into xsl? help please!
Hi, I want to create an html file using an xslt document and xml data. I'm a xsl/xml begginer, so I'm sorry if there is something stupid.
I'm trying to group some divs into one table and the way I found to do it in the xslt is the following: ... <table><tr><td> <xsl:for-each...> <div>...</div><div>...</div>..... <xsl:if....> <!--every 8 divs, close and open other table--> </td></tr></table><table><tr><td> </xsl:if> </xsl:for-each> </td></tr></table> .... But what I get in the html file is < and > instead of < and >. Of course I did't put inside the if element exactly what you see here (it brings an error), it's only what I want to appears in the html file. I have tried with several things, i.e CDATA, xsl:text, etc. But I obtain always the same result. How can I do this please? Thanx a lot in advance. |
|
#2
|
||||
|
||||
|
Here's one of mine:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="html"
version="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
indent="yes"
media-type="text/html" />
<xsl:template match="/collection">
<html>
<head>
<title>MTG Card Collection</title>
</head>
<body>
<xsl:value-of select="sum(card/@quantity)" /> :: <xsl:value-of select="sum(card/@price)" />
<xsl:for-each select="card">
<xsl:sort select="@edition" />
<p><xsl:value-of select="@quantity" /><xsl:text> </xsl:text><xsl:value-of select="@name" /> from <xsl:value-of select="@edition" /> at <xsl:value-of select="@price" /><xsl:text> </xsl:text><b><xsl:value-of select="@quantity * @price" /></b></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
Here I attached two files, one with the xml data (I left only 3 nodes), and the one with the xsl code which made the transform. In that file are two lines with html table tags that works fine, I mean, they pass the transfrom correctly, but inside the xsl:if element, the html tags are replaced in the transformation, there is where I have the problem, I need they to remain as they are.
|
|
#4
|
||||
|
||||
|
There's a huge and obvious difference in the way you use your HTML in the part where it works and the part where it doesn't. The HTML parts that work are tags by themselves, but in the part that doesn't work, you have them inside <xsl:text> tags and marked as CDATA. Just put the HTML there directly inside the <xsl:if>.
Code:
<xsl:if test="ORDEN='7'"></td></tr></table><table><tr><td></xsl:if> |
|
#5
|
|||
|
|||
|
Thanx for your answer, but this was my first try, and it doesn't work because after the open tag <xsl:if ...> it comes the close tag </td> and it brings an error, /td is not the close tag for xsl:if. That's why I have tried with several different ways, such as CDATA, xsl:text, and so on. I believe it can not be done in the way I was trying. Another solution was found to abtain the result I wanted, is this: instead of proccess every matching xml data, take every 8 node, process it and the following 7, and so on. In that way it can be written the open and close tags properly
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > how can I put html tags into xsl? help please! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|