Adding an XMLDocument as a child to another Element

Hello everyone,
I am trying to add an XMLDocument as a child to an existing
element. Here's an example:
import org.w3c.dom.*;
import java.util.*;
import java.io.*;
import java.net.*;
import oracle.xml.parser.v2.*;
public class ggg {
public static void main (String [] args) throws Exception
new ggg().doWork();
public void doWork() throws Exception {
XMLDocument doc1 = new XMLDocument();
Element root1=doc1.createElement("root1");
XMLDocument doc2= new XMLDocument();
Element root2=doc2.createElement("root2");
root1.appendChild(root2);
doc1.print(System.out);
This reports:
D:\Temp\Oracle\sample>c:\jdk1.2.2\bin\javac -classpath
D:\Temp\Oracle\lib\xmlpar
serv2.jar;. ggg.java
D:\Temp\Oracle\sample>c:\jdk1.2.2\bin\java -classpath
D:\Temp\Oracle\lib\xmlpars
erv2.jar;. ggg
Exception in thread "main" java.lang.NullPointerException
at
oracle.xml.parser.v2.XMLDOMException.<init>(XMLDOMException.java:
67)
at
oracle.xml.parser.v2.XMLNode.checkDocument(XMLNode.java:919)
at oracle.xml.parser.v2.XMLNode.appendChild(XMLNode.java,
Compiled Code)
at
oracle.xml.parser.v2.XMLNode.appendChild(XMLNode.java:494)
at ggg.doWork(ggg.java:20)
at ggg.main(ggg.java:12)
Ideas?
Razvan
null

Paul FitzPatrick (guest) wrote:
: Oracle XML Team wrote:
: : Razvan Dragomirescu (guest) wrote:
: : : Hello everyone,
: : : I am trying to add an XMLDocument as a child to an existing
: : : element. Here's an example:
: : : import org.w3c.dom.*;
: : : import java.util.*;
: : : import java.io.*;
: : : import java.net.*;
: : : import oracle.xml.parser.v2.*;
: : : public class ggg {
: : : public static void main (String [] args) throws
: : Exception
: : : new ggg().doWork();
: : : public void doWork() throws Exception {
: : : XMLDocument doc1 = new XMLDocument();
: : : Element root1=doc1.createElement("root1");
: : : XMLDocument doc2= new XMLDocument();
: : : Element root2=doc2.createElement("root2");
: : : root1.appendChild(root2);
: : : doc1.print(System.out);
: : : This reports:
: : : D:\Temp\Oracle\sample>c:\jdk1.2.2\bin\javac -classpath
: : : D:\Temp\Oracle\lib\xmlpar
: : : serv2.jar;. ggg.java
: : : D:\Temp\Oracle\sample>c:\jdk1.2.2\bin\java -classpath
: : : D:\Temp\Oracle\lib\xmlpars
: : : erv2.jar;. ggg
: : : Exception in thread "main" java.lang.NullPointerException
: : : at
: : : oracle.xml.parser.v2.XMLDOMException.<init>
: : (XMLDOMException.java:
: : : 67)
: : : at
oracle.xml.parser.v2.XMLNode.checkDocument(XMLNode.java:919)
: : : at oracle.xml.parser.v2.XMLNode.appendChild
: : (XMLNode.java,
: : : Compiled Code)
: : : at
: : : oracle.xml.parser.v2.XMLNode.appendChild(XMLNode.java:494)
: : : at ggg.doWork(ggg.java:20)
: : : at ggg.main(ggg.java:12)
: : : Ideas?
: : : Razvan
: : You need to use the DocumentFragment class to do this as a
: : document cannot have more than one root.
: : Oracle XML Team
: : http://technet.oracle.com
: : Oracle Technology Network
: Actually, isn't this specifically a problem with appending a
node
: created in another document, since all nodes contain a
reference
: to the document they are created in? While DocumentFragment
: solves this, it isn't a more than one root problem, is it?
BTW,
: is there a quick/easy way to convert com.w3c.dom.Document to
: com.w3c.dom.DocumentFragment?
Oops, make that org.w3c . . .
null

Similar Messages

  • Refer to another element in xml schema

    Hello
    i havea very basic question.
    i am writing an xml schema. I'd like to ask that what should i do if i want to create an element which refers to another element within the same xml file.
    Regards,
    Beans

    <xs:schema>
    <xs:element name="A">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="B"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="B"/>
    </xs:schema>

  • Adding a JPanel from one class to another Class (which extends JFrame)

    Hi everyone,
    So hopefully I go about this right, and I can figure out what I'm doing wrong here. As an exercise, I'm trying to write a Tic-Tac-Toe (TTT) game. However, in the end it will be adaptable for different variations of TTT, so it's broken up some. I have a TTTGame.java, and TTTSquareFrame.java, and some others that aren't relavent.
    So, TTTGame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              addPanel = startSimple();
              if(!addPanel.isValid())
                   System.out.println("Something's wrong");
              contents.add(addPanel);
              setSize(300, 300);
              setVisible(true);
         public JPanel startSimple()
              mainSquare = new TTTSquareFrame(sides);
              mainSquarePanel = mainSquare.createPanel(sides);
              return mainSquarePanel;
    }and TTTSquareFrame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.Misc;
    public class TTTSquareFrame
         private JPanel squarePanel;
         private JButton [] squares;
         private int square, index;
         public TTTSquareFrame()
              System.out.println("Use a constructor that passes an integer specifying the size of the square please.");
              System.exit(0);
         public TTTSquareFrame(int size)
         public JPanel createPanel(int size)
              square = (int)Math.pow(size, 2);
              squarePanel = new JPanel();
              squarePanel.setLayout(new GridLayout(3,3));
              squares = new JButton[square];
              System.out.println(MIN_SIZE.toString());
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setRolloverEnabled(false);
                   squares[i].addActionListener(bh);
                   //squares[i].setMinimumSize(MIN_SIZE);
                   squares[i].setVisible(true);
                   squarePanel.add(squares[i]);
              squarePanel.setSize(100, 100);
              squarePanel.setVisible(true);
              return squarePanel;
    }I've successfully added panels to JFrame within the same class, and this is the first time I'm modularizing the code this way. The issue is that the frame comes up blank, and I get the message "Something's wrong" and it says the addPanel is invalid. Originally, the panel creation was in the constructor for TTTSquareFrame, and I just added the mainSquare (from TTTGame class) to the content pane, when that didn't work, I tried going about it this way. Not exactly sure why I wouldn't be able to add the panel from another class, any help is greatly appreciated.
    I did try and cut out code that wasn't needed, if it's still too much let me know and I can try and whittle it down more. Thanks.

    Yea, sorry 'bout that, I just cut out the parts of the files that weren't relevant but forgot to compile it just to make sure I hadn't left any remnants of what I had removed. For whatever it's worth, I have no idea what changed, but something did and it is working now. Thanks for your help, maybe next time I'll post an actual question that doesn't somehow magically solve itself.
    EDIT: Actually, sorry, I've got the panel working now, but it's tiny. I've set the minimum size, and I've set the size of the panel, so...why won't it respond to that? It almost looks like it's being compressed into the top of the panel, but I'm not sure why.
    I've compressed the code into:
    TTTGame.java:
    import java.awt.*;
    import javax.swing.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              mainSquare = new TTTSquareFrame(sides.intValue());
              contents.add(mainSquare);
              setSize(400, 400);
              setVisible(true);
    }TTTSquareFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class TTTSquareFrame extends JPanel
         private JButton [] squares;
         private int square, index;
         private final Dimension testSize = new Dimension(50, 50);
         public TTTSquareFrame(int size)
              super();
              square = (int)Math.pow(size, 2);
              super.setLayout(new GridLayout(size, size));
              squares = new JButton[square];
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setMinimumSize(testSize);
                   squares[i].setVisible(true);
                   super.add(squares[i]);
              setSize(200, 200);
              setVisible(true);
    I've made sure the buttons are smaller than the size of the panel, and the panel is smaller than the frame, so...
    Message was edited by:
    macman104

