XML文件的代码和microsoft-com:Office:office" />
.NET/Develop/read_article.ASP?id=20733">http://www.csdn.net/Develop/read_article.asp?id=20733 相同
格式转换的xslT-FO文件的代码如下:
watchlist.pdf.xsl
<?xml version="1.0"?>
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
>
root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- defines page layout -->
page-height="29.7cm"
page-width="21cm"
margin-top="1.5cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<!-- defines the content -->
font-size="10pt"
font-family="serif"
line-height="14pt" >
Watch List - Customer #select="./quote-list/customer/@id"/>
font-family="sans-serif"
font-weight="bold"
line-height="26pt"
space-after.optimum="12pt"
background-color="blue"
color="white"
text-align="center">
Your Stock Watch List
font-family="sans-serif"
font-weight="bold"
line-height="18pt"
space-after.optimum="10pt"
start-indent="10pt">
Hello,
font-family="sans-serif"
font-style="italic"
line-height="18pt"
space-after.optimum="10pt"
start-indent="15pt">
Prices were obtained at on
line-height="14pt"
font-family="sans-serif">
SYMBOL
COMPANY NAME
SHARE PRICE
line-height="16pt"
font-family="sans-serif">
$
pdfWriter.jsp
String aa=getservletContext().getRealPath("/")+"J2EE_xml";
String fileName="watchlist.xml";
String trace=aa+fileName;
String styleName="watchlist.pdf.xsl";
String styleTrace=aa+styleName;
String resultName="aa.pdf";
String resultTrace=aa+resultName;
XML.PDFWriter PDFWriter = new XML.PDFWriter();
try {
PDFWriter.createPDFFromXML(styleTrace,trace, resultTrace);
} catch (Exception e) {
System.out.println(e.getMessage());
}
%>
aa.pdf就是格式化后的结果。
到现在使用XML数据的三种方式都介绍过了:
直接读取:http://www.csdn.net/Develop/read_article.asp?id=20720
使用XSLT转化成HTML:http://www.csdn.net/Develop/read_article.asp?id=20733
和这篇里介绍的使用XSL-FO转化成二进制格式。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-962027/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10752043/viewspace-962027/