XSLT动态行

XSLT动态行,xslt,Xslt,我对数据的格式有问题。顶层节点是一部分。节点下方的元素是AML和文档。AML和文档可以是不同的值。AML可以大于单据,单据可以大于AML。我需要文档和AML的元素在同一行上,以便表的格式正确。如果您需要更多信息,请告诉我,并感谢您的帮助。非常感谢 资料 E008643 0000-009 初步的 1234 初步的 B 硬件文档 D000006 B 固件 D000005 A. 设计规范书 D000003 E000371 3Z1JTTD 初步的 千吨 初步的 R00V 初步的 扶轮基金会 初步的 7

我对数据的格式有问题。顶层节点是一部分。节点下方的元素是AML和文档。AML和文档可以是不同的值。AML可以大于单据,单据可以大于AML。我需要文档和AML的元素在同一行上,以便表的格式正确。如果您需要更多信息,请告诉我,并感谢您的帮助。非常感谢

资料


E008643
0000-009
初步的
1234
初步的
B
硬件文档
D000006
B
固件
D000005
A.
设计规范书
D000003
E000371
3Z1JTTD
初步的
千吨
初步的
R00V
初步的
扶轮基金会
初步的
70RL
初步的
B
盒子
D000007
A.
插座
D000008

样式表

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:aras="http://www.aras-corp.com" exclude-result-prefixes="msxsl">
     <xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"></xsl:output>

     <xsl:template match="/">
        <html>
          <head></head>
          <style type="text/css" userData="Global">
        table  {empty-cells:show; border-collapse:collapse;}
        th {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
        td {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid;}
        td.noBorder {font-family:helvetica; font-size:8pt;  padding:2px; border-width:0;}
       </style>
          <body topmargin="50" leftmargin="50">
            <table border="0" cellspacing="0" cellpadding="0" width="1850">
              <tr valign="top">
                <td class="noBorder" align="left" colspan="9" uniqueID="ms__id39">
          </td>
         </tr>
              <tr valign="bottom">
                <td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">Bill of Materials Report -              <xsl:value-of select="//Item/name"></xsl:value-of> Rev              <xsl:value-of select="//Item/major_rev"></xsl:value-of>
                </td>
                <td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">Generated on:              <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length &lt; n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script>
                </td>
         </tr>
              <tr>
                <th>Part Number</th>
                <th>Manufacturer</th>
                <th>Manufacturer Part</th>
                <th>Document Number</th>
                <th>Document Name</th>
                <th>Document Rev</th>
           </tr>
         <xsl:apply-templates select="//Item[@type='Part']"></xsl:apply-templates>
        </table>
       </body>
          <script src="../../javascript/PopupMenu.js"></script>
          <script src="../../javascript/PopupMenu.js"></script>
          <script src="../../javascript/PopupMenu.js"></script>
          <script src="../../javascript/PopupMenu.js"></script>
        </html>
     </xsl:template>
      <xsl:template match="Item[@type='Part']">

      <!-- Find the number Row Span -->
        <xsl:variable name="AML">
          <xsl:choose>
            <xsl:when test="count(Relationships/Item[@type='Part AML'])=0">1</xsl:when>        
            <xsl:otherwise>
              <xsl:value-of select="count(Relationships/Item[@type='Part AML'])"></xsl:value-of>
            </xsl:otherwise>
       </xsl:choose>
      </xsl:variable>
      <xsl:variable name="Doc">
          <xsl:choose>
            <xsl:when test="count(Relationships/Item[@type='Part Document'])=0">1</xsl:when>        
            <xsl:otherwise>
              <xsl:value-of select="count(Relationships/Item[@type='Part Document'])"></xsl:value-of>
            </xsl:otherwise>
       </xsl:choose>
      </xsl:variable>
      <xsl:variable name="rowCount">
         <xsl:choose>
          <xsl:when test="$AML &lt; $Doc"><xsl:value-of select="$Doc"></xsl:value-of></xsl:when> 
            <xsl:otherwise>
            <xsl:value-of select="$AML"></xsl:value-of>    
            </xsl:otherwise>
         </xsl:choose>  
      </xsl:variable>

     <!-- Grab values -->
       <tr>
          <td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id16">
            <xsl:value-of select="item_number"></xsl:value-of>
          </td>      
          <td width="13%" align="center" uniqueID="ms__id26">
            <xsl:value-of select="Relationships/Item[@type='Part AML'][1]/related_id/Item/manufacturer/@keyed_name"></xsl:value-of>
          </td>
          <td width="13%" align="center" uniqueID="ms__id27">
            <xsl:value-of select="Relationships/Item[@type='Part AML'][1]/related_id/Item/item_number"></xsl:value-of>
          </td>
          <td width="5%" align="center" uniqueID="ms__id28">
            <xsl:value-of select="Relationships/Item[@type='Part Document'][1]/related_id/Item/item_number"></xsl:value-of>
          </td>
          <td width="13%px" align="center" uniqueID="ms__id29">
            <xsl:value-of select="Relationships/Item[@type='Part Document'][1]/related_id/Item/name"></xsl:value-of>
          </td>
          <td width="8%" align="center" uniqueID="ms__id30">
            <xsl:value-of select="Relationships/Item[@type='Part Document'][1]/related_id/Item/major_rev"></xsl:value-of>
          </td>
          <td rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id37">
            <xsl:value-of select="count(Relationships/Item[@type='Part AML'])"></xsl:value-of>
          </td>
          <td  rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id38">
            <xsl:value-of select="count(Relationships/Item[@type='Part Document'])"></xsl:value-of>
          </td>
          <td rowspan="{$rowCount}" width="8%" align="center" uniqueID="ms__id40">
            <xsl:value-of select="position() mod 2 = 1"></xsl:value-of>
          </td>
        </tr>

    <!-- Assing first row for AML and Doc -->
        <xsl:apply-templates select="Relationships/Item[@type='Part AML'][position()!=1]|Relationships/Item[@type='Part Document'][position()!=1]"></xsl:apply-templates>
     </xsl:template>

     <!-- AML and Doc Rows 2+ -->    
        <xsl:template match="text()" />

       <xsl:template match="Item[@type = 'Part AML'][not(following-sibling::Item[1]/@type = 'Part Document')]">
        <xsl:call-template name="ItemRow">
          <xsl:with-param name="AmlItem" select="." />
        </xsl:call-template>
      </xsl:template>

      <xsl:template match="Item[@type='Part Document']">
        <xsl:variable name="lastItem" select="preceding-sibling::Item[1][@type = 'Part AML']" />

        <xsl:call-template name="ItemRow">
          <xsl:with-param name="AmlItem" select="$lastItem" />
          <xsl:with-param name="PartDocument" select="." />
        </xsl:call-template>
      </xsl:template>

      <xsl:template name="ItemRow">
        <xsl:param name="AmlItem" />
        <xsl:param name="PartDocument" select="_" />

        <xsl:variable name="rowData">
          <row value="{$AmlItem/related_id/Item/manufacturer/@keyed_name}" id="32" />
          <row value="{$AmlItem/related_id/Item[@type='Manufacturer Part']/item_number}" id="33" />
          <row value="{$PartDocument/related_id[@type='Document']/Item/item_number}" id="34" />
          <row value="{$PartDocument/related_id[@type='Document']/Item/name}" id="35" />
          <row value="{$PartDocument/related_id[@type='Document']/Item/major_rev}" id="36" />
        </xsl:variable>

        <tr>
          <xsl:for-each select="msxsl:node-set($rowData)/row">
            <td width="13%" align="center" uniqueID="ms__id{@id}">
              <xsl:value-of select="@value"/>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:template>
    </xsl:stylesheet>

表{空单元格:显示;边框折叠:折叠;}
th{字体系列:helvetica;字体大小:8pt;填充:2px;边框:1px#000000实心;背景色:#CCCCCC;文本转换:大写;}
td{font-family:helvetica;字体大小:8pt;填充:2px;边框:1px#000000 solid;}
td.noBorder{字体系列:helvetica;字体大小:8pt;填充:2px;边框宽度:0;}
材料清单报告-修订版
生成日期:函数m00(r,n){r+=”;如果(!n)n=2;而(r.length n){r=“0”+r;}返回r;}var dt=new Date();var a=top.opener.top.aras;如果(a){var s=m00(dt.getUTCFullYear(),4)+“-”+m00((dt.getUTCMonth()+1))+“-”+m00(dt.getUTCDate())+“T”+m00(dt.getUTCHours())+”:“+m00(dt.getUTCMinutes())+”:“+m00(dt.getUTCSeconds())+”+“+0000”;s=a.converttoneuttoneural(s),“日期”,“yyyyyy-MM-ddTHH:MM:MM:sszzz”);s=a.convertfromneutfrom(dt.getUTCMinutes),“日期”,“短日期”;“文件”;“s”;”
零件号
制造商
制造商零件
文件编号
文件名
文件修订版
1.
1.
产出1-7-12

     <td width="13%" align="center" uniqueID="ms__id32">Bobs Workshop</td>
     <td width="13%" align="center" uniqueID="ms__id33">1234</td>
     <td width="13%" align="center" uniqueID="ms__id34">D000005</td>
     <td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
     <td width="13%" align="center" uniqueID="ms__id36">B</td>
     <td width="13%" align="center" uniqueID="ms__id34">D000003</td>
     <td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
     <td width="13%" align="center" uniqueID="ms__id36">A</td>
Bobs车间
1234
D000005
固件
B
D000003
设计规范书
A.
期望输出

 <!-- If both present -->
    <tr>
     <td width="13%" align="center" uniqueID="ms__id32">Bobs Workshop</td>
     <td width="13%" align="center" uniqueID="ms__id33">1234</td>
     <td width="13%" align="center" uniqueID="ms__id34">D000005</td>
     <td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
     <td width="13%" align="center" uniqueID="ms__id36">B</td>
    </tr>        
<!-- If only Doc is present -->
    <tr>
     <td width="13%" align="center" uniqueID="ms__id32">""</td>
     <td width="13%" align="center" uniqueID="ms__id33">""</td>
     <td width="13%" align="center" uniqueID="ms__id34">D000003</td>
     <td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
     <td width="13%" align="center" uniqueID="ms__id36">A</td>
    </tr>   
<!-- If only AML is present -->
     <tr>
     <td width="13%" align="center" uniqueID="ms__id32">Nickel</td>
     <td width="13%" align="center" uniqueID="ms__id33">000T</td>
     <td width="13%" align="center" uniqueID="ms__id34">""</td>
     <td width="13%" align="center" uniqueID="ms__id35">""</td>
     <td width="13%" align="center" uniqueID="ms__id36">""</td>
    </tr>  

Bobs车间
1234
D000005
固件
B
""
""
D000003
设计规范书
A.
镍
千吨
""
""
""
所需的完整HTML输出

    <html xmlns:aras="http://www.aras-corp.com">
      <head>
        <META http-equiv="Content-Type" content="text/html; charset=utf-16">
      </head>
      <style type="text/css" userData="Global">
        table  {empty-cells:show; border-collapse:collapse;}
        th {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
        td {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid;}
        td.noBorder {font-family:helvetica; font-size:8pt;  padding:2px; border-width:0;}
       </style>
      <body topmargin="50" leftmargin="50">
        <table border="0" cellspacing="0" cellpadding="0" width="1850">
          <tr valign="top">
          </tr>
          <tr valign="bottom">
            <td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">Bill of Materials Report -             9.6 Hz Parts Rev              1</td>
            <td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">Generated on:              <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length < n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script></td>
          </tr>
          <tr>
            <th colspan="6">Indenture Level</th>
            <th>Part Number</th>
            <th>Legacy Part Number</th>
            <th>Revision</th>
            <th>Name</th>
            <th>Description</th>
            <th>Parameters</th>
            <th>RoHS/Pb-Free</th>
            <th>Quantity</th>
            <th>Reference Designator</th>
            <th>Manufacturer</th>
            <th>Manufacturer Part</th>
            <th>Document Number</th>
            <th>Document Name</th>
            <th>Document Rev</th>
            <th>Pos AML</th>
            <th>Pos Doc</th>
            <th>Mod</th>
          </tr>
          <tr>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id10">0</td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id11"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id16">E008643</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id17"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id18">1</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id19">9.6 Hz Parts</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id20">Test</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id21">Assembly</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id22"></td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id23">1</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id24"></td>
            <td width="13%" align="center" uniqueID="ms__id26">Fasteners Co.</td>
            <td width="13%" align="center" uniqueID="ms__id27">009</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000006</td>
            <td width="13%px" align="center" uniqueID="ms__id29">Hardware Doc</td>
            <td width="8%" align="center" uniqueID="ms__id30">B</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id37">2</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id38">3</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id40">true</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Vishay/Dale</td>
            <td width="13%" align="center" uniqueID="ms__id33">1234</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000005</td>
            <td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
            <td width="13%" align="center" uniqueID="ms__id36">B</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32"></td>
            <td width="13%" align="center" uniqueID="ms__id33"></td>
            <td width="13%" align="center" uniqueID="ms__id34">D000003</td>
            <td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id10"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id11">1</td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id16">E000371</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id17">0061</td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id18">A</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id19">0?</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id20">Thick Film ''</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id21">0, 100, 0.05</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id22">Yes</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id23">1</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id24">R34</td>
            <td width="13%" align="center" uniqueID="ms__id26">Speer</td>
            <td width="13%" align="center" uniqueID="ms__id27">RK73Z1JTTD</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000010</td>
            <td width="13%px" align="center" uniqueID="ms__id29">BOX</td>
            <td width="8%" align="center" uniqueID="ms__id30">B</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id37">5</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id38">3</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id40">false</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Nickel</td>
            <td width="13%" align="center" uniqueID="ms__id33">000T</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000011</td>
            <td width="13%" align="center" uniqueID="ms__id35">SOCKET</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Sonic</td>
            <td width="13%" align="center" uniqueID="ms__id33">R00V</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000007</td>
            <td width="13%" align="center" uniqueID="ms__id35">MOUNT</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">NIC</td>
            <td width="13%" align="center" uniqueID="ms__id33">OTRF</td>
            <td width="13%" align="center" uniqueID="ms__id34"></td>
            <td width="13%" align="center" uniqueID="ms__id35"></td>
            <td width="13%" align="center" uniqueID="ms__id36"></td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Test</td>
            <td width="13%" align="center" uniqueID="ms__id33">9874</td>
            <td width="13%" align="center" uniqueID="ms__id34"></td>
            <td width="13%" align="center" uniqueID="ms__id35"></td>
            <td width="13%" align="center" uniqueID="ms__id36"></td>
          </tr>
          <tr>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id10"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id11">1</td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id16">E001163</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id17">0145</td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id18">A</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id19">8200</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id20">PPS Film ''</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id21">
            </td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id22">Yes</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id23">30</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id24">C1-C5,C12,C17,C22,C25,C27-C29,C31</td>
            <td width="13%" align="center" uniqueID="ms__id26">Sonic</td>
            <td width="13%" align="center" uniqueID="ms__id27">822GX5</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000012</td>
            <td width="13%px" align="center" uniqueID="ms__id29">Doc Test</td>
            <td width="8%" align="center" uniqueID="ms__id30">A</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id37">2</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id38">2</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id40">true</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32"></td>
            <td width="13%" align="center" uniqueID="ms__id33"></td>
            <td width="13%" align="center" uniqueID="ms__id34">D000008</td>
            <td width="13%" align="center" uniqueID="ms__id35">ADAPTER</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
        </table>
      </body><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script></html>

表{空单元格:显示;边框折叠:折叠;}
th{字体系列:helvetica;字体大小:8pt;填充:2px;边框:1px#000000实心;背景色:#CCCCCC;文本转换:大写;}
td{font-family:helvetica;字体大小:8pt;填充:2px;边框:1px#000000 solid;}
td.noBorder{字体系列:helvetica;字体大小:8pt;填充:2px;边框宽度:0;}
材料清单报告-9.6 Hz第1版零件
生成日期:乐趣
    <html xmlns:aras="http://www.aras-corp.com">
      <head>
        <META http-equiv="Content-Type" content="text/html; charset=utf-16">
      </head>
      <style type="text/css" userData="Global">
        table  {empty-cells:show; border-collapse:collapse;}
        th {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
        td {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid;}
        td.noBorder {font-family:helvetica; font-size:8pt;  padding:2px; border-width:0;}
       </style>
      <body topmargin="50" leftmargin="50">
        <table border="0" cellspacing="0" cellpadding="0" width="1850">
          <tr valign="top">
          </tr>
          <tr valign="bottom">
            <td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">Bill of Materials Report -             9.6 Hz Parts Rev              1</td>
            <td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">Generated on:              <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length < n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script></td>
          </tr>
          <tr>
            <th colspan="6">Indenture Level</th>
            <th>Part Number</th>
            <th>Legacy Part Number</th>
            <th>Revision</th>
            <th>Name</th>
            <th>Description</th>
            <th>Parameters</th>
            <th>RoHS/Pb-Free</th>
            <th>Quantity</th>
            <th>Reference Designator</th>
            <th>Manufacturer</th>
            <th>Manufacturer Part</th>
            <th>Document Number</th>
            <th>Document Name</th>
            <th>Document Rev</th>
            <th>Pos AML</th>
            <th>Pos Doc</th>
            <th>Mod</th>
          </tr>
          <tr>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id10">0</td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id11"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id16">E008643</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id17"></td>
            <td rowspan="3" width="2%" align="center" uniqueID="ms__id18">1</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id19">9.6 Hz Parts</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id20">Test</td>
            <td rowspan="3" width="13%" align="center" uniqueID="ms__id21">Assembly</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id22"></td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id23">1</td>
            <td rowspan="3" width="5%" align="center" uniqueID="ms__id24"></td>
            <td width="13%" align="center" uniqueID="ms__id26">Fasteners Co.</td>
            <td width="13%" align="center" uniqueID="ms__id27">009</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000006</td>
            <td width="13%px" align="center" uniqueID="ms__id29">Hardware Doc</td>
            <td width="8%" align="center" uniqueID="ms__id30">B</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id37">2</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id38">3</td>
            <td rowspan="3" width="8%" align="center" uniqueID="ms__id40">true</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Vishay/Dale</td>
            <td width="13%" align="center" uniqueID="ms__id33">1234</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000005</td>
            <td width="13%" align="center" uniqueID="ms__id35">Firmware</td>
            <td width="13%" align="center" uniqueID="ms__id36">B</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32"></td>
            <td width="13%" align="center" uniqueID="ms__id33"></td>
            <td width="13%" align="center" uniqueID="ms__id34">D000003</td>
            <td width="13%" align="center" uniqueID="ms__id35">Design Spec</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id10"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id11">1</td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id16">E000371</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id17">0061</td>
            <td rowspan="5" width="2%" align="center" uniqueID="ms__id18">A</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id19">0?</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id20">Thick Film ''</td>
            <td rowspan="5" width="13%" align="center" uniqueID="ms__id21">0, 100, 0.05</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id22">Yes</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id23">1</td>
            <td rowspan="5" width="5%" align="center" uniqueID="ms__id24">R34</td>
            <td width="13%" align="center" uniqueID="ms__id26">Speer</td>
            <td width="13%" align="center" uniqueID="ms__id27">RK73Z1JTTD</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000010</td>
            <td width="13%px" align="center" uniqueID="ms__id29">BOX</td>
            <td width="8%" align="center" uniqueID="ms__id30">B</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id37">5</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id38">3</td>
            <td rowspan="5" width="8%" align="center" uniqueID="ms__id40">false</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Nickel</td>
            <td width="13%" align="center" uniqueID="ms__id33">000T</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000011</td>
            <td width="13%" align="center" uniqueID="ms__id35">SOCKET</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Sonic</td>
            <td width="13%" align="center" uniqueID="ms__id33">R00V</td>
            <td width="13%" align="center" uniqueID="ms__id34">D000007</td>
            <td width="13%" align="center" uniqueID="ms__id35">MOUNT</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">NIC</td>
            <td width="13%" align="center" uniqueID="ms__id33">OTRF</td>
            <td width="13%" align="center" uniqueID="ms__id34"></td>
            <td width="13%" align="center" uniqueID="ms__id35"></td>
            <td width="13%" align="center" uniqueID="ms__id36"></td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32">Test</td>
            <td width="13%" align="center" uniqueID="ms__id33">9874</td>
            <td width="13%" align="center" uniqueID="ms__id34"></td>
            <td width="13%" align="center" uniqueID="ms__id35"></td>
            <td width="13%" align="center" uniqueID="ms__id36"></td>
          </tr>
          <tr>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id10"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id11">1</td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id12"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id13"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id14"></td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id15"></td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id16">E001163</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id17">0145</td>
            <td rowspan="2" width="2%" align="center" uniqueID="ms__id18">A</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id19">8200</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id20">PPS Film ''</td>
            <td rowspan="2" width="13%" align="center" uniqueID="ms__id21">
            </td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id22">Yes</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id23">30</td>
            <td rowspan="2" width="5%" align="center" uniqueID="ms__id24">C1-C5,C12,C17,C22,C25,C27-C29,C31</td>
            <td width="13%" align="center" uniqueID="ms__id26">Sonic</td>
            <td width="13%" align="center" uniqueID="ms__id27">822GX5</td>
            <td width="5%" align="center" uniqueID="ms__id28">D000012</td>
            <td width="13%px" align="center" uniqueID="ms__id29">Doc Test</td>
            <td width="8%" align="center" uniqueID="ms__id30">A</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id37">2</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id38">2</td>
            <td rowspan="2" width="8%" align="center" uniqueID="ms__id40">true</td>
          </tr>
          <tr>
            <td width="13%" align="center" uniqueID="ms__id32"></td>
            <td width="13%" align="center" uniqueID="ms__id33"></td>
            <td width="13%" align="center" uniqueID="ms__id34">D000008</td>
            <td width="13%" align="center" uniqueID="ms__id35">ADAPTER</td>
            <td width="13%" align="center" uniqueID="ms__id36">A</td>
          </tr>
        </table>
      </body><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script><script src="../../javascript/PopupMenu.js"></script></html>
<xsl:template match="Item[@type='Part AML']|Item[@type='Part Document']">
  <tr>
    <xsl:apply-templates select="related_id/Item/manufacturer/@keyed_name"/>
    ...
  </tr>
</xsl:template>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:aras="http://www.aras-corp.com" exclude-result-prefixes="msxsl">
  <xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"></xsl:output>

  <xsl:template match="/">
    <html>
      <head></head>
      <style type="text/css" userData="Global">
        table  {empty-cells:show; border-collapse:collapse;}
        th {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid; background-color:#CCCCCC; text-transform:capitalize;}
        td {font-family:helvetica; font-size:8pt;  padding:2px; border:1px #000000 solid;}
        td.noBorder {font-family:helvetica; font-size:8pt;  padding:2px; border-width:0;}
      </style>
      <body topmargin="50" leftmargin="50">
        <table border="0" cellspacing="0" cellpadding="0" width="1850">
          <tr valign="top">
            <td class="noBorder" align="left" colspan="9" uniqueID="ms__id39">
            </td>
          </tr>
          <tr valign="bottom">
            <td class="noBorder" colspan="13" style="font-family:helvetica;font-size:15pt;color:#DA1943;padding:2px;" align="left" uniqueID="ms__id22">
              Bill of Materials Report -              <xsl:value-of select="//Item/name"></xsl:value-of> Rev              <xsl:value-of select="//Item/major_rev"></xsl:value-of>
            </td>
            <td class="noBorder" colspan="7" style="font-family:helvetica;font-size:10pt;padding:2px;" align="right" uniqueID="ms__id23">
              Generated on:              <script>function m00(r, n){r += ""; if (!n) n = 2; while(r.length &lt; n){r = "0" + r;} return r;} var dt = new Date(); var a = top.opener.top.aras; if (a){var s = m00(dt.getUTCFullYear(),4)+"-"+m00((dt.getUTCMonth()+1))+"-"+m00(dt.getUTCDate())+"T"+m00(dt.getUTCHours())+":"+m00(dt.getUTCMinutes())+":"+m00(dt.getUTCSeconds())+"+0000"; s = a.convertToNeutral(s, "date", "yyyy-MM-ddTHH:mm:sszzz"); s = a.convertFromNeutral(s, "date", "short_date"); document.write(s);}</script>
            </td>
          </tr>
          <tr>
            <th width="12%" colspan="6">Indent Level</th>
            <th width="5%">Part Number</th>
            <th width="13%">Manufacturer</th>
            <th width="13%">Manufacturer Part</th>
            <th width="13%">Document Number</th>
            <th width="13%">Document Name</th>
            <th width="13%">Document Rev</th>
            <th width="8%">Pos AML</th>
            <th width="8%">Pos Doc</th>
            <th width="8%">Mod</th>
          </tr>
          <xsl:apply-templates select="//Item[@type='Part']"></xsl:apply-templates>
        </table>
      </body>
      <script src="../../javascript/PopupMenu.js"></script>
      <script src="../../javascript/PopupMenu.js"></script>
      <script src="../../javascript/PopupMenu.js"></script>
      <script src="../../javascript/PopupMenu.js"></script>
    </html>
  </xsl:template>
  <xsl:template match="Item[@type='Part']">

    <xsl:variable name="AmlItems" select="Relationships/Item[@type='Part AML']"/>
    <xsl:variable name="DocItems" select="Relationships/Item[@type='Part Document']"/>

    <xsl:variable name="MoreAmlItems" select="count($AmlItems) > count($DocItems)" />

    <xsl:variable name="largerGroup" select="$AmlItems[$MoreAmlItems] | $DocItems[not($MoreAmlItems)]" />

    <!-- Ensure rowCount is at least 1 -->
    <xsl:variable name="rowCount" select="count($largerGroup) + (count($largerGroup) = 0)"/>

    <!-- Grab values -->
    <tr>
      <xsl:call-template name="IndentLevel">
        <xsl:with-param name="rowSpan" select="$rowCount" />
      </xsl:call-template>
      <td rowspan="{$rowCount}" align="center" uniqueID="ms__id16">
        <xsl:value-of select="item_number"></xsl:value-of>
      </td>
      <xsl:apply-templates select="$largerGroup[1]" />
      <td rowspan="{$rowCount}" align="center" uniqueID="ms__id37">
        <xsl:value-of select="count($AmlItems)"></xsl:value-of>
      </td>
      <td  rowspan="{$rowCount}" align="center" uniqueID="ms__id38">
        <xsl:value-of select="count($DocItems)"></xsl:value-of>
      </td>
      <td rowspan="{$rowCount}" align="center" uniqueID="ms__id40">
        <xsl:value-of select="position() mod 2 = 1"></xsl:value-of>
      </td>
    </tr>

    <!-- Assing first row for AML and Doc -->
    <xsl:apply-templates select="$largerGroup[position() > 1]"></xsl:apply-templates>
  </xsl:template>

  <xsl:template name="IndentLevel">
    <xsl:param name="level" select="0" />
    <xsl:param name="rowSpan" />

    <td rowspan="{$rowSpan}" width="2%" align="center" uniqueID="ms__id{10+$level}">
      <xsl:if test="count(ancestor::Item[@type = 'Part']) = $level">
        <xsl:value-of select="$level"/>
      </xsl:if>
    </td>
    <!-- Stop when we reach 5 -->
    <xsl:if test="$level &lt; 5">
      <xsl:call-template name="IndentLevel">
        <xsl:with-param name="level" select="$level + 1" />
        <xsl:with-param name="rowSpan" select="$rowSpan" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

  <!-- AML and Doc Rows 2+ -->
  <xsl:template match="text()" />

  <xsl:template match="Item[@type = 'Part AML']">
    <xsl:variable name="pos" select="position()" />
    <xsl:variable name="isTop" select="not(preceding-sibling::Item[@type = 'Part AML'])"/>
    <xsl:call-template name="ItemRow">
      <xsl:with-param name="AmlItem" select="." />
      <xsl:with-param name="PartDocument" select="../Item[@type = 'Part Document'][position() = $pos + not($isTop)]" />
      <xsl:with-param name="IsTop" select="$isTop" />
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="Item[@type='Part Document']">
    <xsl:variable name="pos" select="position()" />
    <xsl:variable name="isTop" select="not(preceding-sibling::Item[@type = 'Part Document'])"/>
    <xsl:call-template name="ItemRow">
      <xsl:with-param name="AmlItem" select="../Item[@type = 'Part AML'][position() = $pos + not($isTop)]" />
      <xsl:with-param name="PartDocument" select="." />
      <xsl:with-param name="IsTop" select="$isTop" />
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="ItemRow">
    <xsl:param name="AmlItem" />
    <xsl:param name="PartDocument" select="_" />
    <xsl:param name="IsTop" />

    <xsl:variable name="startingId" select="26 * $IsTop + 32 * not($IsTop)" />

    <xsl:variable name="rowData">
      <cell value="{$AmlItem/related_id/Item/manufacturer/@keyed_name}" />
      <cell value="{$AmlItem/related_id/Item[@type='Manufacturer Part']/item_number}" />
      <cell value="{$PartDocument/related_id[@type='Document']/Item/item_number}" />
      <cell value="{$PartDocument/related_id[@type='Document']/Item/name}" />
      <cell value="{$PartDocument/related_id[@type='Document']/Item/major_rev}" />
    </xsl:variable>

    <xsl:variable name="rowCells">
      <xsl:call-template name="RowCells">
        <xsl:with-param name="rowData" select="$rowData" />
        <xsl:with-param name="startingId" select="$startingId" />
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$IsTop">
        <xsl:copy-of select="$rowCells"/>
      </xsl:when>
      <xsl:otherwise>
        <tr>
          <xsl:copy-of select="$rowCells"/>
        </tr>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="RowCells">
    <xsl:param name="rowData" />
    <xsl:param name="startingId" />

    <xsl:for-each select="msxsl:node-set($rowData)/cell">
      <td align="center" uniqueID="ms__id{$startingId + position() - 1}">
        <xsl:value-of select="@value"/>
      </td>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>