Xml xsl fop中的换行符
我使用xslt和fop从xml生成PDF。 在PDF中,我想用换行符替换所有Xml xsl fop中的换行符,xml,xslt,apache-fop,Xml,Xslt,Apache Fop,我使用xslt和fop从xml生成PDF。 在PDF中,我想用换行符替换所有 在第一个SalesOrderItem中,换行符在ShortDescription中,这一行可以正常工作,但在第二个SalesOrderItem中,在OrderText中,括号被转义。如您所见,这里有br/而不是。这里断线不起作用。 我试着更换,但没用 我的xml如下所示: <SalesOrderItem> <ReceivingPerson>...</ReceivingPe
在第一个SalesOrderItem中,换行符在ShortDescription中,这一行可以正常工作,但在第二个SalesOrderItem中,
在OrderText中,括号被转义。如您所见,这里有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>
<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>
...
...
假的
1.
800100
Text1
text2
1,00
1.
20,00
20,00
123
顾客1
06.04.2017
Stück
奥芬
19%
1006901
成本中心
顾客1
NP-RNS
100,00
文字商店
判定元件
30塔吉内托
30塔吉内托
30
0
0
0
fdf
假的
2.
50049411
产品说明
1.670,00
1.
0,01
16,70
9764955002
顾客1
30.03.2017
7090070589br/17br/13.02.2017br/name 1br/12345br/Musterstadtbr/Strasse 25br/D
Stück
奥芬
7%
1006901
成本中心
顾客1
c1
100,00
供应商1
判定元件
14塔根·奥恩·阿布祖格酒店
14塔根·奥恩·阿布祖格酒店
14
0
0
0
我的XSLT如下所示:
<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>
<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>
...
错误处的“替换”和“由”中的参数。这是有效的:
<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="'<br/>'" />
<xsl:with-param name="by" select="'
'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$newtext"/>
</fo:block>
在Oxygen Developer中,我无法实现此功能,但在运行此功能的系统上,必须有一个不同的XSLT处理器,并且该处理器可以工作。您只需插入 ;如果周围的块具有linefreed treatment=preserve,则插入文本,而不是使用fo:block。但是,我没有看到您调用br模板,OrderText中的br已转义到br somewhere,其中br已在xml中转义,我没有机会更改。我试图用换行符替换它 ;但不知怎么的,我没能让它工作。我尝试了来自的解决方案,但无法使其匹配。有什么想法吗?所以你试着用模板来代替“&;书信电报;br/&;gt;'由 ;正确的?并且可以验证输出是否包含换行符?或者换行符在fop中,但不受fop的尊重?@StefanHegny我试图替换,但它没有将换行符替换为br,请查看我的编辑。嗯,在您的编辑中,您是否将其替换为“20”?(约8行)