Can I append an XML Document into another?

I have a large xml document which I open into coldfusion (mx
7), and then a smaller group of files that are opened into thier
own xml objects. After some customization of xml text values, I
want to append the smaller xml documents into the larger document
at specific positions within the document tree.
I have the code that I thought would do this, using an
arrayappend function, but what happens is that only the root
element of the smaller (inserted) xml document is placed into the
main document.
Is this possible, or do I need to modify the code so that the
entire tree of xml data that I am appending is created on the
fly?

Personally I do this with XSLT.
<cfxml variable="doc1">
<root>
<member id="10">
<name>Ian</name>
<sex>male</sex>
</member>
</root>
</cfxml>
<cfxml variable="doc2">
<root>
<member id="1">
<name>Joe</name>
<sex>male</sex>
</member>
<member id="2">
<name>John</name>
<sex>male</sex>
</member>
<member id="3">
<name>Sue</name>
<sex>female</sex>
</member>
</root>
</cfxml>
<cffile action="write" file="#expandPath("/")#\doc2.xml"
output="#ToString(doc2)#" nameconflict="overwrite">
<!--- METHOD ONE using a depreciated and undocumented
method --->
<cfset newNode = doc1.root.member.cloneNode(true)>
<cfset doc2.changeNodeOwner(newNode)>
<cfset doc2.root.appendChild(newNode)>
<cfdump var="#doc2#" label="Merged by hidden functions"
expand="no">
<!--- METHOD TWO using XSLT --->
<!--- create an xsl docutment--->
<cfoutput>
<cfsavecontent variable="transformer">
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>
<!--load the merge file -->
<xsl:variable name="emps"
select="document('#expandPath("/")#\doc2.xml')"/>
<!--- this line references and XML file to be combined
with the main file,
I wonder if there is a way to use an XML document in memory
here? --->
<!-- combine the files -->
<xsl:template match="/">
<root>
<!-- select all the child nodes of the root tag in the
main file -->
<xsl:for-each select="root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
<!-- and all the child nodes of the root tag in the merge
file -->
<xsl:for-each select="$emps/root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
</cfsavecontent>
</cfoutput>
<!--- create a combined xml document --->
<cfset doc2 = XMLparse(XMLtransform(doc1,transformer))>
<cfdump var="#doc2#" label="Merged by XSLT"
expand="no">

