2014-10-02 2 views
0

에게 잘있어서 파싱되지 :jtidy는 프리 마커 HTML 코드

"<#macro print_bono voucher> 
<div id="content"> 
      <div class="icn_fold2"><div class="text"></div></div> 
      <div id="area1"> 
       <div id="bg1"> 
        <p class="barcode"><img src="${voucher.barcode}" alt="${voucher.numberCode}" /></p> 
        <div class="title"> 
         <h1>&#201;sta es tu entrada</h1> 
         <p class="note"><strong>IMPORTANTE:</strong> Para acceder al recinto hay que presentar esta hoja entera</p> 
        </div> 
        <div class="services_bg"> 
         <p class="logo_fcb"><img src="http://evo.cdnstc.com/static/images/bono_ds/logos_fcb.gif" alt="FCB, LFP" /></p> 
         <div class="service"> 
          <table width="260"> 
           <tr> 
            <td width="85"><strong>Jornada:</strong></td> 
            <td width="45">${voucher.jornada}</td> 
            <td width="85"><strong>Temporada:</strong></td> 
            <td width="45">${temporada}</td> 
           </tr> 
           <tr> 
            <td width="85" colspan="2"><strong>Fecha*:</strong></td> 
            <td colspan="2">${voucher.serviceDate}</td> 
           </tr> 
           <tr> 
            <td width="85" colspan="2"><strong>Partido:</strong></td> 
            <td colspan="2">${voucher.match}</td> 
           </tr> 
           <tr> 
            <td colspan="4"><strong>*</strong> <i>Se recomienda verificar la fecha y hora del partido en <span>www.fcbarcelona.cat</span></i></td> 
           </tr> 
          </table> 
          <table> 
           <tr> 
            <td width="130" colspan="2"><strong>Zona:</strong></td> 
            <td colspan="2">${voucher.zoneDescription}</td> 
           </tr> 
           <tr> 
            <td width="130" colspan="2"><strong>Acceso recomendado:</strong></td> 
            <td colspan="2">${voucher.access}</td> 
           </tr> 
           <tr> 
            <td width="85"><strong>Puerta:</strong></td> 
            <td>${voucher.entranceDoor}</td> 
            <td width="85"><strong>Boca:</strong></td> 
            <td>${voucher.gate}</td> 
           </tr> 
           <tr> 
            <td width="85"><strong>Fila:</strong></td> 
            <td>${voucher.row}</td> 
            <td width="85"><strong>Asiento:</strong></td> 
            <td>${voucher.seat}</td> 
           </tr> 
           <tr> 
            <td colspan="4"> </td> 
           </tr> 
           <tr class="price"> 
            <td width="130" colspan="2"><strong>Precio:</strong></td> 
            <td colspan="2"><span>10.080 EUR &#8364;</span></td> 
           </tr> 
          </table> 
         </div> 
        </div> 
        <div class="logo_hex"> 
         <p>CIF:G08266298</p> 
         <img src="http://evo.cdnstc.com/static/images/bono_ds/logo_hotelextras.gif" alt="hotelextras" /> 
        </div> 
       </div> 
      </div> 

      <div id="area2"> 
       <div id="bg2"> 
        <h1>C&#243;mo llegar</h1> 
        <p class="map"><img src="http://evo.cdnstc.com/static/images/bono_ds/img_mapa.gif" alt="" /></p> 
        <p class="logos_pie"><img src="http://evo.cdnstc.com/static/images/bono_ds/logos_pie.gif" alt="" /></p> 
       </div> 
      </div> 
      <div class="icn_fold1"><div class="text"></div></div> 
      <div id="area3"> 
       <div id="bg3"> 
        <div id="banner-content"> 
         <div class="banner"> 
          <img src="http://evo.cdnstc.com/static/images/bono_ds/banner.jpg" alt="" />       
          <img src="http://evo.cdnstc.com/static/images/bono_ds/logo_sensefum.gif" alt="" style="width: 100%; margin-left: 15px;"/> 
          <span class="publi">publicitat</span> 
         </div> 
        </div> 
       </div> 
      </div> 

      <div id="area4"> 
       <div id="bg4"> 
        <p class="note"><strong>IMPORTANTE:</strong> Para acceder al recinto hay que presentar esta hoja entera</p> 
        <div class="info"> 
         <ul class="instructions"> 
          <li><strong>Prohibida la reproducci&#243;n total o parcial de este documento.</strong><br />El FCBarcelona se reserva el derecho de denegar el acceso al recinto en caso de que se detecte la posible duplicaci&#243;n de esta entrada. El titular de la compra se responsabiliza del buen uso de esta entrada.</li> 
          <li><strong class="txt_rose">Para validar la entrada en el mecanismo de control, hay que doblarla como indicamos:</strong><img src="http://evo.cdnstc.com/static/images/bono_ds/img_pliegue.gif" alt="" /></li> 
         </ul> 
         <p class="attention"><strong>ATENCI&#211;N:</strong> Si alguien te ofrece venderte esta entrada no la aceptes. No tendr&#237;a ning&#250;n valor oficial y, por lo tanto, ser&#237;a una copia no autorizada.</p> 
         <h2>Instrucciones y condiciones importantes</h2> 
         <p>La tenencia y/o uso de esta entrada significa la aceptaci&#243;n expresa de todos los t&#233;rminos y condiciones asociados a la entrada y ratificados durante el proceso de compra. En caso de duda, consulta de nuevo las condiciones en <strong>www.fcbarcelona.cat</strong></p> 
         <ul class="list1"> 
          <li><strong>El c&#243;digo de barras de esta entrada permite el acceso al recinto s&#243;lo una vez.</strong> Cualquier duplicado de la misma, bajo ning&#250;n concepto, podr&#225; dar acceso al recinto.</li> 
          <li>En caso de que aparezcan copias duplicadas, el FCBarcelona adoptar� las medidas oportunas, <strong>denegando el acceso al recinto.</strong></li> 
          <li> 
           Reglamento para la prevenci&#243;n de la violencia en espect&#225;culos deportivos. <strong>Causas que impiden el acceso al recinto:</strong> 
           <ul class="list2"> 
            <li>La introducci&#243;n de bebidas alcoh&#243;licas, armas e instrumentos susceptibles de ser utilizados como tales, bengalas, fuegos de artificio u objetos an&#225;logos.</li> 
            <li>La introducci&#243;n y exhibici&#243;n de pancartas, s&#237;mbolos, emblemas o leyendas que impliquen incitaci&#243;n a la violencia.</li> 
            <li>Que el portador haya sido sancionado con la prohibici&#243;n de acceso a cualquier recinto deportivo, mientras no se haya extinguido la sanci&#243;n.</li> 
            <li>Encontrarse bajo los efectos de bebidas alcoh&#243;licas, estupefacientes, psicotr&#243;picos, estimulantes o sustancias an&#225;logas.</li> 
           </ul> 
          </li> 
         </ul> 
        </div> 
       </div> 
      </div> 
      <div class="icn_fold1 icn_fold1_right"><div class="text"></div></div> 
      <div class="icn_fold2 icn_fold2_bottom"><div class="text"></div></div>   
    </div> 
