Re: [xsl] Empty object

Subject: Re: [xsl] Empty object
From: scott gabelhart <swgabel@xxxxxxxxxxxx>
Date: Wed, 28 Jan 2004 12:56:35 -0500
scott gabelhart wrote:

David Carlisle wrote:

in the xml file of course don't appear in my transformed output.


why "of course" ??

The default behaviour of xslt is to copy character data
so if it isn't being copied you presumably have a template that is
explictly not copying it.

Again do you really have

<!DOCTYPE holdspace [<!ENTITY nbsp "& n b s p ;">]>
or has your mailer changed & # 1 6 0 ; to nbsp.
As shown your entity file is defining nbsp to be nbsp.

David




Dan,

I have tried the following combinations:

xml file:

<!DOCTYPE holdspace[<!ENTITY nbsp "&nbsp ;">]> <--no spaces &nbsp;
when I view this xml file I see <OBJECT>&nbsp;</OBJECT>

my transform I have tried with both declaring this holdspace and not. The resulting output from my transform removes the &nbsp; between my OBJECT tags. I want to keep the &nbsp; in my output between my OBJECT tag so when I open this output file I see <OBJECT>&nbsp;</OBJECT>

How do I accomplish this in my stylesheet?

Sincerely,

Scott

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Dave,

I have attached my xml input file and my stylesheet I am still getting in my output <OBJECT> </OBJECT> instead of <OBJECT>&nbsp;</OBJECT>. Obvisouly my OBJECT template is not properly copying my element and character contents over properly. Any guidance you can provide to solve this problem would be greatly appreciated.

xml input file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE WITABLIB [<!ENTITY nbsp "&#160;">]>
<WITAGLIB xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="file:///C:/DPXML/wiservice.xsd">
<....snippet...>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;">$4.00</OBJECT>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;">&#160;</OBJECT>


xsl :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<title>YOU ROCK</title>
</head>
<body>
<xsl:apply-templates select="//FORMATTED/TABLE"/>
</body>
</html>
</xsl:template>
<xsl:template match="TABLE">
<table>
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name() = 'BORDER'">
<xsl:attribute name="border"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'CELLSPACING'">
<xsl:attribute name="cellspacing"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'CELLPADDING'">
<xsl:attribute name="cellpadding"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'WIDTH'">
<xsl:attribute name="width"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'STYLE'">
<xsl:attribute name="style"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="DPROW">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="OBJECT">
<td>
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name() = 'ALIGN'">
<xsl:attribute name="align"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'STYLE'">
<xsl:attribute name="style"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'WIDTH'">
<xsl:attribute name="width"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'HEIGHT'">
<xsl:attribute name="height"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'NAME'">
<xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'TYPE'">
<xsl:attribute name="type"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'VALIGN'">
<xsl:attribute name="valign"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'COLSPAN'">
<xsl:attribute name="colspan"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:when test="name() = 'ROWSPAN'">
<xsl:attribute name="rowspan"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:apply-templates />


</td>
</xsl:template>
</xsl:stylesheet>


xhtml output:

<...snippet..>

<td style="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;">$4.00</td>
<td style="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;"> </td>




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread