Given:
File with data:
<doc>
<a>some text(<p>text here</p>) or blank</a>
<b>same</b>
</doc>
File with default values:
<doc>
<a><p>Dummy text</p></a>
<b><p>Dummy text</p></b>
</doc>
I got this xslt to get the defaults from the second file:
$file = file path with default values
<a>
<xsl:choose>
<xsl:when test="//a!= ''">
<xsl:copy-of select="//a/p" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="document($file)//a/p" />
</xsl:otherwise>
</xsl:choose>
</a>
With this it works well and all, the only problem is that I would like to make an iteration through the xml nodes and make an automated process to improve scalability and save time entering every time the same condition fro each node. But I can't find a way to use the document() function with variables for the xpath, document($file)$nodexpath doesn't work.
I might be missing something, just started recently with xslt, if any of you could give me some advice I would appreciate It greatly.
Thanks in advance.
EDIT: The actual data resembles more an xml like this, it can have more deepth levels.
<doc>
<object>
<group1>
<a>(<p>text here</p> or blank)</a>
<b>(<p>text here</p> or blank)</b>
<c>
<c1>(<p>text here</p> or blank)</c1>
<c2>(<p>text here</p> or blank)</c2>
</c>
</group1>
<group2>
<d>(<p>text here</p> or blank)</d>
</group2>
</object>
</doc>