Problem: <img></img>

P

Philipp Lenssen

My friend has the following problem (background: we want to transform
XML to XHTML via XSLT):

"We copy XHTML fragments into an output by using the following template:

<xsl:template match="*" mode="xhtml">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="xhtml"/>
</xsl:element>
</xsl:template>

Using this template, closed elements (like <br/>) will now appear as
opened (like <br></br>). This isn't quite XHTML-like.

Now we can't copy the XHTML using <xsl:copy-of> even though that would
solve the open-tag problem. That's because the XHTML root element
declares a specific namespace, say "xy".

Now even when we try to suppress the namespace declaration or avoid
copying the particular element, the transformation process will keep
the xmlns attribute, because the copied XML belongs to the document
containing the XY namespace declaration."


All help appreciated!
 
M

Martin Honnen

Philipp Lenssen wrote:

Using this template, closed elements (like <br/>) will now appear as
opened (like <br></br>). This isn't quite XHTML-like.

<br/> is markup for an empty element as much as <br></br> is. Both is
XML (or XML-like or that way XHTML-like).
 
R

Richard Tobin

Stefan Ram said:
For interoperability, the empty-element tag should be
used, and should only be used, for elements which are
declared EMPTY.

for interoperability

[Definition: Marks a sentence describing a non-binding
recommendation included to increase the chances that XML documents
can be processed by the existing installed base of SGML processors
which predate the WebSGML Adaptations Annex to ISO 8879.]

(http://www.w3.org/TR/REC-xml/#dt-interop)

Note "should" (rather than "must") and "non-binding". It's perfectly
legal to use <br></br> in XHTML.

-- Richard
 
A

Andy Dingley

<br/> is markup for an empty element as much as <br></br> is.

<br /> is acceptable for XHTML good commercial practice, but <br></br>
isn't. Search through c.i.w.a.h for much more discussion of this.

<img></img> isn't acceptable, IMHO.

<script></script> is _really_ not acceptable if you're serving it to IE6
(it makes the whole page vanish).
 
M

Martin Honnen

Andy said:
<br /> is acceptable for XHTML good commercial practice, but <br></br>
isn't. Search through c.i.w.a.h for much more discussion of this.

<img></img> isn't acceptable, IMHO.

If you parse XHTML with an XML parser then it will accept <img></img>
the same way as <img/> or <img />. Both is well-formed markup for an
empty element.
Serving XHTML as text/html to HTML browsers with a tag soup parser is a
completely different thing and has lots of problems so that it is better
to use HTML 4 for text/html:
<http://www.hixie.ch/advocacy/xhtml>
<http://www.hut.fi/u/hsivonen/xhtml-the-point>
 
R

Richard Tobin

It's perfectly legal to use <br></br> in XHTML.

It just doesn't work very well.[/QUOTE]

If you put an XHTML DOCTYPE on it, it works in the browsers that I
use.

If you're concerned about getting all browsers to display it right,
it's probably easiest to convert it to old-fashioned HTML before
serving it (or installing it on your server).

-- Richard
 
P

Philipp Lenssen

Andy said:
<br /> is acceptable for XHTML good commercial practice, but <br></br>
isn't. Search through c.i.w.a.h for much more discussion of this.

<img></img> isn't acceptable, IMHO.

<script></script> is really not acceptable if you're serving it to IE6
(it makes the whole page vanish).

You are right. And whatever may be valid in terms of XHTML, I don't
want to serve <img></img> etc. If anyone has a solution that'd be of
great help.
 
A

Andy Dingley

If you put an XHTML DOCTYPE on it, it works in the browsers that I
use.

Which are ?

IMHE, the doctype makes little difference. The HTTP content-type makes
far more difference. If you serve an XHTML page as XML, then you get
browser problems. If you serve it as text/html, then you lose the XML
features (like namespacing) and the no longer valid <script...></script>
_will_ bite you with IE6.
 
D

David Håsäther

Andy Dingley said:
the no longer
valid <script...></script> _will_ bite you with IE6.

That is valid. Works great with IE6 too. I suppose you mean <script/>.
 
P

Peter Flynn

David said:
That is valid. Works great with IE6 too. I suppose you mean <script/>.

Why would you want to encode a null script?
Inquiring minds want to know...:)

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top