I have a following code , I want to display all the attributes of first UserData element of each Occurence corresponding to occurenceRefs ? Actually i want to display this in the HTML format and i am not able to loop through the attributes and display them individually
Thanks in advance …..
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" ?>
<!-- GENERATED BY: PLM XML SDK 7.0.2.173 -->
<PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema"
schemaVersion="6" language="en-us" date="2012-03-23" languages="en-us" time="07:54:04" >
<Header id="id1" traverseRootRefs="#id7" transferContext="CRF_ITM_RPT_TMODE_INST"></Header>
<RevisionRule id="id2" name="Latest Working">
<Description>Latest Working else Latest Any Status</Description>
<ApplicationRef version="QQO9hJBI40bQ2C" application="Teamcenter" label="QQO9hJBI40bQ2C"></ApplicationRef></RevisionRule>
<ProductView id="id4" ruleRefs="#id2" rootRefs="id7" primaryOccurrenceRef="id7">
<ApplicationRef application="Teamcenter" label="BgE9Vysa40bQ2C/QQO9hJBI40bQ2C/AAAAAAAAAAAAAA/BOM"></ApplicationRef>
<UserData id="id3" type="TC Specific Properties">
<UserValue value="imprecise" title="BOM_precision_type"></UserValue></UserData>
<Occurrence id="id7" occurrenceRefs="id11 id15 ">
<ApplicationRef application="Teamcenter" label="BgE9Vysa40bQ2C/"></ApplicationRef>
<UserData id="id6">
<UserValue value="" title="rox9DesignItemID"></UserValue>
<UserValue value="" title="rox9CommrclDesignItemID"></UserValue>
<UserValue value="" title="rox9DesignRevision"></UserValue>
<UserValue value="" title="rox9CommrclDesignRevision"></UserValue></UserData>
<UserData id="id8" type="AttributesInContext">
<UserValue value="" title="AO_ID"></UserValue>
<UserValue value="" title="SequenceNumber"></UserValue>
<UserValue value="" title="OccurrenceName"></UserValue>
<UserValue value="" title="Quantity"></UserValue></UserData>
<Transform id="id5">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence>
<Occurrence id="id11" parentRef="#id7">
<ApplicationRef application="Teamcenter" label="BgE9Vysa40bQ2C/BsC9Vysa40bQ2C/"></ApplicationRef>
<UserData id="id10">
<UserValue value="" title="rox9DesignItemID"></UserValue>
<UserValue value="ROXD00216480" title="rox9CommrclDesignItemID"></UserValue>
<UserValue value="" title="rox9DesignRevision"></UserValue>
<UserValue value="A" title="rox9CommrclDesignRevision"></UserValue></UserData>
<UserData id="id12" type="AttributesInContext">
<UserValue value="" title="AO_ID"></UserValue>
<UserValue value="10" title="SequenceNumber"></UserValue>
<UserValue value="" title="OccurrenceName"></UserValue>
<UserValue value="" title="Quantity"></UserValue></UserData>
<Transform id="id9">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence>
<Occurrence id="id15" parentRef="#id7">
<ApplicationRef application="Teamcenter" label="BgE9Vysa40bQ2C/BsG9Vysa40bQ2C/"></ApplicationRef>
<UserData id="id14">
<UserValue value="ROXD00315587" title="rox9DesignItemID"></UserValue>
<UserValue value="" title="rox9CommrclDesignItemID"></UserValue>
<UserValue value="C" title="rox9DesignRevision"></UserValue>
<UserValue value="" title="rox9CommrclDesignRevision"></UserValue></UserData>
<UserData id="id16" type="AttributesInContext">
<UserValue value="" title="AO_ID"></UserValue>
<UserValue value="20" title="SequenceNumber"></UserValue>
<UserValue value="" title="OccurrenceName"></UserValue>
<UserValue value="" title="Quantity"></UserValue></UserData>
<Transform id="id13">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence>
I have understood a lot and able to fetch and display them but i want to them to display as written below , So the problem is i dont know how to loop over them individually or we may have to use templates and call them repetitively …….
Any help is appreciated.Please refer to code above
Thanks in advance
The required output is:
rox9DesignItemID rox9CommrclDesignItemID rox9DesignRevision rox9CommrclDesignRevision
ROXD00216480 A
ROXD00315587 C
This below is the code for the above XML file . I am almost done with it , I am getting the occurenceRefs in a sequence in occid in the creCLext template and i have verified it by displaying it . The problem is the attributes of UserValue in the same template are not being displayed and i am not able to figure out whats the problem , is there anything wrong with xpath ? What is the correct Xpath to display attributes in creCLext template ?
Thanks in advance
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema">
<xsl:output method="html" indent="yes"/>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<xsl:variable name="trvrootref" select="/plm:PLMXML/plm:Header/@traverseRootRefs"/>
<xsl:variable name="roid" select="substring-after($trvrootref,'#')"/>
<xsl:variable name="roe" select="/plm:PLMXML/plm:ProductView/plm:Occurrence[@id=$roid]"/>
<xsl:variable name="roe1" select="$roe/@occurrenceRefs"/>
<xsl:variable name="rprid" select="substring-after($roe/@instancedRef,'#')"/>
<xsl:variable name="root" select="/plm:PLMXML/plm:ProductRevision[@id=$rprid]"/>
<!-- Reference to the Site element and last name attribute -->
<xsl:variable name="site" select="/plm:PLMXML/plm:Site"/>
<xsl:variable name="site_name" select="$site/@name"/>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<xsl:template match="/">
<html>
<head>
<title>Global Teamcenter - BOM Report</title>
<script type="text/javascript">
function displayDate()
{
var d=new Date();
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
document.write(monthname[d.getMonth()] + " ");
document.write(d.getDate() + ", ");
document.write(d.getFullYear() + " ");
document.write(weekday[d.getDay()] + " ");
}
</script>
</head>
<body style="background-position: 21px 0px; font-size: 10pt; color: black; font-family: Verdana; background-color: white;" lang="en-us">
<div> </div>
<div align="left"> </div>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<div align="center">
<table style="table-layout: fixed; border-width: medium; border-style: none; border-color: -moz-use-text-color; font-size: 10pt; width: 653px; font-family: Verdana; border-collapse: collapse; word-wrap: break-word;" border="1" cellpadding="5">
<colgroup>
<col style="width: 271px;" width="271"></col>
<col style="width: 24px;" width="24"></col>
<col style="width: 358px;" width="358"></col>
</colgroup>
<tbody valign="top">
<tr style="min-height: 42px;">
<td colspan="3" style="border-width: 1pt 1pt 5pt; border-style: none none solid; border-color: rgb(153, 168, 172) rgb(153, 168, 172) rgb(81, 125, 191); color: rgb(235, 240, 249); background-color: rgb(30, 60, 123); text-align: left;" width="653">
<h6 align="center" style="margin-top: 0px; font-weight: normal; margin-bottom: 0px; color: rgb(235, 240, 249);">
<font face="Verdana" size="4">ISE GTc Monthly User Report</font>
</h6>
</td>
</tr>
<tr style="min-height: 42px;">
<td colspan="3" style="border-width: 5pt 1pt 1pt; border-style: solid none none; border-color: rgb(81, 125, 191) rgb(153, 168, 172) rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249); text-align: left;" width="653">
<div>
<font face="Verdana" size="1">Generated by:</font>
</div>
<div>
<span>
<span title="Issue Title" id="L042502201095146C" style="border-right: 1pt none rgb(220, 220, 220); min-height: 18px; padding: 1px; border-width: 1pt; border-style: none; border-color: rgb(220, 220, 220); display: inline-block; margin: 1px; overflow: hidden; width: 100%; color: rgb(0, 0, 255); white-space: nowrap; text-overflow: ellipsis; background-color: rgb(255, 255, 255); text-align: left; word-wrap: normal;">
Atul Kumar
</span>
</span>
</div>
</td>
</tr>
<tr style="min-height: 42px;">
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249); text-align: left;" width="271">
<div>
<font face="Verdana" size="1">Date:</font>
</div>
<div>
<span>
<span title="Opened By" id="L042586E014BA9B4F" style="border-right: 1pt none rgb(220, 220, 220); min-height: 18px; padding: 1px; border-width: 1pt; border-style: none; border-color: rgb(220, 220, 220); display: inline-block; margin: 1px; overflow: hidden; width: 100%; color: rgb(0, 0, 255); white-space: nowrap; text-overflow: ellipsis; background-color: rgb(255, 255, 255); text-align: left; word-wrap: normal;">
<script type="text/javascript">
displayDate()
</script>
</span>
</span>
</div>
</td>
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249);" width="24">
<div>
<font face="Verdana" size="2"> </font>
</div>
</td>
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249); text-align: left;" width="358">
<div>
<font face="Verdana" size="1">Site Name:</font>
</div>
<div>
<span>
<span title="" id="L042587201D05A9D5" style="padding: 1px; display: inline-block; margin: 1px; overflow: hidden; width: 100%; color: rgb(0, 0, 255); white-space: normal; text-overflow: ellipsis; background-color: window; text-align: left; word-wrap: normal;">
<xsl:value-of select="$site_name"/>
</span>
</span>
</div>
</td>
</tr>
<tr style="min-height: 38px;">
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249); text-align: left;" width="271">
<div>
<font face="Verdana" size="1">Author Licenses:</font>
</div>
<div>
<span>
<span title="Area Owner" id="L0425876018E022B2" style="padding: 1px; min-height: 18px; display: inline-block; margin: 1px; overflow: hidden; width: 100%; color: rgb(0, 0, 255); white-space: normal; text-overflow: ellipsis; background-color: rgb(255, 255, 255); text-align: left; word-wrap: normal;">
<xsl:value-of select="count(//plm:UserValue[@title = 'license_level' and @value= '0' and @type='int'])"/>
</span>
</span>
</div>
</td>
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249);" width="24">
<div>
<font face="Verdana" size="2"> </font>
</div>
</td>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<td style="border-width: 1pt; border-style: none; border-color: rgb(153, 168, 172); color: black; background-color: rgb(235, 240, 249); text-align: left;" width="358">
<div>
<font face="Verdana" size="1">Consumer Licenses:</font>
</div>
<div>
<span>
<span title="" id="L042587201D05A9D5" style="padding: 1px; display: inline-block; margin: 1px; overflow: hidden; width: 100%; color: rgb(0, 0, 255); white-space: normal; text-overflow: ellipsis; background-color: window; text-align: left; word-wrap: normal;">
<xsl:value-of select="count(//plm:UserValue[@title = 'license_level' and @value= '1' and @type='int'])"/>
</span>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<span title="" id="" style="padding: 1px; overflow-x: hidden; margin: 1px; width: 647px; text-overflow: ellipsis; word-wrap: break-word;">
</span>
</div>
<div align="center">
<table title="" style="table-layout: fixed; border-width: medium; border-style: none; border-color: -moz-use-text-color; font-size: 10pt; width: 651px; font-family: Verdana; border-collapse: collapse; word-wrap: break-word;" border="1">
<colgroup>
<col style="width: 200px;" width="200"></col>
<col style="width: 160px;" width="160"></col>
<col style="width: 100px;" width="100"></col>
<col style="width: 185px;" width="185"></col>
</colgroup>
<tbody>
<tr style="">
<td style="color: black; background-color: rgb(235, 240, 249); border-width: 1pt; border-style: solid; border-color: rgb(81, 125, 191); vertical-align: top;" width="173">rox9DesignItemID</td>
<td style="color: black; background-color: rgb(235, 240, 249); border-width: 1pt; border-style: solid; border-color: rgb(81, 125, 191); vertical-align: top;" width="253">rox9CommrclDesignItemID</td>
<td style="color: black; background-color: rgb(235, 240, 249); border-width: 1pt; border-style: solid; border-color: rgb(81, 125, 191); vertical-align: top;" width="118">rox9DesignRevision</td>
<td style="color: black; background-color: rgb(235, 240, 249); border-width: 1pt; border-style: solid; border-color: rgb(81, 125, 191); vertical-align: top;" width="173">rox9CommrclDesignRevision</td>
</tr>
</tbody>
<xsl:call-template name="createCL">
<xsl:with-param name="occStr" select="$roe1"/>
</xsl:call-template>
</table>
</div>
<br/>
</body>
</html>
</xsl:template>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<xsl:template name="genData">
<xsl:param name="curPart"/>
<xsl:param name="occStr"/>
<xsl:param name="attStr"/>
</xsl:template>
<!-- inside createCL otherwise occStr <xsl:value-of select="$occStr"/> -->
<xsl:template name="createCL">
<xsl:param name="occStr"/>
<xsl:if test="$occStr!=''">
<xsl:choose>
<xsl:when test="contains($occStr,' ')">
<xsl:variable name="occid" select="substring-before($occStr,' ')"/>
<xsl:call-template name="createCL">
<xsl:with-param name="occStr" select="$occid"/>
</xsl:call-template>
<xsl:call-template name="createCL">
<xsl:with-param name="occStr" select="substring-after($occStr,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="creCLext">
<xsl:with-param name="occid" select="$occStr"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- Reference to the user element and user_id,status and license_level attribute -->
<xsl:template name="creCLext">
<xsl:param name="occid"/>
<!-- Reference to the user element and user_id,status and license_level attribute -->
<xsl:variable name="occname" select="/plm:PLMXML/plm:ProductView/plm:Occurence[@id=$occid]"/>
<xsl:variable name="attribute1" select="$occname/plm:UserData[1]/plm:UserValue[1]/@title"/>
<xsl:variable name="attribute2" select="$occname/plm:UserData[1]/plm:UserValue[2]/@title"/>
<xsl:variable name="attribute3" select="$occname/plm:UserData[1]/plm:UserValue[3]/@value"/>
<xsl:variable name="attribute4" select="$occname/plm:UserData[1]/plm:UserValue[4]/@value"/>
<!-- Reference to the person element and last name attribute -->
<!-- Displaying the values by row order -->
<tr>
<td>
<xsl:value-of select="$attribute1"/></td>
<td><xsl:value-of select="$attribute2"/></td>
<td><xsl:value-of select="$attribute3"/>
</td>
<td><xsl:value-of select="$attribute4"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
I am not sure what yoy mean by ‘corresponding to occurenceRefs?’. Here is an XSL that matches the first
UserDataof eachOccurrence(XPath:plxml:Occurrence/plxml:UserData[1]) and outputs all its attributes (XPath:@*):Here is a variation of the same XSL that output each
UserValueinstead than each attribute:EDIT
Fix the template like this: