GuardianOfTheFlame
Programmer
Hi all,
I have this XSLT:
applied to this XML:
This is the result:
The problem is that the input type tag is not closed (while the div is normally closed) and I don't understand why... I want that the output is well-formed so all tags must be closed...
Also if I simply write
the resulting HTML doesn't close the input tag:
Is it normal? there's something I can do to force the closing?
Thanks again,
Salo
I have this XSLT:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<html>
<head>
<title><xsl:text>Actide - </xsl:text><xsl:value-of select="/xml/layout/@name" /></title>
<link rel="stylesheet" type="text/css" media="screen">
<xsl:attribute name="href">
<xsl:text>css/</xsl:text><xsl:value-of select="/xml/layout/@style" />
</xsl:attribute>
</link>
</head>
<body>
<form>
<xsl:apply-templates select="/xml/layout/page/items" />
</form>
</body>
</html>
</xsl:template>
<xsl:template match="items">
<xsl:for-each select="item">
<!--If the item type is 'text', create a text or a textarea (if multiline) object in the resulting html-->
<xsl:if test="@type='text'">
<xsl:choose>
<xsl:when test="@multiline='0'">
<input type="text">
<xsl:attribute name="id">
<xsl:value-of select="@domid" />
</xsl:attribute>
</input>
</xsl:when>
<xsl:otherwise>
<textarea>
<xsl:value-of select="./content" disable-output-escaping="yes" />
</textarea>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!--If the item type is 'paragraph', create a paragraph object in the resulting html-->
<xsl:if test="@type='paragraph'">
<div>
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="@domid" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@tooltip" />
</xsl:attribute>
<xsl:attribute name="tabindex">
<xsl:value-of select="@tabindex" />
</xsl:attribute>
<xsl:if test="@disabled='1'">
<xsl:attribute name="disabled"/>
</xsl:if>
<xsl:attribute name="style">
<xsl:text>position: absolute; top: </xsl:text><xsl:value-of select="@y" /><xsl:text>px;</xsl:text>
<xsl:text> left: </xsl:text><xsl:value-of select="@x"/><xsl:text>px;</xsl:text>
<xsl:text> width: </xsl:text><xsl:value-of select="@w"/><xsl:text>px;</xsl:text>
<xsl:text> height: </xsl:text><xsl:value-of select="@h"/><xsl:text>px;</xsl:text>
<xsl:if test="@bgcolor!=''" >
<xsl:text> background: </xsl:text><xsl:value-of select="@bgcolor" /><xsl:text>;</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="@bordercolor=''">
<xsl:text> border: 1px solid black;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> border: 1px solid </xsl:text><xsl:value-of select="@bordercolor"/><xsl:text>;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@forecolor!=''" >
<xsl:text> color: </xsl:text><xsl:value-of select="@forecolor" /><xsl:text>;</xsl:text>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="./content" disable-output-escaping="yes"/>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
applied to this XML:
Code:
<xml>
<layout name="my_layout" pages="1" w="600" h="800" format="A4" style="nubistyle_1.css">
<page domid="container" name="container" orientation="portrait">
<items>
<item type="text" x="430" y="40" w="100" h="20" name="text_1" domid="text_1" tooltip="" group="" tabindex="" datatype="" minlen="" maxlen="" bordercolor="" bgcolor="" forecolor="" unique="0" required="0" disabled="0" multiline="0">
<content><![CDATA[Default]]></content>
</item>
<item type="paragraph" x="30" y="50" w="190" h="160" name="paragraph_1" domid="paragraph_1" tooltip="Hi all!" group="" bordercolor="" bgcolor="" forecolor="" multiline="1">
<content><![CDATA[I am a paragraph]]></content>
</item>
<item type="paragraph" x="300" y="240" w="100" h="20" name="paragraph_2" domid="paragraph_2" tooltip="" group="" bordercolor="" bgcolor="" forecolor="" multiline="1">
<content><![CDATA[I am another one]]></content>
</item>
</items>
</page>
</layout>
</xml>
This is the result:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Actide - my_layout</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/nubistyle_1.css">
</head>
<body><form>
<input type="text" id="text_1"><div name="paragraph_1" id="paragraph_1" title="Hi all!" tabindex="" style="position: absolute; top: 50px; left: 30px; width: 190px; height: 160px; border: 1px solid black;">I am a paragraph</div>
<div name="paragraph_2" id="paragraph_2" title="" tabindex="" style="position: absolute; top: 240px; left: 300px; width: 100px; height: 20px; border: 1px solid black;">I am another one</div>
</form></body>
</html>
Also if I simply write
Code:
<xsl:when test="@multiline='0'">
<input type="text" />
</xsl:when>
Code:
<input type="text">
Thanks again,
Salo