2017-05-04 3 views
0

정렬 된 목록에서 선행 형제를 액세스하고 싶습니다. 저는 Antenna House 6.2와 XSLT 1.0을 사용하고 있습니다. node-set()과 함께 msxsl 확장명을 사용했지만 node-set()에 대한 호출에 실패했습니다. 어떤 사람들은 정렬 된 목록에서 선행 형제에 액세스하는 것이 1.0에서는 수행 될 수없고 다른 그룹에서는 Muenching Grouping을 언급하고 xsl:key을 사용하므로 지금 시도하고 있다고 말합니다. 이 페이지를 보았습니다 : http://www.jenitennison.com/xslt/grouping/muenchian.htmlxsl : 선행 형제가있는 정렬 XSLT 1.0 XSL-FO muenchian xsl : 키

테이블이 올바르게 정렬되었지만 키를 사용하여 정렬 된 목록의 이전 형제를 검색하는 방법을 알 수 없었습니다. 더 많은 키가 필요합니까? partNumberValue을 정렬하고 figureNumber을 정렬하고 figureNumberfigureNumberVariant 일 수 있습니다. 모든 제안을 부탁드립니다.

XML :

<illustratedPartsCatalog> 
      <figure id="fig1">...</figure> 
      <catalogSeqNumber assyCode="05" figureNumber="01" indenture="0" item="000" subSubSystemCode="1" subSystemCode="1" systemCode="15"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>AT</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="8910-276"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>GGACC AIR VALVE ASSEMBLY</descrForPart></itemIdentData> 
</partSegment><applicabilitySegment><usableOnCodeAssy>A</usableOnCodeAssy> 
</applicabilitySegment></itemSeqNumber></catalogSeqNumber> 
<catalogSeqNumber assyCode="05" figureNumber="01" indenture="0" item="001" itemVariant="A" subSubSystemCode="1" subSystemCode="2" systemCode="15"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>RF</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="8910-281"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>JJACC AIR VALVE ASSEMBLY</descrForPart></itemIdentData> 
</partSegment><applicabilitySegment><usableOnCodeAssy>B</usableOnCodeAssy> 
</applicabilitySegment></itemSeqNumber></catalogSeqNumber> 
<catalogSeqNumber assyCode="05" figureNumber="01" indenture="1" item="000" subSubSystemCode="1" subSystemCode="1" systemCode="1"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>1</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="2079-1302-1"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>NAMEPLATE COVER</descrForPart></itemIdentData> 
</partSegment> 
<partLocationSegment> 
<attachStoreShipPart attachStoreShipPartCode="1"/></partLocationSegment> 
</itemSeqNumber></catalogSeqNumber> 
      <figure id="fig2">...</figure> 
      <catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="030" subSubSystemCode="1" subSystemCode="2" systemCode="15"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>AR</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="63358"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>LOCK WIRE</descrForPart></itemIdentData></partSegment> 
</itemSeqNumber></catalogSeqNumber> 
<catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="040" subSubSystemCode="1" subSystemCode="2" systemCode="15"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>1</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="1476-3248-1"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>SHIELD</descrForPart></itemIdentData></partSegment> 
</itemSeqNumber></catalogSeqNumber> 
<catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="050" subSubSystemCode="1" subSystemCode="2" systemCode="15"> 
<itemSeqNumber itemSeqNumberValue="00A"> 
<quantityPerNextHigherAssy>2</quantityPerNextHigherAssy> 
<partRef manufacturerCodeValue="" partNumberValue="1025-129"> 
</partRef> 
<partSegment> 
<itemIdentData> 
<descrForPart>SCREW</descrForPart></itemIdentData></partSegment> 
<partLocationSegment> 
<attachStoreShipPart attachStoreShipPartCode="1"/></partLocationSegment> 
</itemSeqNumber></catalogSeqNumber> 
     </illustratedPartsCatalog> 

XSLT :

<xsl:key name="kfigNo" match="catalogSeqNumber" use="@figureNumber" /> 

    <xsl:template match="illustratedPartsCatalog"> 
     <xsl:apply-templates /> 
     <fo:table> 
      <fo:table-header> 
       <fo:table-row> 
        <fo:table-cell> 
         <fo:block>PART</fo:block> 
         <fo:block>NUMBER</fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block>FIG</fo:block> 
         <fo:block>NO.</fo:block> 
        </fo:table-cell> 
<fo:table-cell> 
         <fo:block>ITEM</fo:block> 
         <fo:block>NO.</fo:block> 
        </fo:table-cell> 