Similar Messages

  • How to insert one XML document into another

    Hi,
    I've been working on a simple CMS.
    There is a main template that is just a HTML page. The main template has a few extra 'module' tags that indicates places where individual modules have to be placed.
    main template: template.xml
    <html>
    <body>
    <div>
    <module id="centre"/>
    </div>
    </body>
    </html>module template: module_centre.xml
    <div>
    <a>This is a MODULE and it may be much more complex</a>
    <div>My application has to detect every 'module' tag from the template.xml and insert there XML content from a proper module template.
    The result file has to be generated dynamically on a request. The structures of 'modules' can be only defined in module_*.xml files.
    The expected result
    <html>
      <body>
        <div>
            <div>
                <a>This is a MODULE and it may be much more complex</a>
            <div>
        </div>
      </body>
    </html>What's the best practice do solve this case?
    Pawel

    I think I've came up with a better solution.
    SRC file
    <?xml version="1.0" encoding="utf-8"?>
    <html>
      <head>
        <title></title>
        <style type="text/css">
    div.c4 {background-color:pink;width:400px;height:50px}
    div.c3 {background-color:green}
    div.c2 {background-color:blue;width:400px;height:299px}
    div.c1 {background-color:red}
    </style>
      </head>
      <body>
      <module id="XXX"/>
        <div id="main" class="c3">
          <div id="top" class="c1"><module id="menu_test"/></div>
          <div id="bottom" class="c2"><module id="menu_test2"/></div>
        </div>
        <div id="footer_container" class="c4">    <module id="menu_footer"/></div>
      </body>
    </html>MODULE src file
    <?xml version="1.0" encoding="UTF-8"?>
    <div id="admin_panel_module" style="background-color:orange;width:200px;height:50px">
        <p>Control Panel TEST</p>
    </div> @param source  -  NODES from MODULE document
    *@param target - TEMPLATE document where MODULES are going to be inserted*
    @throws Exception
    public static void insertModules(Node source, Document target) throws Exception {
    Node importedNodes = target.importNode(source, true);
    // Use XPath to find all 'module' nodes in ''
    XPath xpath = XPathFactory.newInstance().newXPath();
    NodeList nodes = (NodeList) xpath.evaluate("//module", target, XPathConstants.NODESET);
    // Remove MODULE node and insert there an XML content from MODULE template
    for (int idx = 0; idx < nodes.getLength(); idx++) {
    Node editedModuleElement = nodes.item(idx);
    // parent of module mode
    Node parentNode = editedModuleElement.getParentNode();
    // replace <module/> node with imported nodes from 'module' XML document
    parentNode.replaceChild(importedNodes, editedModuleElement);
    // nodes.item(idx).appendChild(node);
    importedNodes = target.importNode(source, true);
    }Edited by: maestr0 on May 24, 2010 12:44 AM

  • How can I [cmd]+A including text boxes? Or how to import one Pages document into another Pages document?

    Hi there,
    I am working on my thesis with several Pages documents (for the first time). And I really have searched all over the Internet to find an answer to exactly my question but I cannot find it.
    First my question was: How can I import one Pages document into another one? I found the answer on that (I think) and there is nothing else than just make a new section and copy/paste it in.
    But then another issue pops up: I cannot [cmd]+A my whole document including the texboxes to paste it in the other Pages document. Then the document will be paste without the textboxes (and I have quite a lot of them in that document) and the text will not be at the right place.
    So please explain to me: How I can combine two Pages documents and keep them exactly the way they are? Is that even possible?
    I thank you so much in advance!

    Hi Fruhulda,
    I have already tried to mark the textboxes in line but that did not work, and besides then the text and the boxes won't be at the rigt places either. Thank you for your reply .

  • How to insert a pages document into another pages document?

    How can I insert a pages document into another one?
    How can I insert 1 page of a document into another document?

    Open your files & show thumbnails. Sections have a yellow border around all of the pages in that section. Now click on the page in the thumbnail pane & copy. If the file is more than one page & you only want one, you'll need to insert a section break to separate the pages. Then go to your other file, click in the thumbnail pane & paste. The whole copied page will be pasted in. Repeat with another section. Styles will copy over with the sections but headers & footers will not.

  • How can I import an XML DOM document into another?

    Dear all,
    I'm using the following bit of code:
         public static Node replaceNode(Document replacedDocument,
                        Document replacingDocument,
                        Node replacedNode)
         //Create a documentFragment of the replacingDocument
         DocumentFragment docFrag = replacingDocument.createDocumentFragment();
         Element rootElement = replacingDocument.getDocumentElement();
         docFrag.appendChild(rootElement);     
         //Import docFrag under the ownership of replacedDocument
         Node replacingNode =
         ((replacedDocument).importNode(docFrag, true));
              //In order to replace the node need to retrieve replacedNode's parent
         Node replaceNodeParent = replacedNode.getParentNode();
         replaceNodeParent.replaceChild(replacingNode, replacedNode);
         return replacedDocument;
    to import a DOM document into another DOM document, so that it converts something like this:
    <?xml= .... etc>
    <Data></Data
    to:
    <?xml= .... etc>
    <Data>
    <Yellow>Butter</Yellow>
    <White>Marzipan</White>
    </Data>
    Instead, what it is doing is:
    <?xml= .... etc>
    <Yellow>Butter</Yellow>
    <White>Marzipan</White>
    I know that it is stripping out the <Data> elements because of the call to the replaceChild
    function, after getting the element's parent, but if I change
    Node replaceNodeParent = replacedNode.getParentNode();
    to
    Node replaceNodeParent = replacedNode;
    I get an error about node node being accessible.
    Please help!
    Paul

    http://forum.java.sun.com/thread.jsp?forum=34&thread=208596

  • To load an XML document into 40 tables

    How do I load a large XML document into 40 tables. Most of the exmaples, I see only load one table into the Orcale database?

    From the above document:
    Storing XML Data Across Tables
    Question
    Can XML- SQL Utility store XML data across tables?
    Answer
    Currently XML-SQL Utility (XSU) can only store to a single table. It maps a canonical representation of an XML document into any table/view. But of course there is a way to store XML with the XSU across table. One can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (object views if needed) and then do the inserts ... into the view. If the view is inherently non-updatable (because of complex joins, ...), then one can use INSTEAD-OF triggers over the views to do the inserts.
    -- I've tried this, works fine.

  • Got error message when store XML documents into XML DB repository, via WebD

    Hi experts,
    I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
    I got error message when store XML documents into XML DB repository, via WebDAV.
    I have successfully registered 5 related schemas and generated 1 table.
    I have inserted 40 .xml files into this auto generated table.
    using these data I created relational view successfully.
    but since I couldn't store XML documents into XML DB repository, via WebDAV
    when I query using below code:
    SELECT rv.res.getClobVal()
    FROM resource_view rv
    WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
    I got nothing.
    My ftp code is listed below:
    ftp> open localhost 2100
    Connected to I0025B368E2F9.
    220- C0025B368E2F9
    Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
    220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
    User (I0025B368E2F9:(none)): fda_xml
    331 pass required for FDA_XML
    Password:
    230 FDA_XML logged in
    ftp> cd /home/DEV/message
    250 CWD Command successful
    ftp> pwd
    257 "/home/DEV/message" is current directory.
    ftp> ls -la
    200 PORT Command successful
    150 ASCII Data Connection
    drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
    drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
    226 ASCII Transfer Complete
    ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
    250 SET_CHARSET Command Successful
    ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
    200 PORT Command successful
    150 ASCII Data Connection
    550- Error Response
    ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
    550 End Error Response
    ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
    I have tried all suggestion from another thread such as:
    alter system set events ='31150 trace name context forever, level 0x4000'
    SQL> alter system set shared_servers = 1;
    but failed.
    is there anyone can help?
    Thanks.
    Edited by: Cow on Mar 29, 2011 12:58 AM

    Hi experts,
    I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
    I got error message when store XML documents into XML DB repository, via WebDAV.
    I have successfully registered 5 related schemas and generated 1 table.
    I have inserted 40 .xml files into this auto generated table.
    using these data I created relational view successfully.
    but since I couldn't store XML documents into XML DB repository, via WebDAV
    when I query using below code:
    SELECT rv.res.getClobVal()
    FROM resource_view rv
    WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
    I got nothing.
    My ftp code is listed below:
    ftp> open localhost 2100
    Connected to I0025B368E2F9.
    220- C0025B368E2F9
    Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
    220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
    User (I0025B368E2F9:(none)): fda_xml
    331 pass required for FDA_XML
    Password:
    230 FDA_XML logged in
    ftp> cd /home/DEV/message
    250 CWD Command successful
    ftp> pwd
    257 "/home/DEV/message" is current directory.
    ftp> ls -la
    200 PORT Command successful
    150 ASCII Data Connection
    drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
    drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
    226 ASCII Transfer Complete
    ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
    250 SET_CHARSET Command Successful
    ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
    200 PORT Command successful
    150 ASCII Data Connection
    550- Error Response
    ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
    550 End Error Response
    ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
    I have tried all suggestion from another thread such as:
    alter system set events ='31150 trace name context forever, level 0x4000'
    SQL> alter system set shared_servers = 1;
    but failed.
    is there anyone can help?
    Thanks.
    Edited by: Cow on Mar 29, 2011 12:58 AM

  • Existing XML documents into KM

    Hello Everyone
    Is there a way to load existing xml documents into KM and then maintain them using xml forms built using the form builder. Any help is greatly appreciated.
    Thanks
    Swetha

    Hi Renuka
    You can move the XML projects from one server  to another.The Xml forms created is stored in the path 'etc\xmlforms' in KM. You can send it out and Upload to the target server instead of creating the same in the Target server from the scratch.
    Regards
    Geogi

  • JTextPane: Insert one (part of) a Document into another

    Hi,
    I am writing a small programm which user a JTextPane and a
    StyledDocument with
    an RTFEditorKit.
    Now I have the problem that I want to get one Document, transport it
    over
    a network and insert it into another Document.
    The only method in Document to insert sth needs a string but I have a
    Document.
    So my question is: How can I insert one Document into another or at
    least append
    one Document to another?
    Thanks
    Frank

    Hi, it is much more simpler than i thaught.
    use the getLength method of the Document-Interface.
    e.g.:
                    InputStream in1; // Streams of your Files
         InputStream in2; // Streams of your Files
         RTFEditorKit rtf = new RTFEditorKit();
         Document doc = rtf.createDefaultDocument();
         try{
             rtf.read(in1, doc,0);
             int x = doc.getLength();
             rtf.read(in2,doc,x);
         }catch(BadLocationException ble){
         }catch(IOException ioe){
         }use this value in the read-method as pos and your second doc is concated to the first.
    Or any other pos you like.
    Hope this is what you are lokking for.
    Greetings Michael
    read
    public void read(InputStream in,
                     Document doc,
                     int pos)
              throws IOException,
                     BadLocationException
        Insert content from the given stream which is expected to be in a format appropriate for this
        kind of content handler.
        Overrides:
           read in class DefaultEditorKit
        Parameters:
           in - The stream to read from
           doc - The destination for the insertion.
           pos - The location in the document to place the content.
        Throws:
           IOException - on any I/O error
           BadLocationException - if pos represents an invalid location within the document.

  • How to ftp XML document into a XML type which is not created by itself.

    Hi,
    1.
    I have a table call SNPLEX_DESIGN which is created automaticly when I register a snplex_design.xsd XML schema.( Oracle creates it through the xdb:defaultTable="SNPLEX_DESIGN attribute). and it is created using SNPLEX user account.
    2.
    I also created a folder (resource) call /home/SNPLEX/Orders. which is used to hold all the incoming XML document.
    3.
    I created another user account call SNPLEX_APP, which is the only user account allowed to FTP XML document into /home/SNPLEX/Orders folder.
    Isuues,
    If I login as SNPLEX user, I can ftp XML document into the folder and TABLE (the file size = 0). But If I login as SNPLEX_APP user account, I can only ftp XML document into the folder, but Oracle doesn't store the document into the table( becuase the files size shows a number).
    I have granted all the ACL privileges on the /home/SNPEX/Orders folder to SNPLEX_APP hrough OEM.
    DO I miss anything. Any helps will be great appreciated. Resolve this issues is very import to us, sicne we are on a stage to roll system into production.
    Regards,
    Jinsen

    IN order for a registered schema to be available to other users the schema must be registered as a GLOBAL, rather than a LOCAL Schema. This is controlled by the third agument passed to registerSChema, and the default is local. Note that you will also need to explicity grant appropriate permissions on any tables created by the schema registration process to other users who will be loading or reading data from these tables.

  • How to Append two  word documents into single  using   java

    How to Append two word documents into single using java
    we tried this but it's not append the one word document to other
    source code:public class AppendTwoWordFiles {
         public static void main(String []arg)throws IOException
              FileInputStream fi=null;
              FileOutputStream fo=null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                   File f1=new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2=new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2,true);
                   byte b[]=new byte[2];
                   while((fi.read(b))!=-1);
              fo.write(b);
    System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
              fi.close();
              fo.close();
    plz reply me quickly ,,,what can i follow

    Use this code ..
    and give the path of the both file like this.....
    source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
    destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
    import java.io.*;
    public class AppendTwoWordFiles {
         public static void main(String[] arg) throws IOException {
              FileInputStream fi = null;
              FileOutputStream fo = null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br = new BufferedReader(new InputStreamReader(
                             System.in));
                   File f1 = new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2 = new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2, true);
                   byte b[] = new byte[2];
                   int len = 0;
                   while ((len = fi.read(b)) > 0) {
                        fo.write(b, 0, len);
                   System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   fi.close();
                   fo.close();
    }

  • I dragged a cut out image from one photoshop document into another and now it is blurry. What to do?

    I dragged a cut out image from one photoshop document into another and now it is blurry. What can I do to prevent this?

    What is the resolution of the image that you "dragged"? The resolution is the number in pixels per inch (ppi). If you dragged a significantly lower resolution file into a higher resolution file, it could result in a blurry image.
    see below:
    For further reading of Key Concepts:
    http://www.adobe.com/designcenter-archive/keyconcepts/articles/concept_resolution.html
    You can determine the image size by choosing Image > Image Size
    below you can see the pixel dimensions of my example image.
    Resolution Basics:
    Adobe TV- http://tv.adobe.com/watch/creative-sweet-tv/photoshop-resolution-basics/
    http://tv.adobe.com/watch/visual-design/getting-started-09-resizing-an-image/
    Adobe Help:
    http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7945a.h tml
    -janelle

  • Insert One Word Document into another using OLE ABAP

    Hi,
    I want to insert one word document into another Word Document called by OLE ABAP.
    ie.first word document having 6 pages have been displayed and I want first page of
    second document as a 7th page.I want to dispaly the entire data in  one document.
    Hope to get the reply soon.
    Thanks & Regards,
    Divya.

    T.code :- DWDM
    u can check OLE and OFFICE INTEGRATION tree  have so many demo report
    Report :- RSOLETT1
    Edited by: Krupaji on Feb 18, 2010 2:00 PM

  • How to insert one document into another in microsoft word?

    I would like to set up a word document such that the document has embedded in it another document shrunk down a bit to make room for additional comments and information which I will add on the side. I've been looking to see if word 2007 has this feature
    but have had difficulty finding it. Is it possible to take an entire document and insert it as a resizeable object into another?
    Some of my research suggests that I might be able to accomplish something of this nature with publisher, and while several people in my office do not have publisher and we'd prefer if it were doable in word, instructions for publisher would be appreciated
    as well if Word 2007 cannot do this.

    Hi,
    Thank you for using 
    Word IT Pro Discussions
    forum. 
    From your description, I understand that 
    you would like to know to how to add a Word document into another Word document in Word 2007, and you can make some comments besides the embedded Word documents.
    If there is any misunderstanding, please feel free to let me know.
     Thank you for your inquiring.
    To insert a Word document to another Word document in Word 2007, follow the steps below:
    =========
    1.      
    In the Word document, click the
    Insert tab.
    2.      
    Click the
    Object in the Text group.
    3.      
    Click
    object. Then click the Create from file tab.
    4.      
    Click the
    Browse button to select the Word document. Also, check the checkboxes before:
    Link to file and Display as icon.
    5.      
    Click
    OK to save the settings.
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything I can do for
    you, please feel free to let me know.
    Best Regards,
    Sally Tang

  • Is it possible to insert a document into another?

    I would like to insert a document into another document without cutting and pasting. That is, to "insert" it into the present document. I have been unable to find that option. Is it possible?

    It would seem a logical function, though Pages is in essence a $30.00 program so it's not going to have all the features one might wish. You can submit feedback to Apple on the issue here, though:
    http://www.apple.com/feedback/pages.html
    Regards.

Maybe you are looking for