</#macro> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    <head> 
     <title>Voucher</title> 
     <style> 
      body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td { 
       margin: 0; 
       padding: 0; 
      } 
      table { 
       border-collapse: collapse; 
       border-spacing: 0; 
      } 
      fieldset, img { 
       border: 0 none; 
      } 
      address, caption, cite, code, dfn, em, strong, th, var { 
       font-style: normal; 
       font-weight: normal; 
      } 
      ol, ul, li { 
       list-style: none outside none; 
      } 
      caption, th { 
       text-align: left; 
      } 
      h1, h2, h3, h4, h5, h6 { 
       font-size: 100%; 
       font-weight: normal; 
      } 
      body { 
       background-color: #FFFFFF; 
       color: #000000; 
       font-family: Arial,Helvetica,sans-serif; 
       font-size: 10px; 
       margin: 0; 
       padding: 0; 
       text-align: left; 
      } 
      h1 { 
       font-size: 15px; 
       font-weight: bold; 
       text-transform: uppercase; 
       padding: 10px 0 5px 0; 
       text-align: center; 
       color:#fff; 
      } 
      #content { 
       background-color: #FFFFFF; 
       overflow: hidden; 
       position: relative; 
       margin:0; 
       padding:0; 
      } 
      #content #bg1 .title h1 { 
       color:#fff; 
       padding:0; 
       margin-top:6px; 
       text-align:center; 
      } 
      #content #bg1 .title { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg_title.png") repeat-y left top; 
       width: 309px; 
       height: 44px; 
       margin: 0 0 0 6px; 
      } 
      .note { 
       color:#fff; 
       padding:0; 
       font-size: 8px; 
       margin-bottom: 8px; 
      } 
      .note strong { 
       font-size: 9px; 
      } 
      .txt_rose { 
       color:#A30245; 
      } 
      #content #bg4 .note { 
       padding: 0; 
       text-align:center; 
      } 
      #content #bg1 .services_bg { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg_services.png") no-repeat left top; 
       width:309px; 
       height: 238px; 
       margin: 0 0 0 6px; 
      } 
      #content #bg1 .logo_fcb { 
       margin-top:4px; 
      } 
      #content #bg1 .price span { 
       font-size: 15px; 
       color:#000; 
      } 
      a:hover { 
       text-decoration: underline; 
      } 
      .hidden { 
       display: none; 
      } 
      .first { 
       margin-left: 0; 
      } 
      .last { 
       margin-right: 0; 
      } 
      .clear { 
       clear: both; 
       display: block; 
       height: 0; 
       overflow: hidden; 
       visibility: hidden; 
       width: 0; 
      } 
      .left { 
       float:left; 
      } 
      .right { 
       float:right; 
      } 
      .icn_fold1 { 
       position:absolute; 
       top:500px; 
       left:7px; 
       font-size:8px; 
       font-weight: bold; 
       color:#A30245; 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/icn_fold1_cas.gif") no-repeat left top; 
       height:217px; 
       z-index: 100; 
       *width:40px; 
      } 
      .icn_fold2 { 
       position:absolute; 
       top:6px; 
       left:245px; 
       font-size:8px; 
       font-weight: bold; 
       color:#A30245; 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/icn_fold2_cas.gif") no-repeat left top; 
       height:26px; 
       z-index: 100; 
      } 
      .icn_fold1_right { 
       left:680px; 
      } 
      .icn_fold2_bottom { 
       top:965px; 
      } 
      .icn_fold1 .text { 
       -webkit-transform: rotate(-90deg); 
       -moz-transform: rotate(-90deg); 
       -o-transform: rotate(-90deg); 
       filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); 
       margin-left: -145px; 
       margin-top: -72px; 
       *margin-left: 3px; 
       *margin-top: -115px; 
       margin-left: 3px\0/; 
       margin-top: -115px\0/; 
       width: 300px; 
      } 
      .icn_fold2 .text { 
       margin-left: 15px; 
       margin-top: -2px; 
       width: 300px; 
      } 
      strong { 
       font-weight: bold; 
      } 
      #content { 
       width:720px; 
      } 
      #content div { 
       float:left; 
      } 
      #content #area1 { 
       width: 350px; 
       border-right: 1px dashed #A30245; 
       border-bottom: 1px dashed #A30245; 
      } 
      #content #area2 { 
       width: 354px; 
       border-bottom: 1px dashed #A30245; 
      } 
      #content #area3 { 
       width: 350px; 
       border-right: 1px dashed #A30245; 
      } 
      #content #area4 { 
       width: 354px; 
      } 
      #content #bg1 { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg1.png") no-repeat left top; 
       width: 321px; 
       height: 457px; 
       margin: 25px 8px 8px 25px; 
      } 
      #content #bg1 p { 
       text-align: center; 
      } 
      #content #bg2 { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg2.png") no-repeat left top; 
       width: 321px; 
       height: 457px; 
       margin: 25px 25px 8px 4px; 
      } 
      #content #bg3 { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg3.png") no-repeat left top; 
       width: 321px; 
       height: 457px; 
       margin: 8px 8px 25px 25px; 
       text-align:center; 
       display: table; 
       position: relative; 
      } 
      #content #bg4 { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/bg4.png") no-repeat left top; 
       width: 321px; 
       height: 457px; 
       margin: 8px 0px 25px 4px; 
      } 
      #content #bg4 .info { 
       padding: 5px 0px 0px 13px; 
       font-size:8px; 
      } 
      #content #bg4 ul { 
       float:left; 
      } 
      #content #bg4 .instructions li{ 
       width:148px; 
       display: inline; 
       float:left; 
       margin-right: 5px; 
      } 
      #content #bg4 .instructions img{ 
       margin-top: 10px; 
      } 
      #content #bg4 .attention { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/ico_par.gif") no-repeat left top; 
       padding: 0px 15px 4px 10px; 
       margin: 3px 0 3px 0; 
       float:left; 
       /**width:580px;*/ 
      } 
      #content #bg4 .attention strong { 
       font-size: 9px; 
      } 
      #content #bg4 h2 { 
       font-size: 10px; 
       text-transform: uppercase; 
       float:left; 
       color:#A30245; 
       font-weight: bold; 
       margin-bottom: 5px; 
       /**width:620px;*/ 
      } 
      #content #bg4 p { 
       float:left; 
       padding-right: left; 
      } 
      #content #bg4 p.note { 
       float:none; 
       margin-top:13px; 
      } 
      #content #bg4 .list1 { 
       margin:5px 0 0 0px; 
       font-size: 8px; 
       padding-right: 10px; 
      } 
      #content #bg4 .list1 li { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/ico_line1.png") no-repeat 0 2px; 
       padding-left:8px; 
       margin-bottom:5px; 
      } 
      #content #bg4 .list2 { 
       margin-top: 10px; 
       *margin-left:20px; 
      } 
      #content #bg4 .list2 li { 
       background: url("http://evo.cdnstc.com/static/images/bono_ds/ico_line2.png") no-repeat left 3px; 
      } 
      #content .service { 
       margin: 10px 10px 5px 18px; 
       width: 268px; 
      } 
      #content .service table { 
       margin-bottom:15px; 
       font-size:9px; 
      } 
      #content .service table strong { 
       color: #A30245; 
      } 
      #content .service table span { 
       font-weight:bold; 
      } 
      #content .service table tr.lastd td { 
       border-bottom: 1px dotted #000; 
       padding-bottom:20px; 
      } 
      #content .access strong{ 
       font-size: 10px; 
       color: #FF0000; 
      } 
      #content #bg1 .logo_hex { 
       margin: -20px 0 0 6px; 
       width: 309px; 
       text-align: center; 
      } 
      #content #bg1 .logo_hex img { 
       margin-top: 45px; 
      } 
      #content #bg2 .map { 
       margin:0 0 0 7px; 
       text-align: center; 
      } 
      #content #bg2 .logos_pie { 
       text-align:center; 
       margin-top: 27px; 
      } 
      #content #bg3 .banner { 
       position:relative; 
       margin-bottom: 10px; 
       *position: absolute; 
       *bottom: 0px; 
       *left:0px; 
      } 
      #content #bg3 #banner-content { 
       margin-top: 100px; 
       float:none; 
      } 
      #content #bg3 #banner-content .publi { 
       float:right; 
       font-size:8px; 
       margin:3px 14px 0 0; 
       text-transform: uppercase; 
      } 
      #content .locator { 
       text-align: center; 
       float: none; 
       font-size:10px; 
      } 
      #content .barcode { 
       margin: 9px 0 5px 0; 
      } 
     </style> 
    </head> 
    <body>   
     <#list vouchers as voucher> 
      <@print_bono voucher /> 

      <#if voucher_has_next> 
       <br /><br /><br /><br /> 
      </#if> 
     </#list> 
    </body> 
