Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8727

Re: javax.xml.transform.Transformer and HTML entities

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: javax.xml.transform.Transformer and HTML entities
Date Tue, 11 Oct 2011 17:58:07 -0700
Organization A noiseless patient Spider
Lines 34
Message-ID <j72on2$csd$1@dont-email.me> (permalink)
References <4e94c9cd$0$29390$426a74cc@news.free.fr>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
Injection-Date Wed, 12 Oct 2011 00:58:11 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="13197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gZfGozK81/GKl7L2imGYvhZk5QrvVyGk="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
In-Reply-To <4e94c9cd$0$29390$426a74cc@news.free.fr>
Cancel-Lock sha1:i71H7q0ZwzwuOOHhGj1avBm0cIY=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8727

Show key headers only | View raw


On 10/11/2011 3:57 PM, Aéris wrote:
> I use Transformer to create a HTML file from an DOM Document.
> But in generated HTML, all «&  » on text nodes in the document, which
> are parts of already escaped HTML entities like «&nbsp; », are
> re-escaped by Transformer.
>
> See this sample : http://pastebin.com/LfGpWMai
> Instead of expected
> 	<div>&mdash;</div>
> I get
> 	<div>&amp;mdash;</div>


I tried this:


       final Writer out = new StringWriter();
       final Source in = new StreamSource(
               new StringReader( "<test><div>&mdash;</div></test>") );

       transformer.transform( in, new StreamResult( out ) );
       System.out.println( out );

And got an error:

[Fatal Error] :1:19: The entity "mdash" was referenced, but not declared.
ERROR:  'The entity "mdash" was referenced, but not declared.'

So it's been a rather long while since I played with XSLT, but it seems 
to me that it might be your document builder that is protecting you, and 
the XSLT is just spitting out what it gets in.  I forget though how to 
get XSLT to recognize the HTML entities though.  Search Google might 
offer some clues.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

javax.xml.transform.Transformer and HTML entities Aéris <aeris@imirhil.fr> - 2011-10-12 00:57 +0200
  Re: javax.xml.transform.Transformer and HTML entities Arne Vajhøj <arne@vajhoej.dk> - 2011-10-11 19:04 -0400
  Re: javax.xml.transform.Transformer and HTML entities Jeff Higgins <jeff@invalid.invalid> - 2011-10-11 19:15 -0400
  Re: javax.xml.transform.Transformer and HTML entities markspace <-@.> - 2011-10-11 17:58 -0700
    Re: javax.xml.transform.Transformer and HTML entities Arne Vajhøj <arne@vajhoej.dk> - 2011-10-11 21:14 -0400

csiph-web