<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi there.<br>
      <br>
      Escaping "<" and other the other characters '>', '&',
      and '\r' is always done (with one exception...). The '\n' char is
      also sometimes replaced with \r\n.<br>
      <br>
                  if (ch == '<' || ch == '>' || ch == '&' ||
      ch == '\r' || ch == '\n'<br>
                          || strategy.shouldEscape(ch)) {<br>
                          ......<br>
                  }<br>
      <br>
      To do anything else would be to produce broken XML.<br>
      <br>
      What you want is (likelye to be) broken XML and JDOM is not
      designed to produce broken XML. Really the best way to solve your
      problem is to do the right handling of your output. The code using
      your XML should parse the data from your element and the parsing
      process will un-escape the characters. The next best way to do
      things is to make the actual HTML content valid XHTML and to parse
      it and then add the Element content as JDOM objects to the JDOM
      tree, and then output the complete JDOM document normally.<br>
      <br>
      The wrong way to do it wold be to override/extend the
      AbstractXMLOutputProcessor and to 'hack' the code that does the
      escaping.<br>
      <br>
      TrAXEscapePI concept is designed to support obscure functionality
      in the XMLTransformation process (XSLT). Technically I think you
      *can* use this concept to support not-escaping by having the
      following JDOM content:<br>
      <br>
          Element emt = new Element("tag");<br>
          emt.addContent(new
ProcessingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING));<br>
          emt.addContent(new
      Text("<html><body><p></body></html>"));<br>
          emt.addContent(new
ProcessingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING));<br>
      <br>
      Then you will need to set Format.setIgnoreTrAXExcapingPIs to false
      when you output the JDOM Content.<br>
      <br>
      The above is a *hack* and is not what I recommend that you do.<br>
      <br>
      Rolf<br>
      <br>
      <br>
      <br>
      On 09/01/2013 3:50 AM, SoTaNeZ wrote:<br>
    </div>
    <blockquote
cite="mid:CAJypjWf_ROGQTcLoi1_HHUMCJaY9tKWdb4NgdC24-VoJLo48-Q@mail.gmail.com"
      type="cite">Hello.
      <div><br>
        <div>I have some XML elements which text is not plain, but
          contains some HTML tags.</div>
        <div>The thing is that when outputting these to an XML file the
          characters "<" and ">" are changed into "&lt;" and
          "&gt;" preventing its correct posterior HTML processing.</div>
        <div>I tried using this EscapeStrategy:</div>
        <div><br>
        </div>
        <div>------------------</div>
        <div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>class
            EscapeSimbolos implements EscapeStrategy {</div>
          <div><br>
          </div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>public
            boolean shouldEscape(char car) {</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>switch
            (car) {</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>case
            '<':</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
            false;</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>case
            '>':</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
            false;</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>default:</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
            false;</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
        </div>
        <div>------------------</div>
        <div><br>
        </div>
        <div>but with no effect. The code within the two case statements
          is never reached, but the method is executed, so it seems that
          these characters are converted before the EscapeStrategy gets
          into action, or maybe I am doing something wrong.</div>
        <div><br>
        </div>
        <div>This is the code to set the format:</div>
        <div><br>
        </div>
        <div>---------------------</div>
        <div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>Format
            formato = Format.getPrettyFormat();</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>formato.setTextMode(TextMode.PRESERVE);</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>formato.setEscapeStrategy(new
            EscapeSimbolos());</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>formato.setIgnoreTrAXEscapingPIs(true);</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>XMLOutputter
            outputter = new XMLOutputter(formato);</div>
        </div>
        <div>---------------------</div>
        <div><br>
        </div>
        <div>I tried setting setIgnoreTrAXEscapingPIs to false, because
          I am not sure what this does exactly, but nothing seems to
          change.</div>
        <div><br>
        </div>
        <div>Any ideas?</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
To control your jdom-interest membership:
<a class="moz-txt-link-freetext" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a></pre>
    </blockquote>
    <br>
  </body>
</html>