</html>" 

그냥 반환 문장 전에 결과 채우고 무엇 :

파라미터로서 htmlString 통해 입사 무엇

public static String convertHtmlEntities(String htmlString) throws UnsupportedEncodingException{ 
     String result = null; 

     Tidy tidy = new Tidy(); 
     tidy.setInputEncoding("UTF-8"); 
     tidy.setOutputEncoding("UTF-8"); 
     tidy.setPrintBodyOnly(false); // only print the content 
     tidy.setXmlOut(true); // to XML 
     tidy.setSmartIndent(true); 
     ByteArrayInputStream inputStream = new ByteArrayInputStream(htmlString.getBytes("UTF-8")); 
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 
     tidy.parseDOM(inputStream, outputStream); 
     result = outputStream.toString("UTF-8"); 

     return result; 
    } 

"<html> 
    <head> 
    <meta name="generator" 
    content="HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net" /> 
    <title></title> 
    </head> 
    <body></body> 
</html> 
" 

나는 무엇이 잘못 됐는지 상상할 수 없다. 어떤 도움이나 지침이 필요합니까?

답변

0

나는 그것이 가능하다고 생각하지 않습니다. freemarker 템플릿은 jtidy가 의미하는 유효한 (x) html이 아닙니다. 내가 생각할 수있는 유일한 것은 freemarker 템플릿을 먼저 처리하고 나중에 jtidy를 수행한다는 것입니다.