使用 xslt 过滤器从 Calc 导出时出现 OpenOffice 错误

发布于 2024-11-04 05:58:59 字数 978 浏览 4 评论 0原文

我在 Calc 中有一个基于行的数据,我想使用 xslt 过滤器将其导出到 xml。除非两个相邻列中的值相同,否则过滤器正常工作。例如,参见下面的数据...

SrNo      Col2      Col3      Col4      Col5
1         PQR       123       567       LMN
2         OPQ       665       786       BCD
3         EUR       443       443       UFF
4         OLE       345       887       JAS
5         EJR       565       565       OEP

对于上面的数据,此错误仅发生在第 3 行和第 5 行。由于某种原因,过滤器会跳过 col4 并从 col5 中获取值。对于其余数据,导出效果非常好。这是 xslt 代码...

<row>
<col1><xsl:value-of select="table:table-cell[1]"/></col1>
<col2><xsl:value-of select="table:table-cell[2]"/></col2>
<col3><xsl:value-of select="table:table-cell[3]"/></col3>
<col4><xsl:value-of select="table:table-cell[4]"/></col4>
<col5><xsl:value-of select="table:table-cell[5]"/></col5>
</row>

有人可以对此提供任何意见吗?这很奇怪,因此我陷入了困境。顺便说一句,我正在使用 OpenOffice 3.1.1(Build 9420)和 xslt 2.0。

I have a row-based data in Calc which I want to export to xml using xslt filters. The filters work properly except when values in two adjacent columns are the same. For example, see the data below ...

SrNo      Col2      Col3      Col4      Col5
1         PQR       123       567       LMN
2         OPQ       665       786       BCD
3         EUR       443       443       UFF
4         OLE       345       887       JAS
5         EJR       565       565       OEP

For the above data, this error occurs only for lines 3 and 5. For some reason, the filter skips col4 and takes the value from col5. For rest of the data the export works perfectly fine. Here is the xslt code ...

<row>
<col1><xsl:value-of select="table:table-cell[1]"/></col1>
<col2><xsl:value-of select="table:table-cell[2]"/></col2>
<col3><xsl:value-of select="table:table-cell[3]"/></col3>
<col4><xsl:value-of select="table:table-cell[4]"/></col4>
<col5><xsl:value-of select="table:table-cell[5]"/></col5>
</row>

Can someone please give any inputs on this ? It's pretty weird and I am badly stuck up due to this. Btw, I am using OpenOffice 3.1.1 (Build 9420) with xslt 2.0.

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

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

发布评论

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

