0

I would like to use node-set() in Antenna House so I can access preceding-siblings in a sorted list. (I'm trying to follow this example: [using preceding-sibling with with xsl:sort)

I'm not sure what the syntax is for declaring the namespace to access node-set(). AH is not giving any errors, but my call to node-set() fails. I've tried:

<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">

Here is the 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>
Tony Graham
  • 7,306
  • 13
  • 20
Caroline
  • 167
  • 1
  • 11
  • Could you show the entire XSLT as a single stylesheet? What processor do you perform the transformation with (Java with default/Xalan, Saxon, .NET) and what's the exact error message? – G_H Apr 24 '17 at 16:24
  • There is no `axf:node-set()` function. When trying to use `axf:node-set()`, I would expect that you got an error message indicating that the function does not exist. – Tony Graham Apr 25 '17 at 07:36
  • The text error was caused by a stray text character that was outside the template. I'm using EditPad Pro and Antenna House 6.2 – Caroline Apr 25 '17 at 18:41

1 Answers1

1

I think the default for Antenna House on Windows is to use MSXML so the attempt with xmlns:msxsl="urn:schemas-microsoft-com:xslt" is fine as far as using the node-set extension function.

I think you simply need to change the XSLT to

    <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>

to make sense with the input you have shown (as far as you have shown it, can't judge all those xsl:sort attempts without seeing the data to be sorted).

On the other hand, if you get errors about the stylesheet not being correct XSLT or XML, you would better show us a minimal but complete stylesheet allowing us to reproduce the problem.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • Thank you, I tried your suggestion and SortParts2 is still failing. SortParts2 is being called from context node IllustratedPartsCatalog if that helps. – Caroline Apr 25 '17 at 20:23