Xml 是否显示与OccurnceRefs对应的每个事件的第一个UserData元素的所有属性?

Xml 是否显示与OccurnceRefs对应的每个事件的第一个UserData元素的所有属性?,xml,xslt,xpath,Xml,Xslt,Xpath,我有一个下面的代码,我想显示与occurrencerefs对应的每个occurrence的第一个UserData元素的所有属性?实际上,我想以HTML格式显示它,但我无法循环遍历属性并单独显示它们 提前谢谢 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" ?> <!-- GENERATED BY: PLM XML SDK 7.0.2.173 --> <PLMX

我有一个下面的代码,我想显示与occurrencerefs对应的每个occurrence的第一个UserData元素的所有属性?实际上,我想以HTML格式显示它,但我无法循环遍历属性并单独显示它们 提前谢谢

<?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>

下面是上述XML文件的代码。我差不多完成了,我在creCLext模板中以occid的顺序获得了occurrencerefs,并且通过显示它来验证它。问题是同一模板中的UserValue属性没有显示,我无法找出问题所在,xpath有什么问题吗?在creCLext模板中显示属性的正确Xpath是什么

提前谢谢

    <?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>

全球团队中心-物料清单报告
函数displayDate()
{
var d=新日期();
var weekday=新数组(“星期日”、“星期一”、“星期二”、“星期三”、“星期四”、“星期五”、“星期六”);
var monthname=新数组(“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”);
document.write(monthname[d.getMonth()]+“”);
document.write(d.getDate()+“,”);
document.write(d.getFullYear()+);
document.write(工作日[d.getDay()]+“”);
}
ISE GTc月度用户报告
生成人:
阿图尔·库马尔
日期:
显示日期()
网站名称:
作者许可证:
消费者许可证:
rox9DesignItemID
rox9CommrclDesignItemID
rox9DesignRevision
ROX9COMMRCL设计修订版


我不确定您所说的“对应于发生的事件”是什么意思。下面是一个XSL,它匹配每个
事件的第一个
UserData
(XPath:
plxml:Occurrence/plxml:UserData[1]
),并输出其所有属性(XPath:
@*
):

编辑

按如下方式修复模板:

  <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:Occurrence[@id=$occid]"/>
    <xsl:variable name="attribute1" select="$occname/plm:UserData[1]/plm:UserValue[1]/@value"/>
    <xsl:variable name="attribute2" select="$occname/plm:UserData[1]/plm:UserValue[2]/@value"/>
    <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>


你能帮我一下吗,我已经添加了下面的信息。提前感谢
事件
和两个“r”…你使用了两次
@title
而不是
@value
谢谢@mimo,这真是一个愚蠢的错误。非常感谢你的帮助。
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:plxml="http://www.plmxml.org/Schemas/PLMXMLSchema">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="text()">
  </xsl:template>

  <xsl:template match="plxml:Occurrence/plxml:UserData[1]">
    <xsl:for-each select="@*">
      <p>
        <xsl:value-of select="concat(local-name(),'=',.)"/>
      </p>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:plxml="http://www.plmxml.org/Schemas/PLMXMLSchema">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="text()">
  </xsl:template>

  <xsl:template match="plxml:Occurrence/plxml:UserData[1]">
    <xsl:for-each select="plxml:UserValue">
      <p>
        <xsl:value-of select="concat(@title,'=',@value)"/>
      </p>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
  <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:Occurrence[@id=$occid]"/>
    <xsl:variable name="attribute1" select="$occname/plm:UserData[1]/plm:UserValue[1]/@value"/>
    <xsl:variable name="attribute2" select="$occname/plm:UserData[1]/plm:UserValue[2]/@value"/>
    <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>