简体   繁体   中英

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 this 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>
     ...
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM