使用天通苑XSL-FO XSLT的节点集。

问题描述 投票:0回答:1

我想在天通苑中使用node-set(),这样我就可以在排序列表中访问前面的兄弟姐妹。(我试图按照这个例子来做。[使用xsl:sort的先导同位素。)

我不知道声明要访问的命名空间的语法是什么。node-set(). AH没有给出任何错误,但我打电话给 node-set() 失败。我已经试过了。

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl" version="1.0">

这里是XML

<illustratedPartsCatalog>
        <figure id="fig1">...</figure>
        <catalogSeqNumber assyCode="00" figureNumber="01" indenture="0" item="000" itemVariant="A" subSubSystemCode="0" subSystemCode="0" systemCode="00">
<itemSeqNumber itemSeqNumberValue="000">
<quantityPerNextHigherAssy>XX</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="00000" partNumberValue="11111-111">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>VALVE ASSEMBLY</descrForPart></itemIdentData>
</partSegment><applicabilitySegment><usableOnCodeAssy>X</usableOnCodeAssy>
</applicabilitySegment></itemSeqNumber></catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <figure id="fig2">...</figure>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
        <catalogSeqNumber>...</catalogSeqNumber>
    </illustratedPartsCatalog>

XSLT:

    <xsl:variable name="sortedCSN">
            <xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
                <xsl:sort select="concat(itemSeqNumber/partRef/@partNumberValue, @figureNumber,@item)"/>
                <xsl:copy-of select="." />
            </xsl:for-each>
  </xsl:variable>

    <xsl:template name="SortParts2" >
            <xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
                <xsl:sort select="concat(itemSeqNumber/partRef/@partNumberValue, @figureNumber,@item)"/>
                <xsl:call-template name="catalogSeqNumber-NI">
                    <xsl:with-param name="figNo" select="concat(@figureNumber,@figureNumberVariant)"/>
                    <xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/@figureNumber,preceding-sibling::catalogSeqNumber/@figureNumberVariant)" />
                </xsl:call-template>
            </xsl:for-each>
        </xsl:template>

    <xsl:template name="catalogSeqNumber-NI">
        <xsl:param name="figNo"/>
        <xsl:param name="prfigNo" />        
            <fo:table-row keep-together.within-page="always" wrap-option="wrap">
                <fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-transform="uppercase" wrap-option="wrap">
                    <fo:block wrap-option="wrap">
                        <xsl:value-of select=" ./itemSeqNumber/partRef/@partNumberValue"/>
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell  xsl:use-attribute-sets="table.cell.padding" text-align="start">
                    <xsl:choose>
                        <xsl:when test="$figNo">
                            <fo:block>
                                <xsl:text> </xsl:text><xsl:value-of select="$figNo"/><xsl:text> </xsl:text> <xsl:value-of select="$prfigNo"/>
                            </fo:block>
                        </xsl:when>
                        <xsl:otherwise>
                                <fo:block />
                        </xsl:otherwise>
                    </xsl:choose>
                </fo:table-cell>

                <fo:table-cell  xsl:use-attribute-sets="table.cell.padding" text-align="start">
                    <fo:block>
                        <xsl:if test="./itemSeqNumber/partLocationSegment/notIllustrated">
                            <xsl:text>-</xsl:text>
                        </xsl:if>

                        <xsl:choose>
                            <xsl:when test="@item">
                                <xsl:variable name="itemNo">
                                    <xsl:call-template name="suppressZero" >
                                        <xsl:with-param name="pText" select="@item"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:value-of select="concat($itemNo,@itemVariant)"/>
                            </xsl:when>
                            <xsl:otherwise />
                        </xsl:choose>
                    </fo:block>
                </fo:table-cell>

                <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
                    <fo:block>
                        <xsl:value-of select="./itemSeqNumber/quantityPerNextHigherAssy"/>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </xsl:template>
xslt xsl-fo node-set antenna-house
1个回答
1
投票

我想Windows上的天通苑默认使用MSXML,所以尝试使用 xmlns:msxsl="urn:schemas-microsoft-com:xslt" 是可以的,至于使用 node-set 扩展函数。

我想你只需要将XSLT改为

    <xsl:variable name="sortedCSN">
            <xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
                <xsl:sort select="concat(itemSeqNumber/partRef/@partNumberValue, @figureNumber,@item)"/>
                <xsl:copy-of select="." />
            </xsl:for-each>
  </xsl:variable>

<xsl:template name="SortParts2" >
        <xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
            <xsl:sort select="concat(itemSeqNumber/partRef/@partNumberValue, @figureNumber,@item)"/>
            <xsl:call-template name="catalogSeqNumber-NI">
                <xsl:with-param name="figNo" select="concat(@figureNumber,@figureNumberVariant)"/>
                <xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/@figureNumber,preceding-sibling::catalogSeqNumber/@figureNumberVariant)" />
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>

以使你所显示的输入有意义(就你所显示的,无法判断所有这些。xsl:sort 尝试,而没有看到要排序的数据).另一方面,如果你得到的错误是关于样式表不正确的XSLT或XML,你最好向我们展示一个最小但完整的样式表,让我们重现问题。

另一方面,如果你得到关于样式表不正确的XSLT或XML的错误,你最好向我们展示一个最小但完整的样式表,允许我们重现问题。

© www.soinside.com 2019 - 2024. All rights reserved.