  • TS4036 I added Icloud to join my calendar to another person. It erased all history date from previous months. how do I get that data back?

    I added Icloud to join my calendar on my phone to another person. It erased all history date from previous months. how do I get that data back?

    i found the answer to the first part: reboot and keep hold of command+r
    this gave me a list of options
    one of them was to reinstall lion from fresh
    i went for this
    dont know why... but all forum posts i read said u should delete hard disc? theres an option for this
    which is the right option?
    any suggesstion where i go to register new mac would be great
    thanks

  • Adding the unique validation on child vo attribute

    Hi, I'm using Jdev 11.1.2.0 I have two tables, master child relationship. In master EO1, I have column Master_Id and in child EO2, I have columns Master_Id, child_id, child_name. i have created the assosiations in beteween EO1 and EO2 with the column Master_Id. and creatd vo's and viewlinks also. and when i drag and drop the master vo and child vo on to the page, if i select master vo first row, the correspodning child records are displayed perfectly. Now I want to apply the unique validation on the child vo columns  child_id and child_name. like Child vo data;
    Master_Id 
    Child_Id 
    Child_name
    1
    1
    A
    1
    2
    B
    1
    3
    C
    2
    1
    A
    2
    2
    B
    2
    3
    C
    if I select 1 in master table, then in child table if i create a row and inserting the data, it should check for the duplicate data is there or not under that master_id. I did adding the Custom attribute validation on EO level, like checking the value is existed in the given rowset or not. Instead of adding this custom attibute validation, is there any other way to do it on the EO attribtue level, like  selecting the generate unique key constraint. Any suggestion would be appreciated. Thanks.

