jsnosal - Tuesday, December 18, 2012 12:59 PM:
I'm having issues with the rows inside my form. When there are two AML parts and three documents, the second document row is blank. I'm not sure what is causing this. Thank you for your help.
Search
<Item type="Part" action="GetItemRepeatConfig" select="item_number,name,major_rev,classification" id="{@id}">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id" repeatProp="related_id" repeatTimes="5"/>
</Relationships>
</Item>
Style Sheet
<xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/.../Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:aras="www.aras-corp.com">
<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__id21">
<img src="../images/Logos/CooperPowerSystems.gif" height="60"></img>
</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 < 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>AML Status</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>
</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="Depth" select="count(ancestor::Item[@type='Part'])"></xsl:variable>
<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 <= $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>
<tr>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id10">
<xsl:if test="$Depth=0">0</xsl:if>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id11">
<xsl:if test="$Depth=1">1</xsl:if>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id12">
<xsl:if test="$Depth=2">2</xsl:if>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id13">
<xsl:if test="$Depth=3">3</xsl:if>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id14">
<xsl:if test="$Depth=4">4</xsl:if>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id15">
<xsl:if test="$Depth=5">5</xsl:if>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id16">
<xsl:value-of select="item_number"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id18">
<xsl:value-of select="major_rev"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="13%" align="center" uniqueID="ms__id19">
<xsl:value-of select="name"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="13%" align="center" uniqueID="ms__id20">
<xsl:value-of select="description"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id22">
<xsl:value-of select="rohs_pb_free"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id23">
<xsl:choose>
<xsl:when test="$Depth=0">1</xsl:when>
<xsl:when test="$Depth!=0 and (../../quantity)=''">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../../quantity"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id24">
<xsl:value-of select="../../reference_designator"></xsl:value-of>
</td>
<td width="5%" align="center" uniqueID="ms__id25">
<xsl:value-of select="Relationships/Item[@type='Part AML'][1]/state"></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>
</tr>
<xsl:apply-templates select="Relationships/Item[@type='Part AML'][position()!=1] | Relationships/Item[@type='Part Document'][position()!=1]"></xsl:apply-templates>
</xsl:template>
<!-- Selects AML data for each row -->
<xsl:template match="Item[@type='Part AML'] | Item[@type='Part Document']">
<tr>
<td width="5%" align="center" uniqueID="ms__id31">
<xsl:value-of select="state"></xsl:value-of>
</td>
<td width="13%" align="center" uniqueID="ms__id32">
<xsl:value-of select="related_id/Item/manufacturer/@keyed_name"></xsl:value-of>
</td>
<td width="13%" align="center" uniqueID="ms__id33">
<xsl:value-of select="related_id[@type='Manufacturer Part']/Item/item_number"></xsl:value-of>
</td>
<td width="5%" align="center" uniqueID="ms__id34">
<xsl:value-of select="related_id[@type='Document']/Item/item_number"></xsl:value-of>
</td>
<td width="13%" align="center" uniqueID="ms__id35">
<xsl:value-of select="related_id[@type='Document']/Item/name"></xsl:value-of>
</td>
<td width="8%" align="center" uniqueID="ms__id36">
<xsl:value-of select="related_id/Item/major_rev"></xsl:value-of>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Brian - Thursday, December 20, 2012 1:02 AM:
Hi Jsonal,
Can you send me an email with the actual output of that query plus the stylesheet as attached files?
I can have a look at them and see if something jumps out.
Cheers,
Brian ([email protected])
jsnosal - Wednesday, January 9, 2013 10:56 AM:
I found the solution for this issue. I worked with JLRishe at Stackoverflow.com and the whole BOM report has been rewritten to get it to work. I also found how to make sure the BOM didn't ignore duplicate values. Thanks
Report Query
<Item type="Part" action="get" select="item_number,name,major_rev,classification,rohs_pb_free,description" id="{@id}">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id(item_number,name)">
<related_id>
<Item type="Part" select="item_number,name,major_rev,classification,rohs_pb_free,description">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id(item_number,name)">
<related_id>
<Item type="Part" select="item_number,name,major_rev,classification,rohs_pb_free,description">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id(item_number,name)">
<related_id>
<Item type="Part" select="item_number,name,major_rev,classification,rohs_pb_free,description">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id(item_number,name)">
<related_id>
<Item type="Part" select="item_number,name,major_rev,classification,rohs_pb_free,description">
<Relationships>
<Item type="Part AML" select="state,related_id(item_number,manufacturer)"/>
<Item type="Part Document" select="state,related_id(item_number,name,major_rev)"/>
<Item type="Part BOM" select="sort_order,quantity,reference_designator,related_id(item_number,name)">
<related_id>
<Item type="Part" select="item_number,name,major_rev,classification,rohs_pb_free,description"></Item>
</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
Style Sheet
<xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/.../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="2350">
<tr valign="top">
<td class="noBorder" align="left" colspan="9" uniqueID="ms__id39">
<img src="" height="60"></img>
</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 < 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="13%" colspan="6">Indent Level</th>
<th width="5%">Part Number</th>
<th width="5%">Revision</th>
<th width="13%">Name</th>
<th width="13%">Description</th>
<th width="5%">RoHS/Pb-Free</th>
<th width="5%">Quantity</th>
<th width="5%">Reference Designator</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>
</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)]" />
<xsl:variable name="Depth" select="count(ancestor::Item[@type='Part'])"></xsl:variable>
<!-- 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>
<td rowspan="{$rowCount}" width="2%" align="center" uniqueID="ms__id18">
<xsl:value-of select="major_rev"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="13%" align="center" uniqueID="ms__id19">
<xsl:value-of select="name"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="13%" align="center" uniqueID="ms__id20">
<xsl:value-of select="description"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id22">
<xsl:value-of select="rohs_pb_free"></xsl:value-of>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id23">
<xsl:choose>
<xsl:when test="$Depth=0">1</xsl:when>
<xsl:when test="$Depth!=0 and (../../quantity)=''">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../../quantity"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</td>
<td rowspan="{$rowCount}" width="5%" align="center" uniqueID="ms__id24">
<xsl:value-of select="../../reference_designator"></xsl:value-of>
</td>
<xsl:apply-templates select="$largerGroup[1]" />
</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 < 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>
sagar_makhesana - Tuesday, June 23, 2015 7:34 AM:
Hello Jsnosal ,
Is there any other way to get child level related data of related Item Using AML in this way
<AML>
<Item type="part" action="get" select="keyed_name">
<Relationships>
<Item type="Part Document" action="get">
<related_id>
<Item type="Document" action="get" select="name">
<Relationships>
<Item type="Document File" action="get" select="related_id(keyed_name)"></Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</AML>
But can we shorten the Query ??
Thanks in advance :-)