Re: [xsl] Empty object

Subject: Re: [xsl] Empty object
From: scott gabelhart <swgabel@xxxxxxxxxxxx>
Date: Wed, 28 Jan 2004 16:17:52 -0500
Mike Haarman wrote:

I have attached my xml input file and my stylesheet I am still getting
in my output <OBJECT> </OBJECT> instead of <OBJECT>&nbsp;</OBJECT>.



Scott,


I think what you are missing is the role of an entity as a placeholder,
a name for, something to be textually substituted where the reference
appears in content.  Thus, your & nbsp; *is* appearing in your output as
the character you have defined it to be: a non-breaking space, i.e. &
#xa0; or & #160; (spaces added to prevent munging).

But, since you are no longer referring to an entity in your source
document, the DOCTYPE declaration is no longer necessary.  Or the
content of OBJECT below was changed to facilitate debugging and you
really are receiving & nbsp; in your sources, in which case it is
required.

There is nothing magic about & nbsp; for your HTML output.  The
character designated 160 functions as you expect when rendered by the
browser, holding space, etc.  Indeed, & nbsp; is merely a predefined
entity for HTML which is resolved to the character when processed by a
client browser.  You don't need to make this entity reference appear in
your output for it to function properly.



Obvisouly my OBJECT template is not properly copying my element and
character contents over properly.



Your OBJECT template looks fine; however, it could be rewritten to be more idiomatically XSL and rather more succinct. Rather than a for-each and a test against a hard list of attributes to process, you can apply-templates and select any available attributes, or if only those particular attributes interest you, use select="ALIGN | STYLE | WIDTH | HEIGHT | NAME | TYPE | VALIGN | COLSPAN | ROWSPAN". Using a mode will prevent stepping on any default templates.

The template for processing attributes could look like this:

<xsl:template match="@*" mode="passthrough">
  <xsl:attribute name="translate(name(.),ABCDEFGHIJKLMNOPQRSTUVWXYZ,
abcdefghijklmnopqrstuvwxyz)">
     <xsl:value-of select="."/>
  </xsl:attribute>
</xsl:template



If you absolutely, positively, have to see the entity & nbsp; in your
output, test the text() content of the OBJECT node for & #160; and
output literally:

<xsl:text>&amp;nbsp;</xsl:text>

This entity is already defined for XHTML, I believe.

hth,

Mike


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





Mike,

thanks for the reply. Will look into cleaning up my method for finding attributes for a element. But my first priority is to get &nbsp; into my transformed output.
<xsl:text>&amp;nbsp;</xsl:text> when transformed still places &amp;nbsp; into my output when viewed with a browser.


What am I doing wrong?

- Scott

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


Current Thread