Anybody familiar with JDOM?

Hi,
I've been using jdom for some time now and I have been having problems with the following:
Element root = doc.getRootElement( );
List allChildren = root.getChildren( );
The List returned by the getChildren() call is a java.util.List, an implementation of the List interface all Java programmers know. What's interesting about the List is that it's live. Any changes to the List are immediately reflected in the backing document.:
allChildren.remove(3);
allChildren.add(new Element("jane"));
Somettimes the list returned by element.getChildren( ) or element.getContent( ) is empty (it should definietly not be empty). Does anybody know any possible reasons for this?

I am currently designing an xml-based shared text editor, where paragraphs of text are enclosed within <Paragraph> tags, then it is a matter of propagating XML elements to the users, rather than java strings.
The simple xml structure of the document is as follows. There is a <Doc> root element which contains many instances of <Paragraph> elements. These paragraph elements have textual content. The following is an example of how a new paragraph is added:
public void addElement ( int n, org.jdom.Element e, String s, boolean increment) {
e= new org.jdom.Element("Par");
e.setAttribute("id", String.valueOf(n+1));
e.setText(s);
     allPars = root.getChildren();
     allPars.add(n, e);
     if(increment == true){
     incrementAttributes(n+1);
     saveList(doc);
By sticking in print statements after allPars = root.getChildren( ), I have been getting empty lists even though the list should definitely not be empty. similar for deleteElement method and so on.
I have subsequently noticed that making the document and root element static has eliminated these problems although i had never been creating new instances of these anyway, strange.
static org.jdom.Element root = new org.jdom.Element("Doc");
static org.jdom.Document doc = new org.jdom.Document(root);

Similar Messages

  • Anybody familiar with the details of implementing the Adobe PDF virtual printer?

    Hello, all.
    We need to implement a virtual printer similar to the legendary one by Adobe. The images processed by it will be detailed CAD drawing.
    Can a kind soul point me in the appropriate direction? For starters: what type of data (what format) is the virtual printer expected to receive?
    This will be for Windows.
    TIA,
    -RFH

    Well... it isn't really a data format. A device driver (which includes a printer driver) provides a number of callbacks which correspond to the graphical calls made by a printing program. (At least, that's how it was when I looked into it a very long time ago). A driver might be asked to draw lines or boxes, to output text with particular fonts and attributes, or to accept a variety of raster graphics. This is something for an experienced programmer, or team, already very familiar with Windows graphic models such as GDI: device drivers are not easy to develop or debug, and because they run with special privileges; bugs in them have the potential to completely crash the system (blue screen of death) (although I read of something called "user mode drivers" which might be safer).
    http://msdn.microsoft.com/en-us/library/windows/hardware/gg463348.aspx is a place where some of this seems to be discussed. I don't know whether you have to sign up with Microsoft. You might, because recent OSs will only install signed drivers.
    Updated: if you still want to make a PDF, this is an enormous task, so big that Adobe dropped the two drivers they once had. Adobe don't even write the Adobe PDF driver. Rather, they use the operating system's PostScript driver, then convert PostScript to PDF using Distiller, a tool they conveniently already had. Adobe provide what I think is called a "print monitor" (?) that takes the output from the driver once it is fully formatted. If you can process PostScript you could do the same. (Note: a PostScript interpreter from scratch is a considerably larger task than a print driver, so that isn't an easy option; look at 5-10 person years if the people are sufficiently skilled).

  • Anybody familiar with the TUNE TRANSFER for Ipod program?

    This software product was created by Valu-Soft. It was designed to recover music files from iPod to a NEW PC. However, it appears that this program does not work with a PC that has already iTunes library. Are there any shortcuts or commands to circumvent this condition?

    Well... it isn't really a data format. A device driver (which includes a printer driver) provides a number of callbacks which correspond to the graphical calls made by a printing program. (At least, that's how it was when I looked into it a very long time ago). A driver might be asked to draw lines or boxes, to output text with particular fonts and attributes, or to accept a variety of raster graphics. This is something for an experienced programmer, or team, already very familiar with Windows graphic models such as GDI: device drivers are not easy to develop or debug, and because they run with special privileges; bugs in them have the potential to completely crash the system (blue screen of death) (although I read of something called "user mode drivers" which might be safer).
    http://msdn.microsoft.com/en-us/library/windows/hardware/gg463348.aspx is a place where some of this seems to be discussed. I don't know whether you have to sign up with Microsoft. You might, because recent OSs will only install signed drivers.
    Updated: if you still want to make a PDF, this is an enormous task, so big that Adobe dropped the two drivers they once had. Adobe don't even write the Adobe PDF driver. Rather, they use the operating system's PostScript driver, then convert PostScript to PDF using Distiller, a tool they conveniently already had. Adobe provide what I think is called a "print monitor" (?) that takes the output from the driver once it is fully formatted. If you can process PostScript you could do the same. (Note: a PostScript interpreter from scratch is a considerably larger task than a print driver, so that isn't an easy option; look at 5-10 person years if the people are sufficiently skilled).

  • Anybody familiari with Tibco Spotfire DXP

    Hi all,
    Next week we get a demo on a tool called Spotfire DXP from Tibco company. I donwloaded a trial version and it looks quit good but I have my doubts on implementing this tool for a SAP (BI) environment. As we will probably have Business Objects available for BI on short terms and next to this we have Adobe Flex for custom components that can be integrated in XCelsius, I wonder what kind of added value a tool like Spotfire could/would have in our situation. Does anybody have any experience with this tool?
    kind regards
    Angelique Heutinck

    I also found these documents but the contents doesn't help really me answering my question. Why should we buy Spotfire if we will have an expensive tool like Business Objects in place anyway? What can do Spotfire more than Business Objects can do? Charts and analysis features can also be created by Adobe Flex or by purchasing Flex component libraries. It will be more work in the beginning, but once the component is ready, it is reusable.
    There are many similar tools like Spotfire available on the market for data visualization (Tableau, Corda Technologies, Visual Mining, Advizor Solutions, just to name a few I found on the internet) but I cannot find good reasons from an IT point of view to buy an external software package other than that the frontend looks cool and with a simple flat excel sheet you can make beautiful pictures in just a few minutes (keeping in mind that data visualiztion in all products tours look "hot and sexy"). However, we talk about SAP BI and R3 data, data coming from other sources like Sybase, Notes. It will be quit a challenge to build the custom solutions we want for our company, no matter what choice we will make. How do these packages fit in the esoa concept, can this software work with e.g. webservices, can we integrate a Tibco dashboard in CRM2007 or Portal? What about version and transportation management?

  • Anybody generally familiar with laptop monitor sync ranges?

    After having been happy with arch linux on my desktop for almost 12 hours, I'm now configuring it for my laptop. I'm now working on my XFree86 configuration, and I've hit a snafu. I have no idea what the horizontal & vertical sync ranges ought to be. I never got any monitor documentation with my laptop, and the technical specifications provided by gateway (the manufacturer; not very OSS friendly hardware, and I wouldn't recommend it to anyone getting a new computer) (on the other hand, the boxes are very pretty) are a little bit lacking.
    Consequently, here is everything I can dig up. Is there anyone generally familiar with the kind of frequencies that modern laptop monitors can handle, who can give me a good idea of some values to use?
    We've got:
    15.0-inch active matrix (TFT) LCD color display
    Maximum panel resolution: 1024 × 768
    Maximum color depth: 32-bit (16.7 million colors)
    LCD supported video modes: XGA
    LCD maximum refresh rate: 60 Hz
    Thanks!

    my lcd-config looks like this:
    Section "Monitor"
    Option "CalcAlgorithm" "CheckDesktopGeometry"
    DisplaySize 305 230
    HorizSync 28-95
    Identifier "LCD"
    ModelName "FlexView 1600X1200"
    VendorName "IBM"
    VertRefresh 52-82
    # UseModes "Modes[0]"
    ModeLine "1600x1200/60Hz" 162 1600 1664 1856 2160 1200 1201 1204
    1250 +HSync +VSync
    Option "DPMS
    EndSection
    but the data i got from the manual, so it's not guessing but knowing
    you can try the refresh and sync rates i use  if nobody answers specific for your machine --- i know this settings work on 4 different lcd's for sure and never heard that they made trouble
    instead of the Modeline (i use), i suggest you to write modelines and then just include the Modes-section you wrote to the monitor section (the out-commented line i added)
    would be better you get other replys specific on your hardware - mine is more general, sorry

  • Transformation with JDOM (off-topic)

    Hi All,
    I am wondering if anyone could advice me on how to carry out transformation in a JDOM enviornment. I am familiar with querrying data using XPath with JDOM.
    Any tutorial or online reference material would be very much appreciated.
    I am running Netbeans 6.1, J2EE 5 Glassfish on Windows XP platform.
    Many thanks,
    Jack

    It contains the [org.jdom.transform|http://www.jdom.org/docs/apidocs/org/jdom/transform/package-summary.html] package with classes to do basic transformation. As the documentation says:
    Classes to help with transformations, based on the JAXP TrAX classes. JDOMTransformer supports simple transformations with one line of code. Advanced features are available with the JDOMSource and JDOMResult classes that interface with TrAX.

  • I am running on OSX 10.10.1 and have a 2009 imac intel and I am having severe latency issues.  I am not familiar with macs as this is my home computer used by other family members.  Any help on how to troubleshoot why such latency issues?

    I am running on OSX 10.10.1 and have a 2009 imac intel and I am having severe latency issues.  I am not familiar with macs as this is my home computer used by other family members.  Any help on how to troubleshoot why such latency issues?

    When you see a beachball cursor or the slowness is especially bad, note the exact time: hour, minute, second.  
    These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    Each message in the log begins with the date and time when it was entered. Scroll back to the time you noted above.
    Select the messages entered from then until the end of the episode, or until they start to repeat, whichever comes first.
    Copy the messages to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    The log contains a vast amount of information, almost all of it useless for solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    Some private information, such as your name, may appear in the log. Anonymize before posting.

  • HT1925 Currently have iTunes 11.0.1.12 - how do I restore a previous version of iTunes that was far easier to use (much more familiar with)?

    Currently have iTunes 11.0.1.12 - how do I restore a previous version of iTunes that was far easier to use (much more familiar with)?

    Apple is starting to feel like work and not play.

  • In logic Pro, when I open up an audio track and load an audio file, there is no sound. I will finally get a sound out of one of the audio tracks after opening at least 5 of them alternately. Is anyone familiar with this kind of bug? It's really frustratin

    In logic Pro, when I open up an audio track or software track and load an audio file/loop or software file loop, there is no sound. I will finally get a sound out of one of the audio or software tracks after opening at least 5 of them alternately. Is anyone familiar with this kind of bug? It's really frustrating as this takes much time to complete work.
    os x, Mac OS X (10.6)

    I'm not sure I follow your words Fuzzynormal. You've helped by offering the insight that my issue in Logic Pro 9 is not a bug but a feature. But fell short of enlightenment by being a judge of character and of how one should interact in this forum. You insinuate that I haven't tried to solve the issue on my own when in fact I have. These forums are always my last resort. You further suggest that I am complaining. This is not a complaint. It is a genuine issue that I cannot figure out. Then you think that Brazeca is holding my hand and being a nice guy. Brazeca is helping people like me who might not be as adept at using Logic Pro as probably you are.This community forum was established to raise questions, answers and dicussion to help Apple's customers better undertand their operating systems and related issues. You are doing a disservice by not contributing positively and by trying to make this forum what you want it to be. You may have all the time in the world to try figuring out stuff but we are not all like you. We all have different schedules and different levels of understanding. And that is what this forum is for - to help people move forward. If you can't contribute positively then keep silent. And by the way, you say to "read the words that are printed down to explain to you how that works" what words are you talking about? Why don't you be of some help instead of trying to own this forum. 

  • I am new to the MAC world but I am very familiar with Lightroom on a PC. This weekend I was weeding out the pics I do not want on my MAC and now I have a ? by all my folders.  How do I recover/get back to where I was 2 days ago?

    I am new to the MAC world but I am very familiar with Lightroom on a PC. This weekend I was weeding out the pics I do not want on my MAC and now I have a ? by all my folders.  How do I recover/get back to where I was 2 days ago?

    These instructions will help you fix the problem: Adobe Lightroom - Find moved or missing files and folders

  • XML validation with JDOM / JAXP

    Hello,
    I am trying to validate xml file against schema file. I decided to use JDOM and JAXP.
    First question: is it a good choice?
    I did a first attempt but not sure I have understood all what I am doing :(
    First I have create a parser usinf org.jdom.*
    SAXBuilder parser = new SAXBuilderThen I built my document:
    Document doc = parser.build(myFile)These 2 steps are ok. But it does not do validation.
    I saw in the JDOM documentation that I can set a validation flag to true. I did it. First problem, I got the following error from JDOMException: Document is invalid: no grammar found.
    Is there a way to specify to the parser where to find the xsd file?
    As I did not find answer to this question by myself, I tried implementing the Schema class from JAXP:
    SAXBuilder parser = new SAXBuilder;
    Document doc = parser.build(myFile);
    Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaFile);
    ValidatorHandler vh = schema.newValidatorHandler();
    SAXOutputter so = new SAXOutputter(vh);
    so.output(doc);It does the validation against the schema file specified but I am not really sure about what I am doing here. The last 2 commands are not clear to me :(
    Then in my schema file, I have elements that have default value. I expected the following behavior: if the element is not in the xml file then the default will be used by the parser (and added in the tree). But it seems, it's not the case.
    Any help/explanation will be really appreciated.

    I am trying to validate xml file against schema file. I decided to use JDOM and JAXP.
    First question: is it a good choice?
    If only schema validation is required use the validation API in JDK 5.0.
    http://www-128.ibm.com/developerworks/xml/library/x-javaxmlvalidapi.html
    http://java.sun.com/developer/technicalArticles/xml/validationxpath/
    For validation with JDOM, the following validation application explains the procedure:import org.jdom.input.SAXBuilder;
    import org.xml.sax.SAXException;import org.jdom.*;
    import java.io.*;
    public class JDOMValidator{
    public void validateSchema(String SchemaUrl, String XmlDocumentUrl){
               try{
    SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser",true);<br/>saxBuilder.setValidation(true);
    saxBuilder.setFeature("http://apache.org/xml/features/validation/schema",true);
    saxBuilder.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
    saxBuilder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",SchemaUrl);
    Validator handler=new Validator();
    saxBuilder.setErrorHandler(handler);
    saxBuilder.build(XmlDocumentUrl);
    if(handler.validationError==true)
    System.out.println("XML Document has Error:"+handler.validationError+""+
    handler.saxParseException.getMessage());      
    else           
          System.out.println("XML Document is valid");
              }catch(JDOMException jde){
                }catch(IOException ioe){
    private class Validator extends DefaultHandler{     
         public boolean  validationError = false; 
         public SAXParseException saxParseException=null;    
      public void error(SAXParseException exception) throws SAXException{        
         validationError =true;
         saxParseException=exception; 
      public void fatalError(SAXParseException exception) throws SAXException  {
    validationError = true;     
    saxParseException=exception;
      public void warning(SAXParseException exception) throws SAXException       {
    public static void main(String[] argv)   {
       String SchemaUrl=argv[0];StringXmlDocumentUrl=argv[1];
       JDOMValidator validator=new JDOMValidator();
       validator.validateSchema(SchemaUrl,XmlDocumentUrl);
    }

  • Problem with JDOM and schemas

    I'm trying to parse (and validate) an XML document with JDOM.
    My root element is declared in the schaema whixh is asociated to the document.
    But during parsing, an exception saying that my root element is not declared is thrown.
    Can someone axplain to me what can happen ?
    Thank's

    What's this element ?
    My schema is indicated by the xsi:schemeLocation attribute of my root-element .

  • Modifying XML files with JDOM

    Hi:
    I've been trying to get up to speed with JDOM, and while it seems pretty intuitive, I've been having a problem w/ modifying XML documents.
    Namely, once I get a Document object from a (skeleton) XML file, do changes made to the Document object through, say, addContent() propagate to the original file? My gut feeling is no, although this was certainly what I had expected initially.
    Here's a code fragment of what I had tried to do to populate a barebones XML file:
                   Document doc = builder.build(output);
              // add 100 elements, all the same
              for (int count = 0; count < 100; count++)
                   Element curr = new Element("book");
                   // create child nodes for book
                   Element title = new Element("title");
                   title.addContent("Book " + (count + 1));
                   Element author = new Element("author");
                   author.addContent("Author " + (count + 1));
                   Element price = new Element("price");
                   price.addContent("Price " + (count + 1));
                   curr.addContent(title);
                   curr.addContent(author);
                   curr.addContent(price);
                   doc.getRootElement().addContent( curr );
              }

    Mikael,
    This sounds like one of the many quirks (perhaps bugs) related to how FrameMaker handles non-FM files in books. The current book model doesn't play well with XML files as chapters and this seems like yet another problem. Apparently, if an xref does not target another .fm file in the book, Frame assumes that the target file is not in the book and therefore will not be in the book PDF.
    There have been discussions here about this in the past. The solution that I use is to run an API client before publishing that converts all XML files to .fm files, and redirect all xrefs appropriately. Then, book features work as expected and PDFs come out as normal. This is not feasible, however, without the automation from the API client.
    There may be some who would say that the best approach is to use XML and books the way that the designers did account for... that is, the whole book becomes an XML document with entity references to the separate chapters. In my work, though, this model was not appropriate... rather, I needed a binary FM book to act like a book, except with XML files as chapters. So, I think I understand your situation.
    Is API programming or FrameScript an option for you? I think it may be the only way to get what you are looking for.
    Russ

  • HT201415 After a months of stable work my new IPad suddenly denies to find cell network under any circumstances.Please advice if anyone familiar with that problem?

    After a months of stable work my new IPad suddenly denies to find cell network under any circumstances.Please advice if anyone familiar with that problem?

    It sounds like there are a couple things going on here.  First check if you have a successful install of SQL Server, then we'll figure out the connection issues.
    Can you launch SQL Server Configuration Manager and check for SQL Server (MSSQLSERVER) if default instance or SQL Server (other name) if you've configured your instance as a named instance.  Once you find this, make sure the service is started. 
    If not started, try to start it and see if it throws an error.  If you get an error, post the error message your hitting.  If the service starts, you can then launch SSMS and try to connect.  If you have a default instance, you can use the machine
    name in the connection dialog.  Ex:  "COWBOYS" where Cowboys is the machine name.  However, if you named the SQL Server instance during install, you'll need to connect using the machine\instance format.  Ex:  COWBOYS\Romo (where Romo
    is the instance name you set during install).
    You can also look at the summary.txt file in the SQL Server setup error logs to see what happened on the most recent install.  Past install history is archived in the log folder if you need to dig those up to help troubleshoot, but the most
    recent one may help get to the bottom of it if there is an issue with setup detecting a prior instance that needs to be repaired.
    Thanks,
    Sam Lester (MSFT)
    http://blogs.msdn.com/b/samlester
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
    "Mark as Answer" and
    "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

  • How to be familiar with Java

    I am not a newer to Java.
    Frankly, I am familiar with the basic principle of java.
    But I don't know how to further my study.

    That doesn't really tell us anything. "Familiar with the basic concept" has lots of interpretations, and beginners tend to think they're more skilled than they really are.
    For beginner level stuff, check out the links below. If you find them too elementary, then you should have an idea of a particuar area you want to learn--sockets, web applications, database operations, etc.
    If you just want to improve your overall skill, then study up on OO concepts, create some software, answer questions here and pay attention when you get corrected.
    Beginner Resources
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.

Maybe you are looking for

  • What's wrong with this simple java file

    I am learning java input methods. When I tried to compile the below simple java file, there were two errors. import java.io.*; public class MainClass {    public static void main(String[] args)  {     Console console = System.console();     String us

  • Creating PDF with XML and APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT

    I am trying to generate a PDF report with an existing BLOB stored in a table being applied to a report template. Here is my procedure. declare doc blob; begin select img into doc from table where id = :P1_SEL_ID; APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT ( p

  • Lenovo G510 Win 8 password Forgotten

    I have forgotten the password of Lenovo G510 windows 8. How do I solve this problem any solutions. I have tried "Windows Password Rescuer Personal" but it gives windows not detected Error.  Any other solution. How about One Key Recovery ???? Would it

  • Enterprise Manager V2 and OMS

    Hi I am trying to export a database in the Oracle 8i 8.1.5 environment. Have set up the Oracle Management server and the enterprise manager console on the same machine. The job errors out with the error message VNI 2015 authentication error. I seem t

  • RTE_SQLERRM: ORA-00600: internal error code

    Hi All, OWB Config Details is as follows: Oracle 9i Warehouse Builder Client: 9.2.0.2.8 Oracle 9i Warehouse Builder Repository: 9.2.0.2.8 Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Min