开发者

XSLT Transformation with match

I have the following xml and I'm writing a XSLT to transform it:

<callop>
    <con>unit</con>
    <var>u</var>
    <var>v</var>
</callop>

The problem is that if <callop> is inside <is> then it should be a <nano> element and <con> becomes <Fun> but otherwise it's an <Atom> and <con> becomes a <Rel>.

How is th开发者_开发知识库is possible. Do I have to go and check what the parent node is?


You can handle this pretty easily by just specifying your templates with the full path. The more specific template match will take precedence, so there shouldn't be any issues.

<xsl:template match="is/callop">
   <nano>
     ...
...

<xsl:template match="callop">
   <Atom>
     ...
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