I am wondering if you can access the result-document during processing.
The reason I ask is that I am transforming an input document and would like to insert elements depending on some conditions but this would have to occur when I have traversed the tree and I am nearly at end of creating it.
The transformed xml looks something similar to this:
<xform>
<xforms>
<model>
<instance>
<data />
<data />
</instance>
</model>
<bind />
<bind />
<bind />
</xforms>
</xform>
I intend, during transformation (before the above xml is serialized), to access the <instance> tag and insert additional <data> elements.
Note
The input document is different from the above xml – the above xml is what the transformation should produce.
Similarly, I would want to access the <xform> element and insert additional <bind> nodes.
So the final document would look like this (assuming I added 2 data nodes and 2 bind nodes):
<xform>
<xforms>
<model>
<instance>
<data />
<data />
<data>new data node</data>
<data>second new data node</data>
</instance>
</model>
<bind />
<bind />
<bind />
<bind>new bind node</bind>
<bind>second new bind node</bind>
</xforms>
</xform>
Any help is appreciated.
No, you can’t access a result-document, you can however create temporary trees in variables and then process them again, if needed with templates with a different mode. So instead of e.g.
you would create the first result in a variable and then process it further as in e.g.
That sample does not use modes but I often use them with variables and different processing steps to cleanly seperate the templates for each step from other steps.