评论(3

场罚期间 2024-11-11 05:58:59

这是伟大的代码罗希特;它确实帮助我走向了正确的方向。我很难让 XSLT 2.0 代码在我的 LibreOffice 安装中工作,因此我将代码转换为使用 XSLT 1.0(命名模板而不是函数调用,以及能够将节点传递到递归函数中的扩展)。如果有人需要它,我的代码如下。请注意,它不是通用代码 - 您需要将我的字段替换为您自己的字段。

此特定示例将电子表格导出到 XCode 可以识别的有效 .plist 文件中。它已经在 Vista 上运行的 LibreOffice 3.5 上进行了测试。

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:xt="http://www.jclark.com/xt"
    extension-element-prefixes="xt"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    exclude-result-prefixes="office table text">

    <!--xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no"/-->
    <xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no" doctype-system = "http://www.apple.com/DTDs/PropertyList-1.0.dtd" doctype-public = "-//Apple//DTD PLIST 1.0//EN" />

    <xsl:template name="getColumnValue">
        <xsl:param name="tableRow"/>
        <xsl:param name="colIndex"/>
        <xsl:param name="currentIndex"/>
        <xsl:choose>
            <xsl:when test="$currentIndex < $colIndex">
                <xsl:variable name="repeatColumns" select="xt:node-set($tableRow)/table:table-cell[$currentIndex]/@table:number-columns-repeated"/>
                <xsl:choose>
                    <xsl:when test="$repeatColumns">
                        <xsl:choose>
                            <xsl:when test="$currentIndex + $repeatColumns - 1 >= $colIndex">
                                <xsl:value-of select="xt:node-set($tableRow)/table:table-cell[$currentIndex]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:variable name = "recursiveResult">
                                    <xsl:call-template name="getColumnValue">
                                        <xsl:with-param name="tableRow" select="$tableRow"/>
                                        <xsl:with-param name="colIndex" select="$colIndex - $repeatColumns + 1"/>
                                        <xsl:with-param name="currentIndex" select="$currentIndex + 1"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:value-of select="$recursiveResult"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:variable name = "recursiveResult">
                            <xsl:call-template name="getColumnValue">
                                <xsl:with-param name="tableRow" select="$tableRow"/>
                                <xsl:with-param name="colIndex" select="$colIndex"/>
                                <xsl:with-param name="currentIndex" select="$currentIndex + 1"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:value-of select="$recursiveResult"/>

                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="xt:node-set($tableRow)/table:table-cell[$colIndex]"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- By setting the PropertyValue "URL" in the properties used in storeToURL(), -->
    <!-- we can pass a single parameter to this stylesheet.                         -->
    <!-- Caveat: If we use the "URL" property in the stylesheet and call in OOo     -->
    <!-- from the menu "File" > "Export...", OOo assigns a target URL. And that     -->
    <!-- might not be what we want.                                                 -->
    <xsl:param name="targetURL"/>

    <xsl:variable name="exportDate">
        <xsl:choose>
            <xsl:when test="string-length(substring-before($targetURL,';'))=10">
                <xsl:value-of select="substring-before($targetURL,';')"/>
            </xsl:when>
            <xsl:when test="string-length($targetURL)=10">
                <xsl:value-of select="$targetURL"/>
            </xsl:when>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="exportUser">
        <xsl:if test="string-length(substring-after($targetURL,';'))>0">
            <xsl:value-of select="substring-after($targetURL,';')"/>
        </xsl:if>
    </xsl:variable>

    <xsl:template match="/">
        <plist version="1.0">
            <dict>
                <key>Animations</key>
                <array>
                    <!-- Process all tables -->
                    <xsl:apply-templates select="//table:table"/>
                </array>
            </dict>
        </plist>
    </xsl:template>


    <xsl:template match="table:table">
        <!-- Process all table-rows after the column labels in table-row 1 -->
        <xsl:for-each select="table:table-row">
            <xsl:if test="position()>1">
                <dict>
                    <key>character</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="1"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>animation</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="2"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>cycle</key>
                    <xsl:variable name="cycleTmp">
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="3"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </xsl:variable>
                    <xsl:if test="$cycleTmp > 0">
                        <true/>
                    </xsl:if>
                    <xsl:if test="$cycleTmp = 0">
                        <false/>
                    </xsl:if>

                    <key>frames</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="4"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>randomSpeedPercent</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="5"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>spriteNameRoot</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="6"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>spriteSheetName</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="7"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>anchorX</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="11"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>anchorY</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="12"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                </dict>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

That was great code Rohit; it definitely helped send me in the right direction. I was having a hard time getting the XSLT 2.0 code working in my LibreOffice installation, so I converted the code to use XSLT 1.0 (named templates instead of functions calls, and an extension to be able to pass a node into the recursive function). In case someone needs it, my code is below. Note that it is not general purpose code - you will need to replace my fields with your own.

This particular example exports a spreadsheet into a valid .plist file that is recognized by XCode. It has been tested with LibreOffice 3.5 running on Vista.

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:xt="http://www.jclark.com/xt"
    extension-element-prefixes="xt"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    exclude-result-prefixes="office table text">

    <!--xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no"/-->
    <xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no" doctype-system = "http://www.apple.com/DTDs/PropertyList-1.0.dtd" doctype-public = "-//Apple//DTD PLIST 1.0//EN" />

    <xsl:template name="getColumnValue">
        <xsl:param name="tableRow"/>
        <xsl:param name="colIndex"/>
        <xsl:param name="currentIndex"/>
        <xsl:choose>
            <xsl:when test="$currentIndex < $colIndex">
                <xsl:variable name="repeatColumns" select="xt:node-set($tableRow)/table:table-cell[$currentIndex]/@table:number-columns-repeated"/>
                <xsl:choose>
                    <xsl:when test="$repeatColumns">
                        <xsl:choose>
                            <xsl:when test="$currentIndex + $repeatColumns - 1 >= $colIndex">
                                <xsl:value-of select="xt:node-set($tableRow)/table:table-cell[$currentIndex]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:variable name = "recursiveResult">
                                    <xsl:call-template name="getColumnValue">
                                        <xsl:with-param name="tableRow" select="$tableRow"/>
                                        <xsl:with-param name="colIndex" select="$colIndex - $repeatColumns + 1"/>
                                        <xsl:with-param name="currentIndex" select="$currentIndex + 1"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:value-of select="$recursiveResult"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:variable name = "recursiveResult">
                            <xsl:call-template name="getColumnValue">
                                <xsl:with-param name="tableRow" select="$tableRow"/>
                                <xsl:with-param name="colIndex" select="$colIndex"/>
                                <xsl:with-param name="currentIndex" select="$currentIndex + 1"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:value-of select="$recursiveResult"/>

                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="xt:node-set($tableRow)/table:table-cell[$colIndex]"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- By setting the PropertyValue "URL" in the properties used in storeToURL(), -->
    <!-- we can pass a single parameter to this stylesheet.                         -->
    <!-- Caveat: If we use the "URL" property in the stylesheet and call in OOo     -->
    <!-- from the menu "File" > "Export...", OOo assigns a target URL. And that     -->
    <!-- might not be what we want.                                                 -->
    <xsl:param name="targetURL"/>

    <xsl:variable name="exportDate">
        <xsl:choose>
            <xsl:when test="string-length(substring-before($targetURL,';'))=10">
                <xsl:value-of select="substring-before($targetURL,';')"/>
            </xsl:when>
            <xsl:when test="string-length($targetURL)=10">
                <xsl:value-of select="$targetURL"/>
            </xsl:when>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="exportUser">
        <xsl:if test="string-length(substring-after($targetURL,';'))>0">
            <xsl:value-of select="substring-after($targetURL,';')"/>
        </xsl:if>
    </xsl:variable>

    <xsl:template match="/">
        <plist version="1.0">
            <dict>
                <key>Animations</key>
                <array>
                    <!-- Process all tables -->
                    <xsl:apply-templates select="//table:table"/>
                </array>
            </dict>
        </plist>
    </xsl:template>


    <xsl:template match="table:table">
        <!-- Process all table-rows after the column labels in table-row 1 -->
        <xsl:for-each select="table:table-row">
            <xsl:if test="position()>1">
                <dict>
                    <key>character</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="1"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>animation</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="2"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>cycle</key>
                    <xsl:variable name="cycleTmp">
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="3"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </xsl:variable>
                    <xsl:if test="$cycleTmp > 0">
                        <true/>
                    </xsl:if>
                    <xsl:if test="$cycleTmp = 0">
                        <false/>
                    </xsl:if>

                    <key>frames</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="4"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>randomSpeedPercent</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="5"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>spriteNameRoot</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="6"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>spriteSheetName</key>
                    <string>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="7"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </string>

                    <key>anchorX</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="11"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                    <key>anchorY</key>
                    <integer>
                        <xsl:call-template name="getColumnValue"> <xsl:with-param name="colIndex" select="12"/> <xsl:with-param name="currentIndex" select="1"/> <xsl:with-param name="tableRow" select="."/> </xsl:call-template>
                    </integer>

                </dict>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>
感悟人生的甜 2024-11-11 05:58:59

该问题是由于工作表基础数据结构中的 table:table-cell 元素的 number-columns-repeated 属性造成的。欲了解更多详情,请参阅http:// user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=29674http://user.services.openoffice.org/en /forum/viewtopic.php?f=9&t=11865

尽管后一个链接声称已经解决了问题,但该解决方案并不完全是我想要的。我需要一个简单的基于索引的解决方案,它允许更灵活的 xml 生成。这是我试图解决的问题。

我使用 xslt 2.0 来利用用户定义的函数。这是样式表...

<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="no"/>

<xsl:function name="my:getColumnValue">
    <xsl:param name="tableRow" as="node()"/>
    <xsl:param name="colIndex"/>
    <xsl:param name="currentIndex"/>
    <xsl:choose>
        <xsl:when test="$currentIndex < $colIndex">
            <xsl:variable name="repeatColumns" select="$tableRow/table:table-cell[$currentIndex]/@table:number-columns-repeated"/>
            <xsl:choose>
                <xsl:when test="$repeatColumns">
                    <xsl:choose>
                        <xsl:when test="$currentIndex + $repeatColumns - 1 >= $colIndex"><xsl:value-of select="$tableRow/table:table-cell[$currentIndex]"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex - $repeatColumns + 1, $currentIndex + 1)"/></xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex, $currentIndex + 1)"/></xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:otherwise><xsl:value-of select="$tableRow/table:table-cell[$colIndex]"/></xsl:otherwise>
    </xsl:choose>
