Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problem: <img></img>

Reply
Thread Tools

Problem: <img></img>

 
 
Philipp Lenssen
Guest
Posts: n/a
 
      06-27-2005
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!

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-27-2005


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).


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      06-27-2005
Martin Honnen <(E-Mail Removed)> writes:
><br/> is markup for an empty element as much as <br></br> is.
>Both is XML (or XML-like or that way XHTML-like).


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

http://www.w3.org/TR/2000/REC-xml-20001006.html

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-27-2005
In article <(E-Mail Removed)-berlin.de>,
Stefan Ram <(E-Mail Removed)-berlin.de> wrote:

> 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
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-27-2005
On Mon, 27 Jun 2005 18:47:57 +0200, Martin Honnen <(E-Mail Removed)>
wrote:

><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).

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      06-27-2005


Andy Dingley wrote:

> On Mon, 27 Jun 2005 18:47:57 +0200, Martin Honnen <(E-Mail Removed)>
> wrote:
>
>
>><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.


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>



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-27-2005
On 27 Jun 2005 17:40:27 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Richard Tobin)
wrote:

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


It just doesn't work very well.
 
Reply With Quote
 
David Håsäther
Guest
Posts: n/a
 
      06-27-2005
Andy Dingley <(E-Mail Removed)> wrote:

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

>
> It just doesn't work very well.


In which parser?

--
David Håsäther
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-27-2005
In article <(E-Mail Removed)>,
Andy Dingley <(E-Mail Removed)> wrote:

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

>
>It just doesn't work very well.


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
 
Reply With Quote
 
Nick Kew
Guest
Posts: n/a
 
      06-27-2005
Richard Tobin wrote:

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


But not if you serve it as text/html, as is customary on the WWW.

You might want to run it through mod_xhtml to fix it.
http://apache.webthing.com/mod_xhtml/

--
Nick Kew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments