XML(XSL)错误 - 将HTML转换为PDF(Java)

时间:2023-01-14 08:53:52

I am nearly finished with a program to convert HTML to a PDF format. My issue is more specific than this program though. I have an XSL file that is giving me some grief when I try to use it with my program.

我差不多完成了将HTML转换为PDF格式的程序。我的问题比这个程序更具体。我有一个XSL文件,当我尝试将它与我的程序一起使用时,它给了我一些悲伤。

When using javax.xml.transform.Transformer.transform(source, result) I am getting the following warning and error messages due to my XSL styleSheet:

使用javax.xml.transform.Transformer.transform(source,result)时,由于我的XSL styleSheet,我收到以下警告和错误消息:

Compiler Warnings: Attribute 'leader-length' outside of element.
ERROR: 'Error(Unknown location): fo:list-item is not a valid child element of fo:block.'

编译器警告:元素外的属性“leader-length”。错误:'错误(未知位置):fo:list-item不是fo:block的有效子元素。

The XSL file in question can be found here: http://webcoder.info/downloads/xhtml2fo.html

有问题的XSL文件可以在这里找到:http://webcoder.info/downloads/xhtml2fo.html

It is recommended by this tutorial: https://blogs.oracle.com/chrisf/entry/converting_html_to_pdf_using

本教程推荐使用:https://blogs.oracle.com/chrisf/entry/converting_html_to_pdf_using

Any assistance with what/where these error messages are coming from would be of great help! I am totally unfamiliar with XSL files.

任何有关这些错误消息来自何处/何处的帮助都会有很大帮助!我对XSL文件完全不熟悉。

Thank you so much.

非常感谢。

EDIT: I suppose it is possible that something else is at fault. Using other XSL files, I get: "Document is empty (Something might be wrong with your XSLT stylesheet)" However, I am following the Oracle tutorial pretty much to the letter. Does he have a bug in his code? (Within the link above.)

编辑:我想有可能是别的东西有问题。使用其他XSL文件,我得到:“文档是空的(XSLT样式表可能有问题)”但是,我正在遵循Oracle教程。他的代码中有错误吗? (在上面的链接中。)

EDIT2: I should have posted this in the first place: http://webcoder.info/downloads/xhtml2fo.xsl

EDIT2:我应该首先发布这个:http://webcoder.info/downloads/xhtml2fo.xsl

If that link isn't working, I'll paste in the exact code here. Thanks!

如果该链接不起作用,我将在此处粘贴确切的代码。谢谢!

EDIT3: This is some of the HTML I am trying to use as an example: http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/classpath.html

EDIT3:这是我尝试使用的一些HTML示例:http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/classpath.html

1 个解决方案

#1


1  

On the line before <fo:leader ... /> should not have that slash /.

之前的行上不应该有斜杠/。

#1


1  

On the line before <fo:leader ... /> should not have that slash /.

之前的行上不应该有斜杠/。