以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  xml+xsl=>html(java)  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=17182)


--  作者:sinostone
--  发布时间:4/19/2005 4:37:00 PM

--  xml+xsl=>html(java)
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;

import java.io.FileOutputStream;
import java.io.FileNotFoundException;

public class JAXPTransform {
 public static void main(String args[]) throws TransformerConfigurationException, TransformerException, FileNotFoundException {
  TransformerFactory factory = TransformerFactory.newInstance();
  
  StreamSource stylesheet = new StreamSource(args[1]);
  StreamSource xmlDoc = new StreamSource(args[0]);
  StreamResult result = new StreamResult(new FileOutputStream(args[2]));
  
  Transformer transFormer = factory.newTransformer(stylesheet);
  transFormer.transform(xmlDoc, result);
 }
}


--  作者:city22
--  发布时间:4/23/2005 9:59:00 PM

--  
怎么用呢 javac JAXPTransform 1.xml 2.xsl 3.html 吗?
--  作者:sinostone
--  发布时间:4/24/2005 9:09:00 AM

--  
先编译然后再运行
--  作者:菜籽
--  发布时间:4/24/2005 6:38:00 PM

--  
如何才能在网页中显示啊?
--  作者:sinostone
--  发布时间:4/25/2005 9:56:00 AM

--  
合成html不就可以在ie里显示了吗?
--  作者:zzzvvv
--  发布时间:5/13/2005 4:09:00 PM

--  
好像用不着这么复杂吧
--  作者:xinxi011
--  发布时间:5/21/2005 3:22:00 PM

--  
试试
--  作者:athws
--  发布时间:9/2/2005 2:00:00 PM

--  
那xml+xsl到wml。这样做是不是也可以?
--  作者:mimituo
--  发布时间:12/30/2005 4:23:00 PM

