Subject: Re: [xsl] Inserting a file into another From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 21 Mar 2001 18:02:24 +0000 |
Hi Robert, > I have one xml file that I would like to insert into another XML > file. How do I do this? In your sample, you have an element called Insert_other_file_here. When you find that element, you want to insert a copy of the content of b.xml. You can get hold of b.xml through the document() function: document('b.xml') And you can make a copy of its content with xsl:copy-of: <xsl:copy-of select="document('b.xml')" /> You can match Insert_other_file_here with a template, so that when the element is encountered, the document is copied in its place: <xsl:template match="Insert_other_file_here"> <xsl:copy-of select="document('b.xml')" /> </xsl:template> For all other elements in a.xml, you just want to insert a copy of that particular element (and presumably its attributes) and then move on to process its content. You should probably use the identity transform for this, i.e.: <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> This matches any node, copies the node, then applies templates to the attributes and children of the node... which are matched by the template, which copies the node, then applies templates to the attributes and children of the node... which are matched by the template... and so on recursively down the tree. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Inserting a file into another, Robert . Searle | Thread | [xsl] [XSLT] [Q] Recursion Question, Jonathan Calvert |
Re: [xsl] How to display XML data p, Jeni Tennison | Date | [xsl] [XSLT] [Q] Recursion Question, Jonathan Calvert |
Month |