java.io.IOException:服务器返回 HTTP 响应代码:503 对于 URL:http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

发布于 2024-08-26 06:19:05 字数 1101 浏览 3 评论 0原文

在下面的代码中:

private Document transformDoc(Source source) throws TransformerException, IOException {
    TransformerFactory factory = TransformerFactory.newInstance();

    Transformer transformer =
            factory.newTransformer(new StreamSource(xsltResource.getInputStream()));
    JDOMResult result = new JDOMResult();
    transformer.transform(source, result);
    return result.getDocument();
}

我得到这个异常:

java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

我通过 xsl 翻译的 XHTML 是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  <title>Terms and Conditions</title>
</head>
<body>
  <div>Test Content</div>
</body>
</html>

如何阻止 xalan 变压器打电话回家?

In the following code:

private Document transformDoc(Source source) throws TransformerException, IOException {
    TransformerFactory factory = TransformerFactory.newInstance();

    Transformer transformer =
            factory.newTransformer(new StreamSource(xsltResource.getInputStream()));
    JDOMResult result = new JDOMResult();
    transformer.transform(source, result);
    return result.getDocument();
}

I get this exception:

java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

The XHTML I'm translating over via xsl is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  <title>Terms and Conditions</title>
</head>
<body>
  <div>Test Content</div>
</body>
</html>

How do I stop the xalan transformer from phoning home?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

有深☉意 2024-09-02 06:19:05

禁用解析器中的 DTD 解析(特定于解析器)或设置一个空实体解析器。

复制自 http://www.jdom.org/docs/faq.html#a0350< /a>:

public class NoOpEntityResolver implements EntityResolver {
  public InputSource resolveEntity(String publicId, String systemId) {
    return new InputSource(new StringBufferInputStream(""));
  }
}

// Then in the builder...

builder.setEntityResolver(new NoOpEntityResolver());

Either disable DTD resolving in the parser (parser-specific) or set an empty entity resolver.

Copied from http://www.jdom.org/docs/faq.html#a0350:

public class NoOpEntityResolver implements EntityResolver {
  public InputSource resolveEntity(String publicId, String systemId) {
    return new InputSource(new StringBufferInputStream(""));
  }
}

// Then in the builder...

builder.setEntityResolver(new NoOpEntityResolver());
剧终人散尽 2024-09-02 06:19:05

来自 Xalan-J 邮件列表的这篇文章 建议您“正确的方法”是配置底层 Source/Reader 自己禁用验证。

This post from the Xalan-J mailing list suggests that "the right way" is for you to configure the underlying Source/Reader yourself to disable validation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文