2017-09-29 1 views
1

XSL 1.0을 사용하여 XML을 PDF로 변환하는 데 Apache FOP를 사용하고 있습니다.XSLT PDF에서 " "또는 줄 바꿈 특수 문자를 어떻게 이스케이프 처리합니까?

나는 XML 노드를

<ABC>This is one line&#xD; 
    This is second line&#xD; 
This is third line</ABC> 

을했습니다 내가 노드 즉

This is one line 
    This is second line 
    This is third line 

하지만 그것은 단지 하나 개의 라인에서 오는 유사한 출력을 할 수 있습니다. xsl에서 "& #xD"를 탈출 할 수있는 해결책이 있습니까? 다음 코드는 노드의 값을 가져 오는 데 사용됩니다. 문제를 해결하는 방법에

<xsl:value-of select="ABC" disable-output-escaping="yes" /> 
+0

[XSLT 새로운 행이 보존되지 않음] 가능한 복제본 (https://stackoverflow.com/questions/36802214/xslt-new-lines-not-being-preserved) – lfurini

답변

2

찾으시는 속성은 linefeed-treatment입니다.

별도의 단락 등의 바꿈 구분 텍스트를 처리하는 효과를 가질 것이다 "preserve"로 설정

그래서 이와

<fo:block linefeed-treatment="preserve">A 
B 
C</fo:block> 

같은 블록은 출력 세 라인을 생성한다

A 
B 
C 
+0

감사합니다. 이것은 나를 돕고 나를 위해 일했습니다. –

0

우리가 다음 경기에 분할 만 일치하지 않는 문자열을 사용한다는 사실을 사용하여

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 
    <xsl:template match="/"> 
     <xsl:analyze-string select="ABC" regex="&#xD;"> 
      <xsl:matching-substring></xsl:matching-substring> 
      <xsl:non-matching-substring> 
       <xsl:value-of select="."/> 
      </xsl:non-matching-substring> 
     </xsl:analyze-string> 
    </xsl:template> 
</xsl:stylesheet> 

같은 분석 문자열입니다.

+3

포스터가 "사용 중"이라고 말하는 데 도움이되는지 확실하지 않습니다. XSL 1.0 " –

+0

아니, 그건 약간의 미끄럼틀 실수 다. –

관련 문제