    In this car you only can validate using have methods or groovy.  Read http://docs.oracle.com/middleware/1212/adf/ADFFD/bcrules.htm#CIHBBDDB for more info about this.
    However, if you have the relationship you should have the pk fk too.
    Timo

  • Adding jsf page from a project to another?

    Hi,
    I use ADF 11g and i want to add a jsf page which is from another project to the second page.
    How can i import the first page to the second jsf page which is in another project?
    Thank you

    Hey BaiG,
    Ur right but......
    As a developer the universal saying is copy paste.. but have a thing in mind that, Be confident on the thing which u copy paste....... :)
    then not in even future, ever u wont face any difficulty in life...... am i right BaiG ??????? :)
    Hey BaiG : wht abt this forum u never replied
    Set ADF form in insert mode
    Regards,
    Suganth.G

  • Adding CheckBox and Text as child of a tree

    I want to have the following as the child of a tree :
    **CheckBox[reference of CheckBox]+some text
    example:
    checkbox text1
    checkbox text2
    checkbox text3
    I am unable to add both check box and text as the child of the tree.
    My nodes are generated at run time so number of checkboxes will be known only at run time.
    plz tell how can i achieve this functionality.
    thanx

    Just a small hint (The checkbox is not working yet - but shown):
    import java.awt.Component;
    import javax.swing.JCheckBox;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultTreeCellRenderer;
    public class CheckboxTreeRenderer extends DefaultTreeCellRenderer {
         @Override
         public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                                     boolean sel, boolean expanded,
                                                                     boolean leaf, int row, boolean hasFocus) {
                   JPanel p = new JPanel();
                   p.add(new JCheckBox("Hallo " + row));
                   p.add(new JLabel(value.toString()));
                   return p;
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    public class CheckboxTreeFrame extends JFrame {
         public CheckboxTreeFrame(){
              super("A Checkboxtree");
              JTree t = new JTree(new String[]{"1", "2", "3"});
              t.setCellRenderer(new CheckboxTreeRenderer());
              JScrollPane p = new JScrollPane(t);
              add(p, BorderLayout.CENTER);
         public static void main(String [] args){
              CheckboxTreeFrame tf = new CheckboxTreeFrame();
              tf.setSize(200,300);
              tf.setDefaultCloseOperation(EXIT_ON_CLOSE);
              tf.setVisible(true);
    }

  • Flash - go to another "child" in another scene

    Hi everyone,
    I've got 3 scenes, in every scene is one layer (parent), in every layer (parent in scenes) is one more layer (child), here is for example 5 layers. In every scenes, I have got menu with 3 url to scene.
    Example:
    Scene 1: I roll out menu, I choose url 1, show scene 1, frame 2 (child).
    pietro1.gotoAndStop(2);
    I roll out menu, I choose url 2, show scene 2, frame 1 (child).
    gotoAndStop(1, "Scena 2");
    I'm in link 2(Scene 2), I want to back to: Scene 1, layer 1 (parent), frame 2 (child)
    Example in image: http://bankfotek.pl/image/1786428
    How can I do it?

    It's probably more reliable to do something like:
    stage.addEventListener(Event.ADDED_TO_STAGE, checkforChild, true);
    gotoAndStop(1, "Scena 1");
    function checkForChild(e:Event):void {
         if (DisplayObject(e.target).name=='pietro1') {
              //no need to do this anymore
              stage.removeEventListener(Event.ADDED_TO_STAGE, arguments.callee, true);
              var mc:MovieClip = e.target as MovieClip;
              if (mc) {
                   mc.goToAndStop(2);
    You may also want to try just changing the symbol type of the instance on stage to "graphic" and set it to "Single Frame" Frame 2. The below is set to frame 1 but you get the idea:

  • Application Path Member will be deleted after adding a new Application Path Member in another Application Path List

    I expirienced the behaviour that the first item in the Application Path Member from a Application Path List will be deleted as far as the first item in the Application Path Member List will be selected in anather Application Path List without saving. This is according to severals peripherals as well.
    Example:
    Configuration Manager > Application Path List
    In the Application Path List "McalMediaRouting" the following Application Path Members are configured.
    For this example, the first Media Routing Domain for the Peripheral is Chat.
    Now, adding a new Application Path Member for the Application Path List "SiebelMediaRouting" with a new Media Routing Domain, which is not yet assigned to a Application Path List.
    Select the same Peripheral PG1A_CCM and choose the new MediaRouting from the list. At this point the Application Path Memeber with the Media Routing Domain "Chat" will be deleted in the Application Path List "McalMediaRouting". This will be deleted even without saving it.
    UCCE Version 9.0.2 used.
    Is this per design or is this a defect?
    Kind regards
    David

    HI
    add that fileds in the all locations where you need it like
    in internal table declaration , write statement , select statement
    these are the main areas where you have to add that 2 fileds

  • Check if element node exists then create another element

    Hi Everyone,
    I have element node in the Target structure. I need to create another node if 1st node has been created.
    Please let me know how should I do it.
    Thanks
    NPrabhu

    Hi,
    I need another node to occur.
    I need to check if item in the target is created. If yes then create item[1].
    Also I need to add another item above each item node to say which text it is.
    <ENGLISH_TEXTS>
       <item>
         <LINE>Catalog text jasdkajdlsk;k;</LINE>
       </item>
       <item>
         <LINE>ProductText asasdklkf;sdlfs' </LINE>
       </item>
    </ENGLISH_TEXTS>
    I want it to look like this
    <ENGLISH_TEXTS>
       <item>
         <LINE>Catalog text</LINE>
       </item>
       <item>
         <LINE>Catalog text jasdkajdlsk;k;</LINE>
       </item>
       <item>
         <LINE>Product text </LINE>
       </item>
       <item>
         <LINE>ProductText asasdklkf;sdlfs' </LINE>
       </item>
    </ENGLISH_TEXTS>
    Thanks

  • Function module to find the child of WBS elements

    Hi,
    i need to find the KSTAR (Cost Element) for the corresponding WBS element . If the particular WBS element does not contain the COST Element, then to find all the children WBS element .
    I need to find all the child WBS elements and its level for the parent WBS element. I am using the table COSB and PRPS table . kindly solve to find a FUNCTIONAL MODULE which uniquely  the child WBS element. Kindly help to solve.

    Hit the PRPS table where STUFE(Level in Project Hierarchy) > Current level and project Id = Current project ID.
    Hope it helps.
    Reward if it is useful.
    Thanks,
    Srinivas

  • Adding music from I-pod to Adobe Photoshop Elements 5.0 slideshow

    Trying to put together slideshow for present to teacher from class. Using Adobe Photoshop Elements 5.0. Would like to use some songs purchased from I-Tunes and some that I have added to my I-pod from personal CD collection. Having trouble adding them to the "audio" section of the slideshow. Any easy suggestions?

    You're on the wrong forum. Post on the PSElements specific forum.
    Mylenium

  • Another Elements 5 problem

    After elements 5 opens,  I immediately get a screen saying that windows must close to avoid damage, and it does so. It had worked with no problems for a long time. I am running Windoews XP and added no new programs before the problem started, but there may have been some automatic upgrades. However, I am running the same software on my work computer and have no problems. I have tried the obvious like uninstalling and re-installing. Does anyone have any suggestions? Thanks

    I presume you are posting this question here about Windows closing because it doesn't happen with other programs, only with PSE.
    There are a number of things that could cause the problem, some of them are hardware, and some of them are software. I tend to think that crashes like this are hardware; nevertheless, here are some software things you can try: http://www.johnrellis.com/psedbtool/photoshopelements-6-7-faq.htm#_Troubleshooting_Editor_ crashes

  • Get a symbol follow another element's position

    Hello!
    I would like to do something pretty simple, via the code.
    I have a symbol. Inside this symbol I have a simple rectangle, which is animated on the Y position (so basically just an "up and down" loop animation).
    On the stage, I also have another symbol, and I want this one to follow the Y position of the rectangle inside the first symbol.
    So basically: my 1st symbol don't move, but the rectangle inside of it does, and I want the 2nd symbol to move as the rectangle.
    Is it possible? I really don't know where to put this code, and which code to use...
    Thanks!

    Thank you for your answer!
    Right now what makes the leader moving is a simple loop animation inside the symbol (not in the main timeline), just up/down movement. Is it different if the movement is causes by the code?
    Actually I want it to be practical, which means that I could change the movement of the leader if I want to, the follower will follow anyway. I don't think I would move the leader by code but I may so... If this is an important point I should decide now I guess!
    I'm not really a coder... So if you have some time to write something for me, I would really appreciate it!
    Let's say my first symbol is called crow_01 (leader), my second is called crow_02 (follower), and the movement is done by symbol's timeline animation (let's put the movement by code aside for now).
    Thank you very much!

  • Adding a border to a photo  in photoshop elements 6.0

    Please could someone tell me how to add a border to any photo in elements 6, choose the colour, alter the width and also add text to the border, which would be wider at the bottom of the picture in some situations.
    Photoshop elements is useless for "help"!
    Many thanks.

    Mark,
    1. To add border:
    Select>all
    Edit>stroke
    Enter width, color, location:inside
    2. To add text, access the horizontal type tool. The text can be positioned by dragging, and with the move tool, since it is on its own layer.
    If you want to add text below the picture, you need to extend the canvas. Go to Image>resize canvas size. Try 15% (experiment), be sure relative is checked, and click on the anchor point in the 12 o'clock position. Then engage the type tool.
    HTH,
    Ken

Maybe you are looking for

  • Storing some filenames in an array in loop

    Hi , I am getting some file names in a loop like this: File aDirectory = new File("Data/");          File[] files = aDirectory.listFiles();          //String fileret = null;          for(File file : files){               String file1 = "Data/"+file.g

  • Safely getting rid of unused fonts

    I just replaced my hard drive and with that came the latest OSX version and I noticed in fontbook that out of the 182 fonts installed in the standard OSX install 109 are not english fonts -- I'm never going to use these non- english fonts but having

  • Regarding bar code scanning

    Hi Gurus, I have one requirement. After scanning the barcode, that barcode value is populating in the selection screen of a program. My requirement is, after the value is filled in selection screen by barcode scanning, the report has to be executed a

  • How do I calculate the difference between two times?

    I am so embarrassed by the fact that I can't figure this out. Cell B2- 8:00 am Cell C2- 10:50 am Cell D2- (How do I get this cell to calculate the difference and say 2:50?) I know this is probably one of the most basic operations, but for the life of

  • Export web catalog OBIEE Answers

    Hi, I have created an rpd in Administration Tool on machine Windows. Then in Answers I have created any reports based on rpd definition and all works. Now, I've copied my rpd on another machine (Unix), but when I log in Answers I see the cataloue and