Certain element for docbook table does not get written by stylesheet

时间秒杀一切 提交于 2019-12-25 02:29:26

问题


I'm currently using a XSLT stylesheet to transform an XML document into a docbook document. The document has to contain quite a few tables and some of them have pretty complex formatting. When writing docbook, I will usually format table cells by adding a description like

<?dbhtml bgcolor="#EEEEEE" ?>

and this usually works fine. However, I did not find a way to print this part of the document out from the transformation process.

Here is one of the templates:

<xsl:template match="//ns:chapter" priority="5">
    <sect1 xml:id="sec1.xyz">
        <title>Chapter tbd</title>
        <para>introduction</para>

        <table frame="all">
            <title>Table</title>
            <tgroup cols="2">
                <colspec colname="c1" colnum="1" colwidth="2*"/>
                <colspec colname="c2" colnum="2" colwidth="8*"/>
                <tbody>
                    <xsl:for-each select="//ns:myElement[not(@classID=preceding::ns:myElement/@classID)]">
                        <xsl:variable name="outerElement" select="."/>
                        <row>
                            <entry namest="c1" nameend="c2" align="center"><?dbhtml bgcolor="#EEEEEE" ?>Class 
                                <xsl:value-of select="current()/@classID"/>: 
                                <xsl:value-of select="current()/@classTitle"/>
                            </entry>
                        </row>
                        <xsl:for-each select="//ns:myElement[@classID=$outerElement/@classID]">
                            <row>
                                <entry>
                                    <xsl:value-of select="current()/@id"/>
                                </entry>
                                <entry>
                                    <xsl:value-of select="current()/@title"/>
                                </entry>
                            </row>
                        </xsl:for-each>
                    </xsl:for-each>
                </tbody>
            </tgroup>
        </table>
    </sect1>
</xsl:template>

The template works very well and prints out the table in docbook. However the part is simply ignored.

I somehow understand why this happens (obviously

Does anybody have any tip for me, how I can fix this?!

Thanks Norbert

Edit:
As a minimal, working example: Try to use the following stylesheet against any XML document that contains at least one element.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="*">
  <?dbhtml bgcolor="#EEEEEE" ?>
    </xsl:template>
</xsl:stylesheet>

回答1:


That is a processing instruction you can create with XSLT as <xsl:processing-instruction name="dbhtml">bgcolor="#EEEEEE"</xsl:processing-instruction>. See https://www.w3.org/TR/xslt-30/#creating-processing-instructions



来源:https://stackoverflow.com/questions/49578404/certain-element-for-docbook-table-does-not-get-written-by-stylesheet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!