任何人都可以建议我做错了什么:格式化这个xslt准备word文档它会抛出下一个空白页面,即使它底部有很多空间。事件我试图通过样式管理边距和空格。 这是我的xml:
<?xml version="1.0" encoding="utf-8"?><Invoices>
<Invoice InvoiceId="12" JobId="1" AppraisalRef="JOBRefNo#1" invoicedescription="XXXXX" createdYear="2016" createdMonthName="May" createdMonth="5" createdDayName="Wednesday" createdDay="25" AccountName="rahul" Address1="adline1" Address2="Addline 2" Address3="addline 3" City="city" Region="region" PostalCode="110040">
<InvoiceLinedesc linedesc="yyyy" lineamount="11.11" />
<InvoiceLinedesc linedesc="xzy" lineamount="12.00" />
<InvoiceLinedesc linedesc="abc" lineamount="100.00" />
<InvoiceLinedesc linedesc="pqr" lineamount="120.00" />
<InvoiceLinedesc linedesc="coer" lineamount="-100.00" />
<InvoiceLinedesc linedesc="axz" lineamount="-50.00" />
<InvoiceLinedesc linedesc="jhsdf" lineamount="100.00" />
<InvoiceLinedesc lineamountsum="193.11" />
</Invoice>
</Invoices>
这个是XSLT代码:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="/1999/XSL/Transform" version="1.0">
<xsl:variable name="currencyFormat" select="'$#,###.00'"/>
<xsl:variable name="companyName" select="'Lyon & Turnbull'"/>
<xsl:variable name="logoUrl" select="Request.Url.Scheme + '://' + Request.ServerVariables['HTTP_HOST'] + '/assets/images/logo_new.png'"/>
<xsl:template match="Invoices">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
<style>
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Gotham Bold";
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Gotham Book";
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Gotham Light";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p, li, div
{
margin: 0pt;
font-size:12.0pt;
font-family:"Gotham Book","sans-serif";
display:inline-block;
}
p.Subtitle
{
font-size:10.0pt;
font-family:"Gotham Book","sans-serif";
font-style:italic;
}
p.Bold
{
font-family:"Gotham Bold","sans-serif";
font-weight:bold;
}
p.DoubleHeight
{
font-size:10.0pt;
margin-top:24.0pt
}
p.NoHeight
{
font-size:10.0pt;
margin-top:0pt
}
p.SingleHeight
{
font-size:10.0pt;
margin-top:12.0pt
}
p.Italic
{
font-style:italic;
}
h1
{
margin-top:48.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
page-break-after:avoid;
font-size:22.0pt;
font-family:"Gotham Bold","sans-serif";
font-weight:bold;
}
h2
{
margin-top:24.0pt;
margin-right:0cm;
margin-bottom:12.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:12.0pt;
font-family:"Gotham Book","sans-serif";
font-weight:normal;
}
table
{
margin: 0;
border-collapse:collapse;
border-spacing:0;
padding: 0;
width: 100%;
}
td
{
padding:0 10pt 0 0;
vertical-align: top;
}
table.Footer
{
width: 100%;
}
p.Footer
{
font-size:9px;
font-family:"Gotham Light","sans-serif";
}
@page WordSection1
{
size:612.0pt 792.0pt;
margin: 0.0pt 72.0pt 0pt 72.0pt; /* US: 2.25in 1in 1in 1in; */
mso-header: h1;
mso-footer: f1;
}
div.WordSection1
{
page:WordSection1;
}
td.logo1
{
opacity:0.4;
}
</style>
</HEAD>
<body lang="EN-GB">
<div class="WordSection1">
<table>
<tr>
<td>
<div style='margin-left: -20in; margin-right: -10in;'>
<div style='mso-element:header;' id='h1' >
<img width='200' height='40' src="/images/new_logo.png" />
</div>
</div>
</td>
<td>
<div class="logo1" style='margin-left: 5.2in;align:right;'>
<img width='100' height='100' src="/assets/images/BarcodeImg.png" />
</div>
</td>
</tr>
</table>
<br/>
<table>
<tr>
<td></td>
<td align="right" style='font-size: 8px;'>• • •</td>
</tr>
<tr>
<td>
<div>
<p>
<xsl:value-of select="concat(Invoice/@createdMonthName,' ',Invoice/@createdDay,', ',Invoice/@createdYear )"/>
</p>
<br/>
<p>
<xsl:value-of select="Invoice/@AccountName"/>
</p>
<xsl:if test="Invoice/@Address1!=''" >
<p>
<xsl:value-of select="Invoice/@Address1"/>
</p>
</xsl:if>
<xsl:if test="Invoice/@Address2!=''" >
<p>
<xsl:value-of select="Invoice/@Address2"/>
</p>
</xsl:if>
<xsl:if test="Invoice/@Address3!=''" >
<p>
<xsl:value-of select="Invoice/@Address3"/>
</p>
</xsl:if>
<xsl:if test="Invoice/@City!=''" >
<p>
<xsl:value-of select="Invoice/@City"/>
</p>
</xsl:if>
<p>
<xsl:if test="Invoice/@Region!=''" >
<xsl:value-of select="concat(Invoice/@Region,', ')"/>
</xsl:if>
<xsl:if test="Invoice/@PostalCode!=''" >
<xsl:value-of select="Invoice/@PostalCode"/>
</xsl:if>
</p>
<!--<xsl:if test="Invoice/@PostalCode!=''" >
<p>
<xsl:value-of select="Invoice/@PostalCode"/>
</p>
</xsl:if>-->
</div>
</td>
<td style="align:right">
<p align='right' style='font-size: 8.0pt;'>
1150 First Avenue Suite 150
</p>
<p align='right' style='font-size: 8.0pt;'>
King of Prussia, PA, 19406
<br/>
</p>
<p align='right' style='font-size: 8.0pt; color:#8CC63F;'>
+1 610 254 8400
<br/>
</p>
<p align='right' style='font-size: 8.0pt; color:#8CC63F;'>
info@abc.com
<br/>
</p>
<p align='right' style='font-size: 8.0pt;'>
abc.com
</p>
</td>
</tr>
</table>
<!--<h1 align='center'>
INVOICE FOR APPRAISAL SERVICES
</h1>-->
<h2 style="font-size:12.0pt; text-align:center; font-family: Times;">
<b>
<xsl:value-of select="Invoice/@invoicedescription"/>
</b>
</h2>
<table>
<xsl:for-each select="Invoice/InvoiceLinedesc">
<!--<p style='line-height:150%'>
<span style="text-align: left; margin-right: 0pt;">
<xsl:value-of select="@linedesc"/>
</span>
<span style="text-align: right; margin-left: 0pt;">
<xsl:if test="number(@lineamount) = @lineamount" >
<xsl:value-of select="format-number(@lineamount, $currencyFormat)"/>
</xsl:if>
</span>
</p>-->
<tr>
<td valign='top'>
<p style='line-height:150%'>
<xsl:value-of select="@linedesc"/>
</p>
</td>
<td>
<p style="text-align: right; margin-left: 32pt; line-height:150%">
<xsl:if test="number(@lineamount) = @lineamount" >
<xsl:value-of select="format-number(@lineamount, $currencyFormat)"/>
</xsl:if>
</p>
</td>
</tr>
</xsl:for-each>
</table>
<table>
<tr>
<td with="50%">
<p class="Bold"></p>
</td>
<td width="50%">
<p style="text-align: right; margin-left: 32pt;">
<hr/>
</p>
</td>
</tr>
<tr>
<td with="50%">
<p class="Bold"></p>
</td>
<td width="50%">
<p style="text-align: right; margin-left: 32pt;">
</p>
</td>
</tr>
<tr>
<td>
<p class="Bold"></p>
</td>
<td>
<p style="text-align: right; margin-left: 32pt;">
Subtotal:
<xsl:if test="number(Invoice/InvoiceLinedesc/@lineamountsum) = Invoice/InvoiceLinedesc/@lineamountsum" >
<xsl:value-of select="format-number(Invoice/InvoiceLinedesc/@lineamountsum, $currencyFormat)"/>
</xsl:if>
</p>
</td>
</tr>
<tr>
<td>
<p class="Bold"></p>
</td>
<td>
<p style="text-align: right; margin-left: 32pt;">
Deposit Received:
</p>
</td>
</tr>
<tr>
<td>
<p class="Bold"></p>
</td>
<td>
<p class="Bold" style="text-align: right; margin-left: 32pt;">
Balance Due:
</p>
</td>
</tr>
</table>
<br/>
<p>
Payment is due upon receipt. Accepted forms of payment: VISA, MasterCard, American Express, Discover, Personal or Corporate checks, Wire Transfer.
</p>
<br/>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td>Please remit payment to:</td>
<td>
<!--Wire Instructions:-->
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>Abc Pvt. Ltd.</td>
<td>
<!--Receiving Bank: PNC Bank-->
</td>
</tr>
<tr>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
</td>
</tr>
<!--<tr>
<td></td>
<td>
--><!-- --><!--
</td>
</tr>
<tr>
<td></td>
<td>
--><!--Beneficiary: --><!--
</td>
</tr>
<tr>
<td></td>
<td>
--><!--Beneficiary Account Number: --><!--
</td>
</tr>-->
</table>
<div style='margin-left: -20in; margin-right: -10in;'>
<div style='mso-element:footer' id='f1'>
<P style='font-size:6.0pt;'>
• • •
</P>
<P style='font-size:8.0pt; font-family: Times;'>
LONDON  •  NEW YORK  •  PHILADELPHIA  •  LOS ANGELES  •  ATLANTA  •  AMSTERDAM
</P>
<br/>
<P class='Footer' style='font-size:6.5pt;'>
is the trading name of abc Limited and its subsidiary companies. Abc is a company registered in England and Wales.
<BR/>
<BR/>
Registered number: . Registered office: . VAT.
<BR/>
<BR/>
©2015 . All Rights Reserved.
</P>
</div>
</div>
</div>
</body>
</HTML>
</xsl:template>
</xsl:stylesheet>
提前致谢。
答案 0 :(得分:0)
您不会显示您的输入XML或HTML输出,所以这一切都是一种猜测,但尝试的一件事就是添加
<xsl:strip-space elements="*"/>