Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > self-closing tags

Reply
Thread Tools

self-closing tags

 
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008
My xsl includes image tags as follows:

<img src="../images/u.gif" width="16" height="16" alt="Back to top"
border="0"/>

Yet, after processing, the img tag is no longer self-closing so it's
not well-formed.

Can someone tell me what's going on and how to fix?

FYI, I'm using XALAN v.2.7.0

TIA,
David
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-07-2008
David Schwartz wrote:
> My xsl includes image tags as follows:
>
> <img src="../images/u.gif" width="16" height="16" alt="Back to top"
> border="0"/>
>
> Yet, after processing, the img tag is no longer self-closing so it's
> not well-formed.


"well-formed" is defined for XML and with XML
<img />
as well as
<img/>
as well as
<img></img>
_is_ well-formed.

If you want to generate HTML with your stylesheet then you want
<img>
and that is achieved by using
<xslutput method="html"/>
and by making sure your result elements are in no namespace.





--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008
On Mar 7, 9:47 am, Martin Honnen <(E-Mail Removed)> wrote:
> David Schwartz wrote:
> > My xsl includes image tags as follows:

>
> > <img src="../images/u.gif" width="16" height="16" alt="Back to top"
> > border="0"/>

>
> > Yet, after processing, the img tag is no longer self-closing so it's
> > not well-formed.

>
> "well-formed" is defined for XML and with XML
> <img />
> as well as
> <img/>
> as well as
> <img></img>
> _is_ well-formed.
>
> If you want to generate HTML with your stylesheet then you want
> <img>
> and that is achieved by using
> <xslutput method="html"/>
> and by making sure your result elements are in no namespace.
>


I am using <xslutput method="html"/>. Also, I'm looking for xhmtl so
<img> by itself won't do and, as I understand it anyway, not well-
formed in that context. Any thoughts what might be going on?

My result elements are not in a namespace. FWIW, here are the
stylesheet and output elements (I use the redirect to produce the
output files):

<xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/
Transform" xmlns:redirect="org.apache.xalan.xslt.extensions.R edirect"
extension-element-prefixes="redirect">
<!-- <xslutput method="html" version="4.0" indent="yes"
encoding="ISO-8859-1"/> -->
<xslutput method="xml" omit-xml-declaration="yes" version="4.0"
indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
encoding="ISO-8859-1"/>


Thanks for the help.

David
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-07-2008
David Schwartz wrote:

> I am using <xslutput method="html"/>. Also, I'm looking for xhmtl so
> <img> by itself won't do and, as I understand it anyway, not well-
> formed in that context. Any thoughts what might be going on?


specifying method="html" tells the xslt system that you do not want xml
syntax, you want html syntax, so specify method="xml" if that's what you
want.

> My result elements are not in a namespace. FWIW, here are the
> stylesheet and output elements (I use the redirect to produce the
> output files):


If the result elements are not in a namespace then they are not xhtml,
whatever syntax is used for empty elements, so add
xmlns="http://www.w3.org/1999/xhtml"
to your xsl:stylesheet element.
This will also have the effect of making the default serialisation xml
as the html serialisation the default, ashtml is only the default output
method if the top level element is html in no namespace.
>
> <xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/
> Transform" xmlns:redirect="org.apache.xalan.xslt.extensions.R edirect"
> extension-element-prefixes="redirect">
> <!-- <xslutput method="html" version="4.0" indent="yes"
> encoding="ISO-8859-1"/> -->
> <xslutput method="xml" omit-xml-declaration="yes" version="4.0"
> indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
> encoding="ISO-8859-1"/>
>
>
> Thanks for the help.
>
> David


David

--
http://dpcarlisle.blogspot.com
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a
 
      03-08-2008
I added the namespace attribute as you suggested. Sure enough, the
image tags are self-closing now. However, now every resulting element
has the following: div xmlns=""

David
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      03-08-2008
David Schwartz wrote:
> I added the namespace attribute as you suggested. Sure enough, the
> image tags are self-closing now. However, now every resulting element
> has the following: div xmlns=""


If you want to put all result elements in the namespace
http://wwww.w3.org/1999/xhtml then put that declaration on the
xsl:stylesheet element
<xsl:stylesheet
xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns="http://www.w3.org/1999/xhtml">



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-08-2008
David Schwartz wrote:
> I added the namespace attribute as you suggested. Sure enough, the
> image tags are self-closing now. However, now every resulting element
> has the following: div xmlns=""
>
> David


That means that you have generated the div in no namespace instead of
the xhtml namespace. If you have declared the xhtml namespace on
xsl:stylesheet then elements created in the stylesheet will be xhtml
(unless you work hard to stop that) so perhaps these div elements have
been copied from an input document?
If the input is in no-namespace and you want to generate elements in the
xhtml namepsace, you don't want to copy with xsl:copy or xsl:copy-of you
want to generate an element in the (new) default namespace but wth the
same local name as before, so don't use
<xsl:copy>
use
<xsl:element name="{local-name()}">

David


--
http://dpcarlisle.blogspot.com
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer Rob Nicholson ASP .Net 3 05-28-2005 03:11 PM
Evaluating struts tags inside my own custom tags... A. Brinkmann Java 2 04-16-2004 07:44 AM
JSP newbie - use include, custom tags, standard tags - or what? Mike Java 3 01-09-2004 09:30 AM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM
Custom Tags within Custom Tags. Ranganath Java 2 10-21-2003 06:14 AM



Advertisments