</xsl:function>

<xsl:template match="//table:table">
    <Tests>
        <!-- Process all table rows -->
        <xsl:variable name="colCount" select="count(table:table-row[1]/table:table-cell)"/>
        <xsl:for-each select="table:table-row">
            <xsl:if test="position() > 1">
            <Test>
                <SrNo><xsl:value-of select="my:getColumnValue(.,1,1)"/></SrNo>
                <Name><xsl:value-of select="my:getColumnValue(.,2,1)"/></Name>
                <Age><xsl:value-of select="my:getColumnValue(.,3,1)"/></Age>
                <Height><xsl:value-of select="my:getColumnValue(.,4,1)"/></Height>
                <Address><xsl:value-of select="my:getColumnValue(.,5,1)"/></Address>
            </Test>
            </xsl:if>
        </xsl:for-each>
    </Tests>
</xsl:template>

上面使用的标签只是占位符。请将它们替换为您的 xslt 中适当的内容。此解决方案受到 xslt 处理器允许的递归调用数量的限制。

如果xslt 1.0支持将节点作为参数发送,那么我们可以尝试替换上面的udf以获得基于模板的解决方案。如果您发现任何错误,请告诉我。

The issue is due to number-columns-repeated attribute to table:table-cell element in the sheet's underlying data structure. For more details, please refer to http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=29674 and http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=11865.

