使用XSLT在plmxml模式中显示UserValue

时间:2013-04-22 11:35:51

标签: xml xpath xslt-1.0

您好我有以下代码,我想显示ProductRevision中的UserValue,它与Occurrence中的instancedRef相匹配。架构是plmxml ...

<ProductRevision id="id279" name="Intermediate Shaft" accessRefs="#id17" subType="M3HI_MPTRevision" masterRef="#id284" revision="A" source="unset">
<ApplicationRef version="gCVFl6cKY1F1YB" application="Teamcenter" label="Q_VFl6cKY1F1YB"></ApplicationRef>
<UserData id="id280">
<UserValue value="11111" title="m3hi_Order_No"></UserValue></UserData>
<AssociatedForm id="id283" role="IMAN_master_form" formRef="#id281"></AssociatedForm></ProductRevision>

我正在尝试使用以下XSLT获取UserValue的值

<xsl:variable name="mptRevID" select="substring-after(/plm:PLMXML/plm:ProductView/plm:Occurrence[@id=$mptId]/@instancedRef, '#')"/>
<xsl:variable name="RevTag" select="/plm:PLMXML/plm:ProductRevision[@id=$mptRevID]"/> 
<xsl:variable name="Ord" select="$mptRevTag/plm:UserData/plm:UserValue/@value"/> 

当我执行上述操作时,它会在输出中给我一个空白。

请告诉我我在代码中所犯的错误或如何从xml访问UserData和UserValue。

先谢谢

2 个答案:

答案 0 :(得分:0)

我建议你使用PLMXML的特殊XSLT处理器。 http://plmski.webnode.com/plmxml-xslt-processor/ 处理器自动确定“ref-id”。您无需确定ID。

答案 1 :(得分:0)

我想你有两个问题:

  1. 错字:你在变量“Ord”的选择中使用“$ mptRevTag”代替“$ RevTag”
  2. Xpath:在PLMXML结构中(至少是我所知道的),ProductRevision元素不直接位于根节点下,但XPath表达式应如下所示:/ PLMXML / ProductDef / InstanceGraph / ProductRevision
  3. 此外,由于'title',我当然也会过滤UserValue,因为Teamcenter的所有属性都是使用此元素导出的。

    问候,Loic