天线屋 XSL-FO 扩展无法工作?

发布于 2024-09-30 04:29:57 字数 1125 浏览 5 评论 0 原文

任何通过指向 Antenna House 的 xsl-fo 扩展名的命名空间(这会给出“页面未找到”)的尝试都会导致错误:

命名空间“http://www.w3.org/1999/XSL/Format”中的元素“root”在命名空间“http://www.antennahouse.com/names”中具有无效的子元素“document-info” /XSL/扩展'。预期可能的元素列表:命名空间“http://www.w3.org/1999/XSL/Format”中的“layout-master-set”。

似乎存在某种类型的命名空间引用问题,其中 xsl-fo 命名空间中的元素无法识别扩展元素是有效的子元素?

代码如下所示:

<xsl:stylesheet version='1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
     xmlns:axf='http://www.antennahouse.com/names/XSL/Extensions'>
    <xsl:template match='/root'>
        <fo:root xmlns:fo='http://www.w3.org/1999/XSL/Format' xmlns:axf='http://www.antennahouse.com/names/XSL/Extensions'>
            <axf:document-info name='title' value='value' />
        </fo:root>
    </xsl:template>
</xsl:stylesheet>

有趣的是,他们在其网站上列出了一个示例,看起来与此处完全相同:http://www.antennahouse.com/xslfo/axf4-extension.htm#axf.document-info

不幸的是,它似乎不适用于他们的 xsl v4.3格式化程序。

Any attempt to use Antenna House's xsl-fo extensions by pointing to their namespace (which gives a "page not found" btw) results in an error:

The element 'root' in namespace 'http://www.w3.org/1999/XSL/Format' has invalid child element 'document-info' in namespace 'http://www.antennahouse.com/names/XSL/Extensions'. List of possible elements expected: 'layout-master-set' in namespace 'http://www.w3.org/1999/XSL/Format'.

It appears that there's some type of namespace referencing issue where the elements in the xsl-fo namespace don't recognize that the extension elements are valid child elements?

Code looks like such:

<xsl:stylesheet version='1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
     xmlns:axf='http://www.antennahouse.com/names/XSL/Extensions'>
    <xsl:template match='/root'>
        <fo:root xmlns:fo='http://www.w3.org/1999/XSL/Format' xmlns:axf='http://www.antennahouse.com/names/XSL/Extensions'>
            <axf:document-info name='title' value='value' />
        </fo:root>
    </xsl:template>
</xsl:stylesheet>

Funny that they have an example listed on their website that looks exactly the same here: http://www.antennahouse.com/xslfo/axf4-extension.htm#axf.document-info

Unfortunately it doesn't seem to be working with v4.3 of their xsl formatter.

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

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

发布评论

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

