Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Xalan 2.7.0 output method="html" - empty HTML tags

Reply
Thread Tools

Xalan 2.7.0 output method="html" - empty HTML tags

 
 
Xh
Guest
Posts: n/a
 
      03-18-2007
Hi All,

I have problems with generating valid HTML output

there are few HTML elements that i don't what to output as <tagname/>
but as <tagname></tagname> but Xalan keeps generating them as
<tagname/>

there are few really annoying situations where adding &#160; to some
HTML elements is necessary:

<textarea class="textarea" name="{concat($textarea/ancestor::form/@id,
@id)}">
&#160;
</textarea>

otherwise FF produces very, very strange code when displaying:
<textarea .... />

but when I add &#160; user sees this space in textarea field...

or in this situation:

<xsl:template name="generateHelp">
<xslaram name="help"/>
<xslaram name="formId"/>
<xslaram name="fieldId"/>
<span id="{concat($formId, '_', $fieldId,'_msg')}" style="font-
weight: bold; color: red;">
</span>
<label for="{concat($formId, '_', $fieldId)}">
<xsl:value-of select="$help"/>
</label>
</xsl:template>

the <span> element is generated as <span {attributes...} />

when i use JavaScript innerHTML for span id FireFox swallows
everything as innerHTML including
the <label> element

any idea how to solve this?

or I should always use the &#160; space entity?

best regards
Łukasz

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      03-19-2007
Xh wrote:
> there are few HTML elements that i don't what to output as <tagname/>
> but as <tagname></tagname> but Xalan keeps generating them as
> <tagname/>
>
> there are few really annoying situations where adding &#160; to some
> HTML elements is necessary:
>
> <textarea class="textarea" name="{concat($textarea/ancestor::form/@id,
> @id)}">
> &#160;
> </textarea>
>
> otherwise FF produces very, very strange code when displaying:
> <textarea .... />
>
> but when I add &#160; user sees this space in textarea field...
>
> or in this situation:
>
> <xsl:template name="generateHelp">
> <xslaram name="help"/>
> <xslaram name="formId"/>
> <xslaram name="fieldId"/>
> <span id="{concat($formId, '_', $fieldId,'_msg')}" style="font-
> weight: bold; color: red;">
> </span>
> <label for="{concat($formId, '_', $fieldId)}">
> <xsl:value-of select="$help"/>
> </label>
> </xsl:template>
>
> the <span> element is generated as <span {attributes...} />
>
> when i use JavaScript innerHTML for span id FireFox swallows
> everything as innerHTML including
> the <label> element
>
> any idea how to solve this?
>
> or I should always use the &#160; space entity?
>
> best regards
> Łukasz
>



--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      03-19-2007
Xh wrote:
>there are few HTML elements that i don't what to output as <tagname/>
>but as <tagname></tagname> but Xalan keeps generating them as
><tagname/>


Shouldn't be happening necessary if you're really specifying HTML output
mode, and if you're letting Xalan handle the serialization. (If you're
using a SAXResult rather than a StreamResult, maintaining this
distinction is your responsibility).

Can you provide a minimal example that demonstrates the problem?



On the other, hand, apropos of your workaround:

> but when I add &#160; user sees this space in textarea field...


If you don't want the user to see a space, don't use a Required Blank
character as the content; if you use ordinary spaces/linebreaks HTML
will probably discard them.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      03-19-2007
Joe Kesselman wrote:
> If you don't want the user to see a space, don't use a Required Blank
> character as the content; if you use ordinary spaces/linebreaks HTML
> will probably discard them.


(BTW, to make sure that space is output to the HTML file rather than
being dropped, you'll probably want to wrap it in an <xsl:text>. Which
is generally a good practice for literal text even when it isn't
entirely necessary.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
Xh
Guest
Posts: n/a
 
      03-19-2007
Hi Joe!

On Mar 19, 6:37 am, Joe Kesselman <(E-Mail Removed)> wrote:
> Joe Kesselman wrote:
> > If you don't want the user to see a space, don't use a Required Blank
> > character as the content; if you use ordinary spaces/linebreaks HTML
> > will probably discard them.

>
> (BTW, to make sure that space is output to the HTML file rather than
> being dropped, you'll probably want to wrap it in an <xsl:text>. Which
> is generally a good practice for literal text even when it isn't
> entirely necessary.)


I'd like to provide an example but it is a bit complicated because I
use it my XML + XSLT in JBossAS

but <xsl:text> </xsl:text> is doing great job and so far I overcame
all
inconveniences

best regards
Łukasz

 
Reply With Quote
 
Simon Brooke
Guest
Posts: n/a
 
      03-19-2007
in message <(E-Mail Removed) .com>, Xh
('(E-Mail Removed)') wrote:

> Hi All,
>
> I have problems with generating valid HTML output
>
> there are few HTML elements that i don't what to output as <tagname/>
> but as <tagname></tagname> but Xalan keeps generating them as
> <tagname/>


Tag minimisation. One of the real experts will be along in a moment to tell
you how to prevent this properly, but the following works:

<div class="othernews">
<xsl:comment> prevent tag minimisation of DIV -
Internet Explorer barfs </xsl:comment>
<xsl:apply-templates select="feed"/>
</div>

If '<xsl:apply-templates select="feed"/>' in the above generates nothing
(e.g., if there are no 'feed' elements) the XML would naturally contain an
empty element which would be tag minimised on serialisation (printing to
thee and me). So you put in the xsl:comment essentially to force the tag
to have content, so that it can't be minimised. Don't think this solution
will work for text areas, though - you may have to generate some default
text.

--
http://www.velocityreviews.com/forums/(E-Mail Removed) (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Skill without imagination is craftsmanship and gives us
;; many useful objects such as wickerwork picnic baskets.
;; Imagination without skill gives us modern art.
;; Tom Stoppard, Artist Descending A Staircase
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      03-19-2007
On 19 Mar, 01:00, Joe Kesselman <(E-Mail Removed)> wrote:

> Shouldn't be happening necessary if you're really specifying HTML output
> mode,


I've been getting this recently too. Unchanged application code,
"maintenance" update of libraries and before I know it, I've got "/>"
in my HTML 8-(

> Can you provide a minimal example that demonstrates the problem?


Nope. 8-( It's a vast pile of Ant (a Java-ish build tool) with the
<xslt> task in it, grabbing the nearest available Trax processor. I
might get to sort it out some time around the next millenium.

 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      03-19-2007
Andy Dingley wrote:
>>Can you provide a minimal example that demonstrates the problem?

> Nope. 8-(


Unfortunately, that limits the amount of volunteer debugging assistance
you're going to get.. If I think of anything I'll let you know.

I presume you've asked this on Xalan's own mailing list, since if there
really has been a behavioral change that's where you're most likely to
find the folks who know what it was.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
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
Xalan - empty element Albert Greincker XML 7 09-09-2006 03:23 PM
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
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
Upgrade of Xalan 1.2.2 and Xerces 1.4.4 to Xalan 2.6 and Xerces 2.6.2 cvissy XML 0 11-16-2004 07:06 AM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM



Advertisments