comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Console from GUI? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/916a2f91d4c72ba3 * VM Error - heap memory problem - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/363218dc7986a594 * Java was created in SODOM and GOMORRAH !!!! - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/241d795807847c94 * can't make addSetTop work with Digester - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a5934c91d226b9c * how to post UTF-8 values to a servlet - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8720339cb557e8ea * setting class root directory - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7d840c5b8cf116e5 * RMI Callback and Threading - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fcd30567613814c * .class file includes debug info?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/68f1bf9ec4850ab3 * Regexp to extract filename from g++ output - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d495dd5db4858206 * hi all - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ca38bfbf0ac2dfb8 * JSP, session, 'caching' - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9b4a7e1061e7b01c * Problem with "if - else" statement in for loop - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5b7924948803c3c4 * Tomcat and jTDS - not that stable... - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c23245a26d17c26 * Removing the dtd name when using print(...) on the dtd generated class - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f0437c5e1b622a93 * Setting DOCTYPE to a DOM- document - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f0a2e7258baad09 ============================================================================== TOPIC: Console from GUI? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/916a2f91d4c72ba3 ============================================================================== == 1 of 2 == Date: Tues, Dec 21 2004 12:20 am From: "Bilal" Hello, I've built a tiny interpreter for a tiny programming language. The program has a GUI that enables the user to write his code in a text-box and then run the program. The language contains two instructions: read <variable> write <expression> To achive these two instructions I'm thinking of a text-based console. How can I create a console from within a frame-based GUI porgram? How can I then deal with the in and the out? I'm using Borland's JBuilder so for now, I can use the "Messages" Panel to cope with writing... I'm running both Windows and Linux. Is there a swing bean that emulate exactly the console (DOS for example)? Thanks in Advance. == 2 of 2 == Date: Tues, Dec 21 2004 3:02 pm From: "Heiner Kücker" Bilal > Hello, > > I've built a tiny interpreter for a tiny programming language. > The program has a GUI that enables the user to write his code in a > text-box and then run the program. > The language contains two instructions: > > read <variable> > write <expression> > > To achive these two instructions I'm thinking of a text-based console. > > How can I create a console from within a frame-based GUI porgram? > How can I then deal with the in and the out? > > I'm using Borland's JBuilder so for now, I can use the "Messages" Panel > to cope with writing... > > I'm running both Windows and Linux. > > Is there a swing bean that emulate exactly the console (DOS for > example)? > > Thanks in Advance. > Is this ok?: http://www.google.com/search?hl=en&q=java+console -- Heiner Kuecker Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ ============================================================================== TOPIC: VM Error - heap memory problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/363218dc7986a594 ============================================================================== == 1 of 2 == Date: Tues, Dec 21 2004 2:43 am From: Surendra Singhi Hi, I am using Java on a windows xp machine. Recently while writing a program which takes large amount of memory I ran into this runtime error. And it is giving me nightmares, as I have a very important deadline to meet. The program takes large amount of memory so I tried increasing the heap size and set the following options for the vm -verbosegc -ms128m -mx128m Also, at one or two places I am explicitly calling gc, to help free up some memory. The time the program will take to execute is not a concern as long as it runs smoothly. Attached is a part of the trace of the gc run and the run time error. How to fix this bug? And is it memory allocation which is causing it? Any help on this will be heartily appreciated. Thanks in advance. -- Surendra Singhi www.public.asu.edu/~sksinghi/ [GC 14246K->6146K(130112K), 0.0047735 secs] [GC 14273K->6473K(130112K), 0.0017715 secs] [Full GC 9045K->6183K(130112K), 0.0460307 secs] [GC 14310K->6221K(130112K), 0.0022045 secs] [GC 14349K->6206K(130112K), 0.0014379 secs] [GC 14333K->6222K(130112K), 0.0006643 secs] [GC 14350K->6206K(130112K), 0.0005355 secs] [GC 14334K->6209K(130112K), 0.0005559 secs] [GC 14337K->6212K(130112K), 0.0006160 secs] [GC 14339K->6215K(130112K), 0.0019924 secs] [GC 14343K->6218K(130112K), 0.0006233 secs] [GC 14346K->6232K(130112K), 0.0021648 secs] [GC 14360K->6229K(130112K), 0.0007012 secs] [Full GC 6988K->6229K(130112K), 0.0446780 secs] # # HotSpot Virtual Machine Error, Internal Error # Please report this error at # http://java.sun.com/cgi-bin/bugreport.cgi # # Java VM: Java HotSpot(TM) Client VM (1.4.2_06-b03 mixed mode) # # Error ID: 43113F2652414D452D41503F491418160E435050005C # # Problematic Thread: prio=5 tid=0x0035f020 nid=0x358 runnable # Heap at VM Abort: Heap def new generation total 9088K, used 2794K [0x10010000, 0x109e0000, 0x109e0000) eden space 8128K, 34% used [0x10010000, 0x102cab28, 0x10800000) from space 960K, 0% used [0x10800000, 0x10800000, 0x108f0000) to space 960K, 0% used [0x108f0000, 0x108f0000, 0x109e0000) tenured generation total 121024K, used 6229K [0x109e0000, 0x18010000, 0x18010000) the space 121024K, 5% used [0x109e0000, 0x10ff5628, 0x10ff5800, 0x18010000) compacting perm gen total 4096K, used 2159K [0x18010000, 0x18410000, 0x1c010000) the space 4096K, 52% used [0x18010000, 0x1822bcc8, 0x1822be00, 0x18410000) == 2 of 2 == Date: Tues, Dec 21 2004 6:18 am From: "asaguden" You are not setting the JVm memory correctly. Memory settings are a part of the -X settings Further, this is not an expert opinion only my own: - I would recommend against doing your own gc too increase performance, the jvm does that better than you. However you can hint to the jvm what kind of gc you need. (see links) I would do this: 1. Increase heap size to make the application work 2. Check with som kind of analyzing tool what eats up your memory, and check to see whether the architecture can be less memory consuming. 3. Give correct jvm/hotspot parameters to maximise performance for this particular application (see links) Hotspot performance: http://java.sun.com/docs/hotspot/gc1.4.2/ JVM options: [http://java.sun.com/docs/hotspot/VMOptions.html] Good luck. asaguden ============================================================================== TOPIC: Java was created in SODOM and GOMORRAH !!!! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/241d795807847c94 ============================================================================== == 1 of 4 == Date: Tues, Dec 21 2004 11:11 am From: "Azeus" "Bruno Beam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > JAVA was written by SATAN in SODOM with help of the ANTICHRIST > in GOMORRAH !!! DEMONS added a lot of BLASPHEMY and HERETICS and > WITCHES tons of pure SIN !!!! That makes JAVA extremly EVIL and > UNHOLY !!!! > > If you want to use JAVA, you need HOLY WATER, a BIBLE and a > CRUCIFIX and only experienced EXORCISTS can master JAVA !!!! Well, considering it is OO, you are requires to have inherited some common sense to be able to use it properly. == 2 of 4 == Date: Tues, Dec 21 2004 11:12 am From: Stefan Schulz On 20 Dec 2004 22:53:48 -0800 [EMAIL PROTECTED] (Bruno Beam) wrote: > JAVA was written by SATAN in SODOM with help of the ANTICHRIST > in GOMORRAH !!! DEMONS added a lot of BLASPHEMY and HERETICS and > WITCHES tons of pure SIN !!!! That makes JAVA extremly EVIL and > UNHOLY !!!! > > If you want to use JAVA, you need HOLY WATER, a BIBLE and a > CRUCIFIX and only experienced EXORCISTS can master JAVA !!!! Bad attempt to flood scot.tld, please do not fall into the trap. Other then that, not even funny. -- In pioneer days they used oxen for heavy pulling, and when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger computers, but for more systems of computers. --- Rear Admiral Grace Murray Hopper == 3 of 4 == Date: Tues, Dec 21 2004 10:17 am From: Andrew Thompson On 20 Dec 2004 22:53:48 -0800, Bruno Beam wrote: > JAVA ... Yeah, yeah, yeah.. Please refrain from attempting to get groups inundated with angry posts from Java users. a) It will fail. b) It wastes our bandwidth. Note: scot.tld dropped from X-Post. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane == 4 of 4 == Date: Tues, Dec 21 2004 2:43 am From: "Sudee" Guess this is far from being even funny !!! Bruno Beam wrote: > JAVA was written by SATAN in SODOM with help of the ANTICHRIST > in GOMORRAH !!! DEMONS added a lot of BLASPHEMY and HERETICS and > WITCHES tons of pure SIN !!!! That makes JAVA extremly EVIL and > UNHOLY !!!! > > If you want to use JAVA, you need HOLY WATER, a BIBLE and a > CRUCIFIX and only experienced EXORCISTS can master JAVA !!!! ============================================================================== TOPIC: can't make addSetTop work with Digester http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a5934c91d226b9c ============================================================================== == 1 of 3 == Date: Tues, Dec 21 2004 2:18 am From: [EMAIL PROTECTED] (Vincent Fuchs) Hi all, I have a problem with Digester : I want to set a parent-child relationship between 2 objects, and I want to use Digester's addSetTop method. Here is my XML file : <?xml version="1.0" encoding="ISO-8859-1"?> <docExcel> <onglet name="Lot1"> <cellule positionX="F" positionY="4" type="pourcent"> <seuilBas positionX="E" positionY="4"/> <seuilHaut positionX="D" positionY="4"/> <indicateur name="transfert_de_fichiers" periodicite="hebdo"/> </cellule> </onglet> </docExcel> I want to set the relationship between cellule and onglet, by calling a setOnglet(Onglet ong) method on a Cellule object. Here is my code : Digester mapping=new Digester(); mapping.setValidating(false); mapping.addObjectCreate("docExcel",DocExcel.class); mapping.addObjectCreate("docExcel/onglet",Onglet.class); mapping.addSetProperties("docExcel/onglet"); mapping.addObjectCreate("docExcel/onglet/cellule",Cellule.class); mapping.addSetTop("docExcel/onglet/cellule","setOnglet","divData2csv.excel.Onglet"); mapping.addSetProperties("docExcel/onglet/cellule"); So, in the Digester's stack, from bottom to top, I have a DocExcel, an Onglet, and a Cellule. According to the documentation, the addSetTop method should call the setOnglet method on the top object (Cellule), passing the top-1 object (Onglet) as an argument. When I execute my program, I have this in the log file : - Fire begin() for SetTopRule[methodName=setOnglet, paramType=divData2csv.exel.Onglet] - Fire begin() for SetPropertiesRules[] and the properties are set, but nothing else about setOnglet. Am I misunderstanding the way it should work ? I couldn't find any example using addSetTop, so if I have some, I would be glad to have a look at it. thanks -- Vince == 2 of 3 == Date: Tues, Dec 21 2004 5:26 pm From: "Guru" Hi, I have a database table with text and boolean. i need to show the text in a label and depending upon the boolean i need to show a check box with state off or on. I should do this in struts. Here comes the problem: How to populate the checkbox dynamically ? As we do not know the check box count, how to generate setter and getter for that in the form bean ? --guru == 3 of 3 == Date: Tues, Dec 21 2004 5:29 pm From: "Guru" I am sorry. I have replied my problem to another question. As i am a new user of the OE,please forgive me :) ! --guru. "Guru" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I have a database table with text and boolean. > i need to show the text in a label and depending upon > the boolean i need to show a check box with state off or on. I should do > this in struts. > > Here comes the problem: > How to populate the checkbox dynamically ? > As we do not know the check box count, how to generate setter and getter for > that in the form bean ? > > --guru > > ============================================================================== TOPIC: how to post UTF-8 values to a servlet http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8720339cb557e8ea ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 10:49 am From: "Andy Fish" "Andy Fish" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I have a form with some text boxes, and I'm trying to post the data to a > servlet in utf-8 format (which I would have thought would be the default > but it appears not?) > > the HTML file containing the form itself is definitely encoded in UTF-8, > and the form tag looks like this: > > <form action="http://localhost:8080/foo/servlet" method="post" id="form1" > charset="UTF-8" name="form1"> > <INPUT type="text" name="foo"> > </form> > > In the servlet I'm just calling request.getParameter("foo"); > > If I type in an English pound sign £ (this is the English currency symbol, > not #), I get £ (which is A circumflex followed by the pound sign). > > I've been playing with various variations for 1/2 a day now and it's > starting to get me rather frustrated. Can anyone point me in the right > direction. > FWIW, my solution was to call request.setCharacterEncoding("UTF-8") at the top of the doPost method. I'm not entirely happy with hard-coding it this way, but hey it seems to work. > TIA > > Andy > > ============================================================================== TOPIC: setting class root directory http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7d840c5b8cf116e5 ============================================================================== == 1 of 2 == Date: Tues, Dec 21 2004 3:43 am From: "PRadyut" hi, in j2ee 1.4 i have chosen the ejb class files in the new enterprise bean wizard but on clicking the next button in the ejb jar general settings it is giving the message i the class (converter.Converter) could not be loaded: please consult online help for assisstance in setting up the class root directory and choosing class files. any help thanks Pradyut http://pradyut.topcities.com http://groups.yahoo.com/group/d_dom/ India == 2 of 2 == Date: Tues, Dec 21 2004 11:50 am From: Andrew Thompson On 21 Dec 2004 03:43:06 -0800, PRadyut wrote: > please consult online help for assisstance in setting up the class root > directory and choosing class files. Feel free to let us know the result of that. Good luck with it. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: RMI Callback and Threading http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fcd30567613814c ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 4:02 am From: [EMAIL PROTECTED] (H. M?ller) Hello, i build a thread pool that computes some kind of jobs. The jobs are delivered by a RMI call (one call with jobarray) to the server together with a reference to the client (RMI Callback). Each job was computed by an own thread. A pool thread gets its jobs from a queue, compute it and invokes a method on the client reference. Sometimes i get a Connection refused Exception when i do the callback, but other callbacks work well. So, i enclose the callback with a synchronization block: class PoolThread extends Thread { public PoolThread(IClient client) { this.client = client; } ... run() { ... synchronized (client) { client.returnJob(job); } ... } ... } Now it works, but i do not understand why. Can anybody give me a hint? Is it because of several threads doing the callback concurrently? Does the RMI framework not handle this case? Again, everything worked well without the invokation of a callback INSIDE a thead. regards Mr. Müller ============================================================================== TOPIC: .class file includes debug info?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/68f1bf9ec4850ab3 ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 4:05 am From: [EMAIL PROTECTED] Hi, I'm looking for a command-like utility which can read a .class file and tell you whether it includes debug information, i.e. whether it was built with the -g option of javac. Thanks in Advance, Dónal ============================================================================== TOPIC: Regexp to extract filename from g++ output http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d495dd5db4858206 ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 12:16 pm From: "Mike" thanks for your replies! gordon, your version fails here if there is no column: c:\tmp\test.cpp:1: error: message does this work in your jre? i am using sun's 1.4.2_06 under win2k. i think i do not understand the logic of regular expressions at all: i have: fn:1:2: (.*)(:[0-9]+)+ i would expect that this returns a group that contains 'fn' but it returns 'fn:1' why does it always return the 'maximum matching area'? when i use: (.*)(:[0-9]+:)|(:[0-9]+:[0-9]+:) again it returns 'fn:1' is this the expected behaviour? what extra logic is applied to the OR? when i use (.*)(:[0-9]+:[0-9]+:)|(:[0-9]+:) it works, but fails for the input string 'fn:1:' how can i express "read into group1 until the first :[0-9]+ is found" with a regexp? thanks, mike ============================================================================== TOPIC: hi all http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ca38bfbf0ac2dfb8 ============================================================================== == 1 of 2 == Date: Tues, Dec 21 2004 5:29 am From: [EMAIL PROTECTED] (akshatha) i am new to j2ee. i have been working with j2ee sun 1.4. Now, i want to deploy my application in jboss. Kindly provide me sufficient guidance Thanks -Akshatha == 2 of 2 == Date: Tues, Dec 21 2004 2:50 pm From: "Salim" "akshatha" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] >i am new to j2ee. i have been working with j2ee sun 1.4. Now, i want > to deploy my application in jboss. Kindly provide me sufficient > guidance > > > > Thanks > -Akshatha you can easily deploy your compnents EJB while keeping your classes and the file ejb-jar.xml, but you must create a new file ejb-jboss-jar.xml which replaces that of SUN. inside of this file you must configure your EJB in JBOSS, for this you can look at the files of JBOSS examples. Salim ============================================================================== TOPIC: JSP, session, 'caching' http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9b4a7e1061e7b01c ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 10:14 pm From: Rico On Fri, 17 Dec 2004 15:31:39 -0500, John C. Bollinger wrote: > Rico wrote: >> I'll be looking up some example of how to use what I think should be >> 'session' scope to achieve what I described. Suggestions welcome though. >> >> I'm mainly wondering if there could be any tools or libraries that would >> ease the implementation of this kind of, how to call it... caching? that >> I am considering? > > You could select all the rows into a scrollable, updatable ResultSet, > then hold the ResultSet in the session across requests. There are all > sorts of gotchas and caveats there, especially in the area of > scalability, but if you only need to support a handful of concurrent > users then it could be made to work without too much hassle. It has the > advantage of being able to cache unread results _in the DB_ rather than > in memory, supports user modifications in a straightforward way, and > only requires one query. Amongst those gotchas and caveats, would there be a requirement to provide the client with a close() method that they have to call for the bean to know to release the connection? Or is there a mechanism for when the session expires? E.g, I am using a ConnectionPool and performing JNDI lookups by making use of Tomcat's "context". So, upon the session expiring would the context implementation be able to free the resources for reuse? Thanks. Rico. ============================================================================== TOPIC: Problem with "if - else" statement in for loop http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5b7924948803c3c4 ============================================================================== == 1 of 2 == Date: Tues, Dec 21 2004 6:04 am From: [EMAIL PROTECTED] I am having problems with this section of code... public void updateRank(){ int x = -1; int y = -1; String winnerMemNum = JOptionPane.showInputDialog ("Enter winner's membership number:"); int wMemNum = Integer.parseInt(winnerMemNum); for(int i=0;i<list.size();i++){ Player temp = (Player)list.get(i); if(temp.getMemberNumber() == wMemNum) x = i; else System.out.println("Player not found"); break; } I want the condition in the if statement to be tested for every element in the list before the code in the else block executes, but at the moment it is only testing the first element. I know I need to put brackets in, but when I did that, the whole thing stopped working! Any ideas? == 2 of 2 == Date: Tues, Dec 21 2004 2:15 pm From: "VisionSet" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] ... > > I want the condition in the if statement to be tested for every element > in the list before the code in the else block executes, but at the > moment it is only testing the first element. I know I need to put > brackets in, but when I did that, the whole thing stopped working! Any > ideas? > public void updateRank(){ > int x = -1; > int y = -1; > String winnerMemNum = JOptionPane.showInputDialog > ("Enter winner's membership number:"); > > int wMemNum = Integer.parseInt(winnerMemNum); java.util.Iterator iterator = list.iterator(); boolean playerFound = false; while(iterator.hasNext()) { Player player = (Player) iterator.next(); if(player.getMemberNumber() == wMemNum) { playerFound = true; break; } } if(! playerFound) { System.out.println("Player not found"); } -- Mike W ============================================================================== TOPIC: Tomcat and jTDS - not that stable... http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c23245a26d17c26 ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 10:24 pm From: Rico On Mon, 20 Dec 2004 09:06:07 +0000, Alin Sinpalean via JavaKB.com wrote: > Rico, > > If you encounter any problems with jTDS please submit them as bugs on > SourceForge. We'll be more than glad to help you out. Sure Alin. Thanks. I'll drop by some time. I was facing a problem related to authentication previously. My test system at home doesn't belong to a domain, SQL authentication worked fine. When I uploaded onto the production server, two things: (i) I didn't upload the latest version of class A that imported static fields from a separate class B that I had modified. (ii) jTDS seems to have problems using SQL authentication when running in Tomcat's "context" when a domain is present. I solved (i) rather by chance before reading Michael's post to be clearer on the situation. (ii) was more of a hunch, that I wish had come earlier, to try and use domain=X and Windows authentication instead. Not sure if the problem is with Tomcat, jTDS or the domain policy. Thanks for the invite. Rico. ============================================================================== TOPIC: Removing the dtd name when using print(...) on the dtd generated class http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f0437c5e1b622a93 ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 6:58 am From: "Joseph Tilian" I have created some classes from a dtd using the classgen-package. One of these classes is MyClass. When I use print(System.out) on the MyClass I get: <!DOCTYPE MyClass SYSTEM "jar:file:/D:/MyProject/lib/MyJar.jar!/MyProject/MyDTDs/MyClass_dtd.txt"> as the first line. I would like to have all of the mumbo jumbo including SYSTEM not to show up, i e I don't wont the name of the dtd to show up at all. Is there a way to accomplish this? I'm using the Oracle9 classgen.jar When I used the Oracle8 classgen.jar the SYSTEM and all the crap after didn't show up. ============================================================================== TOPIC: Setting DOCTYPE to a DOM- document http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f0a2e7258baad09 ============================================================================== == 1 of 1 == Date: Tues, Dec 21 2004 7:01 am From: "John C. Bollinger" All, Resolution: The method described earlier in this thread for creating a Document with DocumentType works as expected. However, that is not enough to achieve the OP's goal. (In fact, it may be orthogonal to that goal.) The OP was using a default Transformer to output a representation of his DOM document, and even though the document had a correct document type node, it was not reflected in the output. This appears to be because the data model used by XSLT does not accommodate document type declarations, and hence a Transformer object (or any other XSLT transformation mechanism) will not emit one without coaxing. One could write an appropriate document type declaration into the stylesheet as text, but that precludes using a default Transformer. There is a more flexible way: [...] import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; [...] /** * Applies an identity XSLT transform to the provided DOM Document, * directing the result to provided Result object. If the document * contains a DocumentType node then its public and system ids are * provided as the appropriate properties of the transform, which * will generally cause a DOCTYPE declaration to be part of the * transformation result (but whether or not the provided Result * object does anything with it depends on that object). * * @param doc the DOM Document to copy * @param result the Result object that should receive the * copy * * @throws TransformerException if one occurs while obtaining an * Transformer instance or while performing the * transformation */ public void transformWithDoctype(Document doc, Result result) throws TransformerException { TransformerFactory factory = TransformerFactory.newInstance(); Transformer xformer = factory.newTransformer(); DocumentType doctype = doc.getDoctype(); if (doctype != null) { xformer.setOutputProperty( OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId()); xformer.setOutputProperty( OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId()); } /* * Note: the default output method is used (either "xml" or * "html", depending on the document). See chapter 16 of the * XSLT spec for the details. */ xformer.transform(new DOMSource(doc), result); } [...] This should also be expressible directly in XSLT. John Bollinger [EMAIL PROTECTED] ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