Though the latter link claims to have resolved the issue, the solution is not quite what I was looking for. I required a simple index-based solution which allows a more flexible xml generation. Here is what I tried to work out.

I have used xslt 2.0 to make use of user defined functions. Here is the stylesheet ...

<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="no"/>

<xsl:function name="my:getColumnValue">
    <xsl:param name="tableRow" as="node()"/>
    <xsl:param name="colIndex"/>
    <xsl:param name="currentIndex"/>
    <xsl:choose>
        <xsl:when test="$currentIndex < $colIndex">
            <xsl:variable name="repeatColumns" select="$tableRow/table:table-cell[$currentIndex]/@table:number-columns-repeated"/>
            <xsl:choose>
                <xsl:when test="$repeatColumns">
                    <xsl:choose>
                        <xsl:when test="$currentIndex + $repeatColumns - 1 >= $colIndex"><xsl:value-of select="$tableRow/table:table-cell[$currentIndex]"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex - $repeatColumns + 1, $currentIndex + 1)"/></xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex, $currentIndex + 1)"/></xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:otherwise><xsl:value-of select="$tableRow/table:table-cell[$colIndex]"/></xsl:otherwise>
    </xsl:choose>
</xsl:function>

<xsl:template match="//table:table">
    <Tests>
        <!-- Process all table rows -->
        <xsl:variable name="colCount" select="count(table:table-row[1]/table:table-cell)"/>
        <xsl:for-each select="table:table-row">
            <xsl:if test="position() > 1">
            <Test>
                <SrNo><xsl:value-of select="my:getColumnValue(.,1,1)"/></SrNo>
                <Name><xsl:value-of select="my:getColumnValue(.,2,1)"/></Name>
                <Age><xsl:value-of select="my:getColumnValue(.,3,1)"/></Age>
                <Height><xsl:value-of select="my:getColumnValue(.,4,1)"/></Height>
                <Address><xsl:value-of select="my:getColumnValue(.,5,1)"/></Address>
            </Test>
            </xsl:if>
        </xsl:for-each>
    </Tests>
</xsl:template>

The tags used above are just placeholders. Please replace them with appropriate ones in your xslt. This solution is limited by number of recursive calls allowed by the xslt processor.

If xslt 1.0 supports sending node as params, then we can try to replace the above udf to get a template based solution. If you find any bugs, do let me know.

忘羡 2024-11-11 05:58:59

马塞尔的解决方案看起来很复杂,但效果很完美,而且适应起来并不复杂。

所以,再次向大家简述一下:
您基本上将整个模板复制并粘贴到您的 xsl 中:

<xsl:template name="getColumnValue"> ... </>

然后,将所有标准表:行(失败)替换为

<xsl:call-template name="getColumnValue"> 
    <xsl:with-param name="colIndex" select="1"/> 
    <xsl:with-param name="currentIndex" select="1"/> 
    <xsl:with-param name="tableRow" select="."/> 
</xsl:call-template>

确保调整“colIndex”值,但将 currentIndex 保留为 1!
最后,将标题的 xt 行添加到您的标题中。

xmlns:xt="http://www.jclark.com/xt"
extension-element-prefixes="xt"

完美,马塞尔!

Marcel's solution looks complicated, but works perfect and is not so complicated to adapt.

So, again in short for everybody:
You basically copy&paste the whole template into your xsl:

<xsl:template name="getColumnValue"> ... </>

Then, replace all the standard table:row (which is failing) with

<xsl:call-template name="getColumnValue"> 
    <xsl:with-param name="colIndex" select="1"/> 
    <xsl:with-param name="currentIndex" select="1"/> 
    <xsl:with-param name="tableRow" select="."/> 
</xsl:call-template>

Be sure to adjust the "colIndex" values, but leave the currentIndex on 1!
Finally, add the xt lines of the header to yours.

xmlns:xt="http://www.jclark.com/xt"
extension-element-prefixes="xt"

Perfect, Marcel!

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