2017-04-24 44 views
0

我想在天線屋中使用節點集(),所以我可以訪問排序列表中的前兄弟姐妹。 (我試圖按照這個例子:[using preceding-sibling with with xsl:sort使用節點集天線房XSL-FO XSLT

我不確定聲明命名空間訪問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> 
+0

您能否將整個XSLT顯示爲單個樣式表?你用什麼處理器執行轉換(具有默認/ Xalan,Saxon,.NET的Java)以及什麼是確切的錯誤信息? –

+0

沒有'axf:node-set()'函數。當試圖使用'axf:node-set()'時,我希望你得到一個錯誤消息,指出函數不存在。 –

+0

文本錯誤是由模板之外的零散文本字符引起的。我正在使用EditPad Pro和Antenna House 6.2 – Caroline

回答

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,那麼您最好向我們展示一個最小但完整的樣式表,它允許我們重現該問題。

+0

謝謝,我嘗試了您的建議,並且SortParts2仍然失敗。如果有幫助,SortParts2將從上下文節點IllustratedPartsCatalog調用。 – Caroline