--  
[Error] classdict.xsl:149:49: Element type "td" must be declared.
[Error] classdict.xsl:150:22: Element type "td" must be declared.
[Error] classdict.xsl:152:66: Element type "table" must be declared.
[Error] classdict.xsl:153:11: Element type "tr" must be declared.
[Error] classdict.xsl:154:58: Element type "td" must be declared.
[Error] classdict.xsl:155:69: Element type "table" must be declared.
[Error] classdict.xsl:156:11: Element type "tr" must be declared.
[Error] classdict.xsl:157:24: Element type "td" must be declared.
[Error] classdict.xsl:160:69: Element type "table" must be declared.
[Error] classdict.xsl:161:10: Element type "tr" must be declared.
[Error] classdict.xsl:162:37: Element type "td" must be declared.
[Error] classdict.xsl:162:59: Element type "span" must be declared.
[Error] classdict.xsl:162:172: Element type "img" must be declared.
[Error] classdict.xsl:162:210: Element type "a" must be declared.
[Error] classdict.xsl:162:277: Element type "a" must be declared.
[Error] classdict.xsl:162:330: Element type "span" must be declared.
[Error] classdict.xsl:165:81: Element type "table" must be declared.
[Error] classdict.xsl:166:23: Element type "tr" must be declared.
[Error] classdict.xsl:167:111: Element type "td" must be declared.
[Error] classdict.xsl:171:68: Element type "table" must be declared.
[Error] classdict.xsl:172:23: Element type "tr" must be declared.
[Error] classdict.xsl:173:36: Element type "td" must be declared.
[Error] classdict.xsl:174:85: Element type "table" must be declared.
[Error] classdict.xsl:175:29: Element type "tr" must be declared.
[Error] classdict.xsl:176:53: Element type "td" must be declared.
[Error] classdict.xsl:176:148: Element type "img" must be declared.
[Error] classdict.xsl:177:94: Element type "td" must be declared.
[Error] classdict.xsl:178:59: Element type "form" must be declared.
[Error] classdict.xsl:179:55: Element type "span" must be declared.
[Error] classdict.xsl:180:110: Element type "select" must be declared.
[Error] classdict.xsl:182:51: Element type "xsl:for-each" must be declared.
[Error] classdict.xsl:183:32: Element type "xsl:if" must be declared.
[Error] classdict.xsl:184:42: Element type "option" must be declared.
[Error] classdict.xsl:185:25: Element type "option" must be declared.
[Error] classdict.xsl:186:25: Element type "option" must be declared.
[Error] classdict.xsl:190:51: Element type "xsl:for-each" must be declared.
[Error] classdict.xsl:191:34: Element type "xsl:if" must be declared.
[Error] classdict.xsl:192:44: Element type "option" must be declared.
[Error] classdict.xsl:193:25: Element type "option" must be declared.
[Error] classdict.xsl:194:23: Element type "option" must be declared.
[Error] classdict.xsl:198:51: Element type "xsl:for-each" must be declared.
[Error] classdict.xsl:199:34: Element type "xsl:if" must be declared.
[Error] classdict.xsl:200:44: Element type "option" must be declared.
[Error] classdict.xsl:201:25: Element type "option" must be declared.
[Error] classdict.xsl:202:25: Element type "option" must be declared.
[Error] classdict.xsl:210:65: Element type "td" must be declared.
[Error] classdict.xsl:211:72: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:216:98: Element type "table" must be declared.
[Error] classdict.xsl:217:9: Element type "tr" must be declared.
[Error] classdict.xsl:218:20: Element type "td" must be declared.
[Error] classdict.xsl:219:67: Element type "table" must be declared.
[Error] classdict.xsl:220:7: Element type "tr" must be declared.
[Error] classdict.xsl:221:51: Element type "td" must be declared.
[Error] classdict.xsl:222:103: Element type "table" must be declared.
[Error] classdict.xsl:223:43: Element type "tr" must be declared.
[Error] classdict.xsl:224:74: Element type "td" must be declared.
[Error] classdict.xsl:225:42: Element type "div" must be declared.
[Error] classdict.xsl:226:77: Element type "div" must be declared.
[Error] classdict.xsl:227:75: Element type "td" must be declared.
[Error] classdict.xsl:228:42: Element type "div" must be declared.
[Error] classdict.xsl:229:74: Element type "td" must be declared.
[Error] classdict.xsl:230:42: Element type "div" must be declared.
[Error] classdict.xsl:231:86: Element type "td" must be declared.
[Error] classdict.xsl:232:42: Element type "div" must be declared.
[Error] classdict.xsl:236:51: Element type "td" must be declared.
[Error] classdict.xsl:237:103: Element type "table" must be declared.
[Error] classdict.xsl:238:43: Element type "tr" must be declared.
[Error] classdict.xsl:239:74: Element type "td" must be declared.
[Error] classdict.xsl:240:42: Element type "div" must be declared.
[Error] classdict.xsl:241:77: Element type "div" must be declared.
[Error] classdict.xsl:242:75: Element type "td" must be declared.
[Error] classdict.xsl:243:42: Element type "div" must be declared.
[Error] classdict.xsl:244:74: Element type "td" must be declared.
[Error] classdict.xsl:245:42: Element type "div" must be declared.
[Error] classdict.xsl:246:86: Element type "td" must be declared.
[Error] classdict.xsl:247:42: Element type "div" must be declared.
[Error] classdict.xsl:258:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:259:45: Element type "xsl:for-each" must be declared.
[Error] classdict.xsl:260:66: Element type "table" must be declared.
[Error] classdict.xsl:265:6: Element type "tr" must be declared.
[Error] classdict.xsl:267:19: Element type "td" must be declared.
[Error] classdict.xsl:269:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:270:83: Element type "table" must be declared.
[Error] classdict.xsl:271:12: Element type "tr" must be declared.
[Error] classdict.xsl:273:38: Element type "td" must be declared.
[Error] classdict.xsl:274:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:275:70: Element type "table" must be declared.
[Error] classdict.xsl:276:41: Element type "tr" must be declared.
[Error] classdict.xsl:277:52: Element type "td" must be declared.
[Error] classdict.xsl:281:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:282:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:283:96: Element type "table" must be declared.
[Error] classdict.xsl:284:21: Element type "tbody" must be declared.
[Error] classdict.xsl:285:19: Element type "tr" must be declared.
[Error] classdict.xsl:286:46: Element type "td" must be declared.
[Error] classdict.xsl:288:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:289:73: Element type "table" must be declared.
[Error] classdict.xsl:290:54: Element type "tbody" must be declared.
[Error] classdict.xsl:291:56: Element type "tr" must be declared.
[Error] classdict.xsl:292:29: Element type "td" must be declared.
[Error] classdict.xsl:293:64: Element type "table" must be declared.
[Error] classdict.xsl:294:72: Element type "tbody" must be declared.
[Error] classdict.xsl:295:71: Element type "tr" must be declared.
[Error] classdict.xsl:296:25: Element type "td" must be declared.
[Error] classdict.xsl:297:64: Element type "table" must be declared.
[Error] classdict.xsl:298:35: Element type "tbody" must be declared.
[Error] classdict.xsl:299:80: Element type "tr" must be declared.
[Error] classdict.xsl:301:38: Element type "td" must be declared.
[Error] classdict.xsl:301:41: Element type "a" must be declared.
[Error] classdict.xsl:301:68: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:301:102: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:302:41: Element type "img" must be declared.
[Error] classdict.xsl:303:28: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:304:40: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:321:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:322:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:324:69: Element type "table" must be declared.
[Error] classdict.xsl:325:74: Element type "tbody" must be declared.
[Error] classdict.xsl:326:73: Element type "tr" must be declared.
[Error] classdict.xsl:327:62: Element type "td" must be declared.
[Error] classdict.xsl:327:158: Element type "img" must be declared.
[Error] classdict.xsl:328:47: Element type "div" must be declared.
[Error] classdict.xsl:332:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:337:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:338:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:339:66: Element type "table" must be declared.
[Error] classdict.xsl:340:53: Element type "tr" must be declared.
[Error] classdict.xsl:341:66: Element type "td" must be declared.
[Error] classdict.xsl:344:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:345:45: Element type "td" must be declared.
[Error] classdict.xsl:345:67: Element type "span" must be declared.
[Error] classdict.xsl:345:89: Element type "span" must be declared.
[Error] classdict.xsl:346:21: Element type "a" must be declared.
[Error] classdict.xsl:346:48: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:346:82: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:347:35: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:347:77: Element type "span" must be declared.
[Error] classdict.xsl:350:28: Element type "td" must be declared.
[Error] classdict.xsl:350:50: Element type "span" must be declared.
[Error] classdict.xsl:351:23: Element type "div" must be declared.
[Error] classdict.xsl:351:45: Element type "span" must be declared.
[Error] classdict.xsl:351:77: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:352:40: Element type "td" must be declared.
[Error] classdict.xsl:352:60: Element type "div" must be declared.
[Error] classdict.xsl:352:82: Element type "span" must be declared.
[Error] classdict.xsl:352:114: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:354:5: Element type "tr" must be declared.
[Error] classdict.xsl:355:30: Element type "td" must be declared.
[Error] classdict.xsl:355:52: Element type "span" must be declared.
[Error] classdict.xsl:355:85: Element type "span" must be declared.
[Error] classdict.xsl:356:34: Element type "a" must be declared.
[Error] classdict.xsl:357:29: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:358:58: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:360:32: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:362:45: Element type "tr" must be declared.
[Error] classdict.xsl:363:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:364:15: Element type "tr" must be declared.
[Error] classdict.xsl:365:90: Element type "td" must be declared.
[Error] classdict.xsl:366:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:367:70: Element type "table" must be declared.
[Error] classdict.xsl:368:51: Element type "tr" must be declared.
[Error] classdict.xsl:369:81: Element type "td" must be declared.
[Error] classdict.xsl:372:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:373:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:374:87: Element type "table" must be declared.
[Error] classdict.xsl:375:53: Element type "tr" must be declared.
[Error] classdict.xsl:376:67: Element type "td" must be declared.
[Error] classdict.xsl:376:89: Element type "span" must be declared.
[Error] classdict.xsl:380:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:383:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:390:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:395:21: Element type "td" must be declared.
[Error] classdict.xsl:396:26: Element type "xsl:if" must be declared.
[Error] classdict.xsl:397:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:398:83: Element type "table" must be declared.
[Error] classdict.xsl:399:12: Element type "tr" must be declared.
[Error] classdict.xsl:401:38: Element type "td" must be declared.
[Error] classdict.xsl:402:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:403:70: Element type "table" must be declared.
[Error] classdict.xsl:404:41: Element type "tr" must be declared.
[Error] classdict.xsl:405:52: Element type "td" must be declared.
[Error] classdict.xsl:409:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:410:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:411:96: Element type "table" must be declared.
[Error] classdict.xsl:412:21: Element type "tbody" must be declared.
[Error] classdict.xsl:413:19: Element type "tr" must be declared.
[Error] classdict.xsl:414:46: Element type "td" must be declared.
[Error] classdict.xsl:416:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:417:73: Element type "table" must be declared.
[Error] classdict.xsl:418:54: Element type "tbody" must be declared.
[Error] classdict.xsl:419:56: Element type "tr" must be declared.
[Error] classdict.xsl:420:29: Element type "td" must be declared.
[Error] classdict.xsl:421:64: Element type "table" must be declared.
[Error] classdict.xsl:422:72: Element type "tbody" must be declared.
[Error] classdict.xsl:423:71: Element type "tr" must be declared.
[Error] classdict.xsl:424:25: Element type "td" must be declared.
[Error] classdict.xsl:425:64: Element type "table" must be declared.
[Error] classdict.xsl:426:35: Element type "tbody" must be declared.
[Error] classdict.xsl:427:80: Element type "tr" must be declared.
[Error] classdict.xsl:429:38: Element type "td" must be declared.
[Error] classdict.xsl:429:41: Element type "a" must be declared.
[Error] classdict.xsl:429:68: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:429:102: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:430:41: Element type "img" must be declared.
[Error] classdict.xsl:431:28: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:432:40: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:449:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:450:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:452:69: Element type "table" must be declared.
[Error] classdict.xsl:453:74: Element type "tbody" must be declared.
[Error] classdict.xsl:454:73: Element type "tr" must be declared.
[Error] classdict.xsl:455:62: Element type "td" must be declared.
[Error] classdict.xsl:455:158: Element type "img" must be declared.
[Error] classdict.xsl:456:47: Element type "div" must be declared.
[Error] classdict.xsl:460:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:465:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:466:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:467:66: Element type "table" must be declared.
[Error] classdict.xsl:468:53: Element type "tr" must be declared.
[Error] classdict.xsl:469:66: Element type "td" must be declared.
[Error] classdict.xsl:472:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:473:45: Element type "td" must be declared.
[Error] classdict.xsl:473:67: Element type "span" must be declared.
[Error] classdict.xsl:473:89: Element type "span" must be declared.
[Error] classdict.xsl:474:21: Element type "a" must be declared.
[Error] classdict.xsl:474:48: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:474:82: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:475:35: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:475:77: Element type "span" must be declared.
[Error] classdict.xsl:478:28: Element type "td" must be declared.
[Error] classdict.xsl:478:50: Element type "span" must be declared.
[Error] classdict.xsl:479:23: Element type "div" must be declared.
[Error] classdict.xsl:479:45: Element type "span" must be declared.
[Error] classdict.xsl:479:77: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:480:40: Element type "td" must be declared.
[Error] classdict.xsl:480:60: Element type "div" must be declared.
[Error] classdict.xsl:480:82: Element type "span" must be declared.
[Error] classdict.xsl:480:114: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:482:5: Element type "tr" must be declared.
[Error] classdict.xsl:483:30: Element type "td" must be declared.
[Error] classdict.xsl:483:52: Element type "span" must be declared.
[Error] classdict.xsl:483:85: Element type "span" must be declared.
[Error] classdict.xsl:484:34: Element type "a" must be declared.
[Error] classdict.xsl:485:29: Element type "xsl:attribute" must be declared.
[Error] classdict.xsl:486:58: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:488:32: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:490:45: Element type "tr" must be declared.
[Error] classdict.xsl:491:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:492:15: Element type "tr" must be declared.
[Error] classdict.xsl:493:90: Element type "td" must be declared.
[Error] classdict.xsl:494:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:495:70: Element type "table" must be declared.
[Error] classdict.xsl:496:51: Element type "tr" must be declared.
[Error] classdict.xsl:497:81: Element type "td" must be declared.
[Error] classdict.xsl:500:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:501:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:502:87: Element type "table" must be declared.
[Error] classdict.xsl:503:53: Element type "tr" must be declared.
[Error] classdict.xsl:504:67: Element type "td" must be declared.
[Error] classdict.xsl:504:89: Element type "span" must be declared.
[Error] classdict.xsl:508:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:511:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:518:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:526:14: Element type "xsl:comment" must be declared.
[Error] classdict.xsl:531:81: Element type "table" must be declared.
[Error] classdict.xsl:532:39: Element type "tr" must be declared.
[Error] classdict.xsl:533:70: Element type "td" must be declared.
[Error] classdict.xsl:536:127: Element type "table" must be declared.
[Error] classdict.xsl:537:31: Element type "tr" must be declared.
[Error] classdict.xsl:538:57: Element type "td" must be declared.
[Error] classdict.xsl:538:92: Element type "div" must be declared.
[Error] classdict.xsl:539:44: Element type "td" must be declared.
[Error] classdict.xsl:542:118: Element type "table" must be declared.
[Error] classdict.xsl:543:31: Element type "tr" must be declared.
[Error] classdict.xsl:544:57: Element type "td" must be declared.
[Error] classdict.xsl:544:92: Element type "div" must be declared.
[Error] classdict.xsl:544:163: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:545:44: Element type "td" must be declared.
[Error] classdict.xsl:557:34: Element type "td" must be declared.
[Error] classdict.xsl:559:80: Element type "table" must be declared.
[Error] classdict.xsl:560:7: Element type "tr" must be declared.
[Error] classdict.xsl:561:5: Element type "td" must be declared.
[Error] classdict.xsl:561:98: Element type "img" must be declared.
[Error] classdict.xsl:564:79: Element type "table" must be declared.
[Error] classdict.xsl:565:7: Element type "tr" must be declared.
[Error] classdict.xsl:566:9: Element type "td" must be declared.
[Error] classdict.xsl:566:68: Element type "SCRIPT" must be declared.
[Error] classdict.xsl:567:29: Element type "span" must be declared.
[Error] classdict.xsl:577:31: Element type "script" must be declared.
[Error] classdict.xsl:588:95: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:592:95: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:600:31: Element type "script" must be declared.
[Error] classdict.xsl:605:101: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:605:198: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:610:31: Element type "script" must be declared.
[Error] classdict.xsl:615:101: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:615:198: Element type "xsl:value-of" must be declared.
[Error] classdict.xsl:620:31: Element type "script" must be declared.

