<root>
<tag>
<form>
some html form will be here
</form>
</tag>
<tag>
some visible data
</tag>
xslt
<xsl:template match="tag">
<div id="page-base">
<xsl:apply-templates />
</div>
</xsl:template>
produce
<div id="page-base">
</div>
<div id="page-base">
some visible data
</div>
Desired output
<div id="page-base">
<form>
some html form will be here
</form>
</div>
<div id="page-base">
some visible data
</div>
EDIT:
What if tag is nested in tag element where the templates rules applies it will replace the tag with the templates and will copy other element where templates does not match. please see the example. tag could be aribtrary nested
<root>
<tag>
<form>
some html form will be here
</form>
<tag>
arbitrary nested tags
</tag>
</tag>
<tag>
some visible data
</tag>
</root>
expected result
<div id="page-base">
<form>
some html form will be here
</form>
<div id="page-base">
arbitrary nested tags
</div>
</div>
<div id="page-base">
some visible data
</div>
This transformation:
when applied on the provided XML document:
produces the wanted, correct result:
Explanation:
Your code lacked something to copy the body of the matched
tagelement.This “something” is the
xsl:copy-ofinstruction.Update:
The OP has changed his question and this requires a different solution:
When this transformation is applied on the newly-provided XML document: