'Can we match a parent node using it's child element name?
I want to match the parent node using it's child element name. Example:
<parent><child1>text</child1></parent>
Here i want to match parent element but i don't know the parent tag name but what i know is it's child element name. So i need to perform tranformation on parent tag and that's why i need to match the parent tag using it's child element name .And also if parent of child tag is root then i don't want to perform any transformation.
For more clearity i need to match something like <xsl:template match="[ancestor::contentblock]"> or <xsl:template match="[parent::contentblock]"> but xslt doesn't allow this.
Solution 1:[1]
Try something like:
//*/*[child1]
If the xpath is used in an xsl:template match, you can leave off the //.
match="*/*[child1]"
Edit
This should be more of what you're looking for:
match="*[parent::*][.//child1]"
This matches any element that has a parent element and also a descendant child1 element.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