<fo:table-cell> 
               <fo:block>QTY.</fo:block> 
        </fo:table-cell> 

       </fo:table-row> 
      </fo:table-header> 
      <fo:table-body> 
       <xsl:call-template name="SortParts"/> 
      </fo:table-body> 
     </fo:table> 
    </xsl:template> 


<xsl:template name="SortParts"> 
    <xsl:for-each select="catalogSeqNumber[key('kfigNo', @figureNumber)]"> 
     <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> 
         <fo:table-cell> 
          <fo:block> 
           <xsl:value-of select=" ./itemSeqNumber/partRef/@partNumberValue"/> 
          </fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <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> 
       <fo:block>          <xsl:value-of select="concat(@item,@itemVariant)"/>    </fo:block> 
      </fo:table-cell> 

      <fo:table-cell> 
       <fo:block> 
        <xsl:value-of select="./itemSeqNumber/quantityPerNextHigherAssy"/> 
       </fo:block> 
      </fo:table-cell> 
        </fo:table-row> 
       </xsl:template> 

예상 출력 : 작동하지 않는

<fo:table-row> 
     <fo:table-cell><fo:block>1025-129</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 02</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 050</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>1476-3248-1</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 02 02</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 040</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>2079-1302-1</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 000</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>3082-1604-1</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 010</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>63358</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 02 01</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 030</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>8910-276</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 000</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
<fo:table-row> 
     <fo:table-cell><fo:block>8910-281</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block> 001</fo:block></fo:table-cell> 
     <fo:table-cell><fo:block>1</fo:block></fo:table-cell> 
</fo:table-row> 
+0

예제는 하나의 'catalogSeqNumber'를 보여 주지만, 질문, 정렬 및 결과는 최소한 두 개의 'catalogSeqNumber'가 있어야한다는 것입니다. 결과를 생성하기위한 충분한 정보를 가진 적어도 하나의'catalogSeqNumber'를 추가 할 수 있으며 또한 결과 테이블 행에 포함되어야하는 것을 보여줄 수 있습니까? –

+0

나는이 질문을 갱신했다. 고마워, 토니. – Caroline

+0

[정렬 된 노드의 다음 형제 선택] 복제본 (가능한 경우) (http://stackoverflow.com/questions/38516360/selecting-the-following-sibling-of-a-sorted-node) –

답변

1

node-set() 경우에, 당신이 다시 정렬을해야 할 바로 얻을 수 이전 항목 :

<xsl:key name="all" match="catalogSeqNumber" use="true()" /> 

<xsl:template name="SortParts"> 
    <xsl:apply-templates 
     select="catalogSeqNumber[key('kfigNo', @figureNumber)]"> 
     <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/> 
     <xsl:sort select="@figureNumber"/> 
     <xsl:sort select="@item"/> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="catalogSeqNumber"> 
    <xsl:variable 
     name="figNo" 
     select="concat(@figureNumber,@figureNumberVariant)"/> 
    <xsl:variable name="current-position" select="position()"/> 
    <xsl:variable name="prfigNo"> 
    <xsl:for-each select="key('all', true())"> 
     <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/> 
     <xsl:sort select="@figureNumber"/> 
     <xsl:sort select="@item"/> 
     <xsl:if test="position() = $current-position - 1"> 
     <xsl:value-of select="concat(@figureNumber,@figureNumberVariant)" /> 
     </xsl:if> 
    </xsl:for-each> 
    </xsl:variable> 
    <fo:table-row> 
    <fo:table-cell padding="3pt"> 
     <fo:block> 
     <xsl:value-of 
      select="itemSeqNumber/partRef/@partNumberValue"/> 
     </fo:block> 
    </fo:table-cell> 
    <fo:table-cell padding="3pt"> 
     <fo:block> 
     <xsl:if test="$figNo"> 
      <xsl:text> </xsl:text> 
      <xsl:value-of select="$figNo"/> 
      <xsl:text> </xsl:text> 
      <xsl:value-of select="$prfigNo"/> 
     </xsl:if> 
     </fo:block> 
    </fo:table-cell> 
    <fo:table-cell padding="3pt"> 
     <fo:block> 
     <xsl:value-of select="concat(@item,@itemVariant)"/> 
     </fo:block> 
    </fo:table-cell> 
    <fo:table-cell padding="3pt"> 
     <fo:block> 
     <xsl:value-of 
      select="itemSeqNumber/quantityPerNextHigherAssy"/> 
     </fo:block> 
    </fo:table-cell> 
    </fo:table-row> 
</xsl:template> 
+0

이것은 작동합니다. 고마워, 토니. – Caroline