用你的方法测试了,报这么多是哪里的问题?


--  作者:xiongbajian
--  发布时间:1/3/2006 7:20:00 PM

--  
顺便问一下,有没有用Jdom实现的例子?谢谢了。
--  作者:mimituo
--  发布时间:1/19/2006 12:02:00 PM

--  
这段代码是我自己在网上一边收集,一边自己写的,需要JDOM包支持
String xslFile  模板文件的相对路径
Document xmlFile 生成的xmlFile文档
输出为一段HTML脚本,直接打印出来变是HTML
谢谢大家
  public static String getXmlAddXslToHtml(String xslFile, Document xmlFile) throws
      XSLTransformException, JDOMException, TransformerConfigurationException,
      TransformerException {

    try {
      org.jdom.output.DOMOutputter outputter = new org.jdom.output.DOMOutputter();
      org.w3c.dom.Document domDocument = outputter.output(xmlFile);
      javax.xml.transform.Source xmlSource =
          new javax.xml.transform.dom.DOMSource(domDocument);
      //将xml的document对象放入Source对象中
      String xslUri = "file:" + new File(xslFile).getAbsolutePath();
      StreamSource xslSource = new StreamSource(xslUri);
      //将Xsl以流文件方式放入对象中
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Templates translet = tFactory.newTemplates(xslSource);
      //将双方写入事务工厂
      Writer outfile = new StringWriter();
      StreamResult result = new StreamResult(outfile);
      //确定输出流为字符串
      Transformer transformer = translet.newTransformer();
      transformer.transform(xmlSource, result);
      //开始合并,并且输出到outfile字符串返回
      return outfile.toString();
    }
    catch (TransformerException e) {
      throw new JDOMException("XSLT创建事务失败!", e);
    }
  }


--  作者:xiongbajian
--  发布时间:1/20/2006 8:06:00 PM

--  
谢楼上
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
148.438ms