I am trying to translate an XML document into a specialized form of XML via XSLT. During the translation process, there are certain cases where I need to reuse a previously translated node and it's children. I am having trouble figuring out how to store the node when it is translated and output it to the new document when needed. Thanks.
Already translated node can be accessed by giving absolute xpath (start from root tag like /Root/Child) while translating other node. But remember that you can access data of the source tree but not the target tree while translation process.
<b> holds value '10' but not '100'.
In <xsl:template match="b">, if you want to know what the translated 'a' contains, you obviously need to check if sachin scored a century or not.
Thanks for the reply. I guess I wasn't very clear with my question. Given a node (and children of the node) of xml from the source document, I translate it into the destination document. What I want to do is store that translated node so that I can added it later on without having to re-translate that section. The reasoning being that I need to append the stored translated node to each subsequent translated node. Hope this make sense.
Joined: Sep 23, 2006
Store the translated node into an xml document and retrive it to copy into destination document (while translation) using document() function.
For eg. to copy your translated doc(stored in trans.xml) to an element 'A' <A> <xsl:copy-of select="document('c:/x/trans.xml')"/> </A> ..... Or if your tobe copied node and other elements (into which you want to copy) exist in the same file (during same tranlation), put the tobe copied node in a variable and use <xsl:copy-of select="$var"/> where ever needed.
If it isn't make sense, please give your problem with code. I will try to answer..