0
xslt 및 fop을 사용하여 xml에서 PDF를 생성합니다. PDF로 보내고 싶습니다 모두 < br/> 줄 바꿈으로 대체되었습니다. 첫 번째 SalesOrderItem에서 xsl fop의 줄 바꿈
는 줄 바꿈 SHORTDESCRIPTION에이 사람은 잘 작동하지만 두 번째 SalesOrderItem에 < BR/>가 OrderText에 있고 괄호 이스케이프된다. 보시다시피, & lt; br/& gt; < br/> 대신. 여기서 줄 바꿈이 작동하지 않습니다. 교체를 시도했지만 작동하지 않았습니다.내 XML은 다음과 같습니다
<SalesOrderItem>
<ReceivingPerson>...</ReceivingPerson>
<Building />
<Department>...</Department>
<Floor />
<Room />
<DeliveryAddress>
</DeliveryAddress>
<IsFreetext>false</IsFreetext>
<OrderItemNo>1</OrderItemNo>
<ProductId>800100</ProductId>
<ExtProductId />
<ProductDescShort>Text1 <br/><b>text2</b></ProductDescShort>
<Quantity>1,00</Quantity>
<PriceUnit>1</PriceUnit>
<NetPrice>20,00</NetPrice>
<TotalNetPrice>20,00</TotalNetPrice>
<GLAccount>
<GLAccountId>123</GLAccountId>
<DescShort />
<CustomerId>customer1</CustomerId>
</GLAccount>
<DeliveryDate>06.04.2017</DeliveryDate>
<OrderText />
<UnitOfMeasure id='PCE'>
<Description>Stück</Description>
</UnitOfMeasure>
<Status id='090'>
<StatusDesc>offen</StatusDesc>
</Status>
<Tax id='BB'>
<Description>19%</Description>
</Tax>
<CostDistribution>
<CostDistributionPositions>
<CostDistributionPos>
<CostObject>
<CostObjectId>1006901</CostObjectId>
<CostObjectType>COSTCENTER</CostObjectType>
<CustomerId>customer1</CustomerId>
<MasterCostObjectId>NP-RNS</MasterCostObjectId>
</CostObject>
<Percentage>100,00</Percentage>
</CostDistributionPos>
</CostDistributionPositions>
</CostDistribution>
<DocumentAttachments />
<Attributes />
<ExtGLAccountId />
<Comment />
<Supplier supplierId='90025370'>
<SupplierName>WORDSHOP</SupplierName>
<SupplierLanguage>de</SupplierLanguage>
<AddressAssociation type='default' default='true'>
<Address id='90025370'>
</Address>
</AddressAssociation>
<TermsOfDelivery>
<Description />
<LongDescription />
</TermsOfDelivery>
<TermsOfPayment>
<Description>30 Tage netto</Description>
<LongDescription>30 Tage netto</LongDescription>
<DiscountDays1>30</DiscountDays1>
<DiscountDays2>0</DiscountDays2>
<NetDays />
<DiscountPerc1>0</DiscountPerc1>
<DiscountPerc2>0</DiscountPerc2>
</TermsOfPayment>
</Supplier>
</SalesOrderItem>
<SalesOrderItem>
<ReceivingPerson>fdf</ReceivingPerson>
<Building />
<Department/>
<Floor />
<Room />
<DeliveryAddress>
</DeliveryAddress>
<IsFreetext>false</IsFreetext>
<OrderItemNo>2</OrderItemNo>
<ProductId>50049411</ProductId>
<ExtProductId />
<ProductDescShort>Product desc</ProductDescShort>
<Quantity>1.670,00</Quantity>
<PriceUnit>1</PriceUnit>
<NetPrice>0,01</NetPrice>
<TotalNetPrice>16,70</TotalNetPrice>
<GLAccount>
<GLAccountId>9764955002</GLAccountId>
<DescShort />
<CustomerId>customer1</CustomerId>
</GLAccount>
<DeliveryDate>30.03.2017</DeliveryDate>
<OrderText>7090070589<br/>17<br/>13.02.2017<br/>name 1<br/>12345<br/>Musterstadt<br/>Strasse 25<br/>D</OrderText>
<UnitOfMeasure id='PCE'>
<Description>Stück</Description>
</UnitOfMeasure>
<Status id='090'>
<StatusDesc>offen</StatusDesc>
</Status>
<Tax id='N8'>
<Description>7%</Description>
</Tax>
<CostDistribution>
<CostDistributionPositions>
<CostDistributionPos>
<CostObject>
<CostObjectId>1006901</CostObjectId>
<CostObjectType>COSTCENTER</CostObjectType>
<CustomerId>customer1</CustomerId>
<MasterCostObjectId>c1</MasterCostObjectId>
</CostObject>
<Percentage>100,00</Percentage>
</CostDistributionPos>
</CostDistributionPositions>
</CostDistribution>
<DocumentAttachments />
<Attributes />
<ExtGLAccountId />
<Comment />
<Supplier supplierId='90004996'>
<SupplierName>supplier1</SupplierName>
<SupplierLanguage>de</SupplierLanguage>
<AddressAssociation type='default' default='true'>
<Address id='90004996'>
</Address>
</AddressAssociation>
<TermsOfDelivery>
<Description />
<LongDescription />
</TermsOfDelivery>
<TermsOfPayment>
<Description>innerhalb von 14 Tagen ohne Abzug</Description>
<LongDescription>innerhalb von 14 Tagen ohne Abzug</LongDescription>
<DiscountDays1>14</DiscountDays1>
<DiscountDays2>0</DiscountDays2>
<NetDays />
<DiscountPerc1>0</DiscountPerc1>
<DiscountPerc2>0</DiscountPerc2>
</TermsOfPayment>
</Supplier>
</SalesOrderItem>
내 XSLT는 다음과 같습니다
<xsl:template match="br">
<fo:block><xsl:apply-templates/></fo:block>
</xsl:template>
...
<xsl:for-each select="SalesOrder/SalesOrderItems/SalesOrderItem">
...
<xsl:if test="ProductDescShort">
<fo:block><xsl:apply-templates select="ProductDescShort"/></fo:block>
</xsl:if>
...
<xsl:if test="OrderText!=''">
<fo:table-row keep-with-next.within-line="always" keep-with-previous.within-line="always" keep-with-previous.within-column="always" keep-with-previous.within-page="always">
<fo:table-cell/><fo:table-cell number-columns-spanned="3" display-align="before">
<fo:block position="relative" white-space-collapse="false" linefeed-treatment="preserve" start-indent="2.0pt" display-align="before" text-align="start" color="#000000" font-family="Arial" font-size="10.0pt">
<xsl:apply-templates select="OrderText"/>
</fo:block>
</fo:table-cell>
...
</xsl:for-each>
편집 :
이 같은 교체를 변경하지만 원 ' 대체하지 마라. 내 바꾸기 검색 문자열이 잘못되었다고 생각하지만 일치하도록 만들기 위해 내가 무엇을 삽입해야하는지 알 수 없습니다.
<xsl:if test="OrderText!=''">
<fo:table-row keep-with-next.within-line="always" keep-with-previous.within-line="always" keep-with-previous.within-column="always" keep-with-previous.within-page="always">
<fo:table-cell/><fo:table-cell number-columns-spanned="3" display-align="before">
<fo:block position="relative" white-space-collapse="false" linefeed-treatment="preserve" start-indent="2.0pt" display-align="before" text-align="start" color="#000000" font-family="Arial" font-size="10.0pt">
<xsl:variable name="newtext">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="OrderText" />
<xsl:with-param name="replace" select="'&lt;br/&gt;'" />
<xsl:with-param name="by" select="20" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$newtext"/>
</fo:block>
</fo:table-cell>
...
<!-- Replace Template -->
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="$text = '' or $replace = ''or not($replace)" >
<!-- Prevent this routine from hanging -->
<xsl:value-of select="$text" />
</xsl:when>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
주변 블록에 linefreed-treatment = preserve가있는 경우 fo : 블록을 사용하는 대신 을 텍스트에 삽입하면됩니다. 그러나, 나는 당신이 템플릿을 볼 수 없어 브래지어가 OrderText 안에있는 < 어딘가에 > 어딘가에 –
으로 이스케이프되었습니다. 브릿지는 이미 xml에서 이스케이프 처리되었으므로 바꿀 기회가 없습니다. 나는 줄 바꿈으로 대체하려고 시도했다. 그러나 어떻게 든 그것을 작동시키지 못했다. 나는 [link] (http://stackoverflow.com/questions/3067113/xslt-string-replace)에서 해결책을 시도했지만 일치시킬 수 없었다. 어떤 아이디어? –
템플릿을 사용하여 '& lt; br/& gt;' 에 의해 오른쪽? 출력물에 개행 문자가 포함되었는지 여부를 확인할 수 있습니까? 아니면 개머리판 쇠고랑에 있었지만 존경받지 못했던가? –