评论(3

回眸一笑 2024-10-07 04:29:57

我认为问题可能是 xsl-fo 不完整。错误是在将 XML 转换为 XSL-FO 时发生还是在处理 XSL-FO 时发生?

另外,我认为您不需要将命名空间添加到 fo:root 元素(如果它们位于 xsl:stylsheet 中)。但这可能是 XSL 处理器特有的。 (我正在使用 Saxon。)

我没有任何使用 Antenna House 的经验,但我使用具有类似扩展的 RenderX。

下面是 XML 文件、XSL 样式表和生成的 XSL-FO 的示例。 (这在 RenderX 中工作得很好。)

XML 文件

<?xml version="1.0" encoding="UTF-8"?>
<root/>

XSL 样式表

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/root">
    <fo:root>
      <rx:meta-info>
        <rx:meta-field name="title" value="Some Title"/>
        <rx:meta-field name="author" value="DevNull"/>
        <rx:meta-field name="subject" value="Some Subject"/>
        <rx:meta-field name="keywords" value="abc def ghi jkl"/>
      </rx:meta-info>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
          <fo:block/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

</xsl:stylesheet>

XSL-FO 输出

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
         xmlns:rx="http://www.renderx.com/XSL/Extensions">
   <rx:meta-info>
      <rx:meta-field name="title" value="Some Title"/>
      <rx:meta-field name="author" value="DevNull"/>
      <rx:meta-field name="subject" value="Some Subject"/>
      <rx:meta-field name="keywords" value="abc def ghi jkl"/>
   </rx:meta-info>
   <fo:layout-master-set>
      <fo:simple-page-master master-name="my-page">
         <fo:region-body/>
      </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="my-page">
      <fo:flow flow-name="xsl-region-body">
         <fo:block/>
      </fo:flow>
   </fo:page-sequence>
</fo:root>

我想如果你交换 renderx 扩展 (rx :) 对于天线室扩展,它应该可以工作。也许您应该先尝试渲染 XSL-FO,然后再尝试使用 XSL-T 生成 XSL-FO。

希望这有帮助。

I think that the issue might be that the xsl-fo is not complete. Does the error occur when transforming the XML to XSL-FO or does it occur when processing the XSL-FO?

Also, I don't think you need to add the namespaces to the fo:root element if they're in xsl:stylsheet. This might be specific to the XSL processor though. (I'm using Saxon.)

I don't have any experience with Antenna House, but I use RenderX that has similar extensions.

Here's an example of an XML file, XSL stylesheet, and the resulting XSL-FO. (Which works fine in RenderX.)

XML File

<?xml version="1.0" encoding="UTF-8"?>
<root/>

XSL stylesheet

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/root">
    <fo:root>
      <rx:meta-info>
        <rx:meta-field name="title" value="Some Title"/>
        <rx:meta-field name="author" value="DevNull"/>
        <rx:meta-field name="subject" value="Some Subject"/>
        <rx:meta-field name="keywords" value="abc def ghi jkl"/>
      </rx:meta-info>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
          <fo:block/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

</xsl:stylesheet>

XSL-FO output

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
         xmlns:rx="http://www.renderx.com/XSL/Extensions">
   <rx:meta-info>
      <rx:meta-field name="title" value="Some Title"/>
      <rx:meta-field name="author" value="DevNull"/>
      <rx:meta-field name="subject" value="Some Subject"/>
      <rx:meta-field name="keywords" value="abc def ghi jkl"/>
   </rx:meta-info>
   <fo:layout-master-set>
      <fo:simple-page-master master-name="my-page">
         <fo:region-body/>
      </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="my-page">
      <fo:flow flow-name="xsl-region-body">
         <fo:block/>
      </fo:flow>
   </fo:page-sequence>
</fo:root>

I think if you swap the renderx extensions (rx:) for the antenna house extensions, it should work. Maybe you should try rendering the XSL-FO first before trying to generate the XSL-FO using XSL-T.

Hope this helps.

孤独岁月 2024-10-07 04:29:57

这是我的错。有一个我不知道的 xsd 架构文件。我们最终不得不在根节点和块节点中使用“任意”元素,以获得访问天线室扩展的模板。

<xs:element name="root">
  <xs:complexType>
    <xs:sequence>
      <xs:any namespace="http://www.antennahouse.com/names/XSL/Extensions" processContents="skip"/>
...

<xs:element name="block">
  <xs:complexType mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:any namespace="http://www.antennahouse.com/names/XSL/Extensions" processContents="skip"/>
...

This was my fault. There was an xsd schema file that I wasn't aware of. We ended up having to use the "any" element in the root and block nodes in order to get the template to access the antennahouse extentions.

<xs:element name="root">
  <xs:complexType>
    <xs:sequence>
      <xs:any namespace="http://www.antennahouse.com/names/XSL/Extensions" processContents="skip"/>
...

<xs:element name="block">
  <xs:complexType mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:any namespace="http://www.antennahouse.com/names/XSL/Extensions" processContents="skip"/>
...
以酷 2024-10-07 04:29:57

focheck (https://github.com/AntennaHouse/focheck) 版本包括用于 XSL 1.1 的 W3C XSD 以及 Antenna House 扩展。

focheck (https://github.com/AntennaHouse/focheck) releases include a W3C XSD for XSL 1.1 plus Antenna House extensions.

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