Randy Miller

Ranch Hand
+ Follow
since Feb 13, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Randy Miller

Hi ranchers!

I am currently working on some new features of my XML processing tool and occured a problem working with the XML scheme. Basically, my tool generates a user GUI based on a XML scheme(=XSD) and a corresponding XML. I use a GUI Engine to dynamically generate the GUI based on the XSD and fill the generated blank formular with the information provided by the XML. But there´s a problem in displaying the "<any...>" elements. The problem is simply caused by the underlying XSD declarations, but I am not allowed to change the XSD period. So, I got the idea to just temporarly alter the XSD to successfully process the now correctly displayed data. My basic idea goes something like this:

I wanna provide a mechanism to overload the problematic XSD section with a correct one. Just like this:

Basic XSD section:

Wanted XSD section:

So,I basically wanna exchange the basic XSD section in XSD file 1 with the wanted XSD section in XSD file 2. Again, I cannot change the basic XSD for good, just temporarely.
I just want to allow the user to easily overload a section by for example click a button.
The problem with the "any"-section just is, that ANYTHING can be written in there, so the GUI engine I am currently using, just has no clue what elements are inside the section <variableParameters> because the elements are not mentioned inside the XSD.

Long story, short question: Is there any way to realize the overloading process of a XSD?I searched for days now but haven´t found anything yet...
Wow! Didn´t think it was that easy
My performance is now through the roof
Thank you John for your code snippet! WOrked perfectly fine!

Here´s the winner:

Hi John!

Sorry, my mistake ;)
Just fixed the code block and copied the correct code up above!

Of course, the for loop you saw there before, was completly irrelevant ;)
Hi guys!

Right now I´m trying to find out all equally named nodes for two different XMLs, saving the found node names inside a StringList and use this list for the user to choose between these nodes.
The idea behind all of this is simple: When I try to overload a section, I now want two big XMLs to switch certain sections, that both of them have(at least equally named sections). The user can choose the section he wants to switch from a Combobox. To prevent mistakes, I figured out, I would compare all nodes first and offer the user just the equally named sections, found in both XMLs, so I prevent the user from trying to switch the <info>-section from XML A with the <person>-section in XML B.
So far,so good. It works just fine, but I have a big performance problem:If both XMLs have more than 300 nodes each, comparing them still works fine, but it takes a lot of time before the program continues its work. The user GUI is frozen until the node comparing process is done. Now, I worked around it so far by warning the user, if a certain number of nodes is found in both documents and I let him type in the desired node name manually. (of course I then check if both documents have this node ;) )
But is there an easier/better way to find out all equally named sections for two different XMLs?
Here´s my code(which works just fine except the performance for bigger XMLs):

I use this method to create two ArrayLists holding ALL nodes of the corresponding XML file.
Afterwards, I compare the two ArrayLists just like this:

And that´s exactly where the performance problem lies. Does anyone have a suggestion how to better the performance issue?


Hi guys!

John, I can´t thank you enough my friend!!THAT was the problem!!There were stupid whitespaces
The method worked just perfect, but I never saw the whitespaces...
Thank you thank you thank you,you´re Awesome

And g tsuji,thank you for trying to help out as well
Ok John,now I found THE problem, but I don´t have ANY clue how to solve this.
Let´s look at this code snippet of my replace() method:

If I start the program just like this, the chosenSection in BOTH System.out.prints is perfectly correct. It´s basically a String from a JComboBox where the user can choose his node to be replaced.
The kicker is, the list length in THIS scenario is 0...

If I alter the code snippet and write the actual String as a replacement of chosen Section just like this:

Now,the programm works perfectly fine...Even though it uses the EXACT same String,just now not represented by chosenSection...
But chosenSection holds the EXACT same String...How in the world could this be???
Hi John!

Did EXACTLY what you suggested and here are the results ;)

So,the name is definitely correct.And there also is an existing list.
I just can´t interpret what the output for the list means.

When I use the list.item(index) method and use 0, the output is the section I wanted, BUT if I use any other index it´s null...

Hi Peter!

So, I fixed this problem myself
Ain´t that difficult if you once find out how it works.
Just to answer your question: YES, I used an EXTRA folder for the images like this: projectname/src/images/some.jpg
Basically to get this one done with eclipse, first you create an executable jar just as you normally would.
Then, you use WinRar to open a view on the jar structure and manipulate it afterwards WITHOUT unpacking and repacking it again.
I just added the wanted folder "images" to the bin folder inside the jar and there it was: The perfect executable jar

Thanks for your help

to Bill: Line 28 to be exact!I know,A LOT of comments, I sort of "marked" it in there. Right at this position, the element is zero, even though, the searched node name exists in BOTH XMLs and the name isn´t wrong at all.

to John: Ok, tried that one. It´s zero??Now why´s that??The node exists and the name is correct...Maybe it just won´t find the element??
Hi guys!

It´s me again with another XML related question ;)
So,basically,I now try to create a dynamic process for replacing XML sections.

Just to give you a short summary: First, I tried to overload a certain section inside a big XML with a smaller XML just containing an equally named section with other data.
Now,I build a GUI around this stuff and read out all possible nodes to be overloaded and save them inside a ComboBox for the user to choose.
When the user picks his node to be replaced, the application should then search for the corresponsing section inside XML number A,copy that one and import it into XML number B.
So far so good.But somehow, the element, I want to import into the other is ALWAYS empty, even though I read out the chosen node correctly(checked this one out with MANY System.out.prints ;) )

The idea is, that,no matter whereever inside the XML the wanted section is located, used to overload the other equally named section inside the second XML,the application is able to locate this section and import it.

Just to illustrate:



And now,the user gets all possible nodes provided by XML A inside a ComboBox to choose which section he wants to overload. Then, the application uses the name of this section to search inside XML B, retrieves the data and imports it inside XML A. For example the application locates the field "name", after being chosen, inside XML B and overrides the existing data in XML A ("Maier") with the data in XML B("Müller"). This means, the section to be retrieved from XML B doesn´t have to be the root node, but it might be!

Now, here´s my code so far:

You don´t have to look at all the comments I made inside the code ;)
As you can see, I tried a lot of print()-statements to find out, where the problem is.
And apparently, my Element is null??But I use the correct name for the node to locate it.
I just can´t figure out the problem...

Hopefully someone has an idea


Hi Peter!

Sorry for taking so long to answer but I´ve been crazy busy lately...
I´m not pretty sure what EXACTLY you mean by where the pictures are located with the project folder, but I´ll try my best to answer ;)
Basically I have my project folder, inside the project folder is the folder src and inside THIS folder is a package containing ALL classes.
The pictures,my property files etc are all located inside the source folder(src), but NOT inside the package itself.

Does this lead to my executable jar problems?
Hi Peter!

Looking at the eclipse environment, the pictures are located in a folder inside the project. When I start the application in Eclipse, everything´s perfectly fine.
But then, I tried to use the "Export"-function to create an executable Jar...Now, I can directly open this far and it starts running but it just won´t display the 3 pictures.
And seemingly, my property-files(also located inside the project folder) aren´t in use,also...
I unzipped the executable Jar and there´s NO pictures folder, NO property files,NOTHING...
Funny thing is,Eclipse just won´t create an executable Jar with these folders.So far I haven´t found an option to choose where I might tell eclipse to please include these folders as well during the creating process.
But, if I just simply create a normal jar, all folders are included correctly.Now,how may I create an executable jar with this "normal" jar?
Hi guys!

It worked
Big Thank You to g tsuji
That´s EXACTLY what caused the problem!
For everybody who is looking for the complete solution, here´s the code:

Hi guys!

The topic says it all: I basically want to export my current project via eclipse to create a runnable jar. So far so good. The project works just fine, BUT: My project is a bigger GUI, where I also use external pictures which are located inside a seperate folder INSIDE the project. Somehow, no matter how I try to export the project, it just won´t use these pictures when I try to start the runnable Jar.
The only thing that works is either: Export a runnable jar without the pictures OR export a normal jar, which is NOT runnable...
Does somebody have the same problems and a solution to this mess?


Hi guys!

I know, I already posted this problem, some time ago, but I mistakenly though, I found the solution. But, I didn´t
So basically, to shortly recap what I want to do: I have 2 XML file. Both files have a similar named section. What I want to do is, to replace section A from file A with section A from file B.
To illustrate:

File A:

File B:

The similar named section, both have in common is <note>, but the contained attributes differ from file to file.
File B is just the section, I want to place inside File A,nothing more, while File A is a HUGE file,where you have to locate the correct section first before overloading it.
The overloading process would be perfect if I would save the result in an entirely new XML, not actually overwriting the existing file.

I tried this for weeks now and I just can´t figure this one out...All I got so far was, to append the wanted section to the right file, but that´s still not it...
And the replaceChild(), adoptChild() won´t work too...

Here´s my code so far,hopefully somebody finds the mistake

No matter what I try,it just won´t work...And I already tried a lot of System.out.print-statements to figure this one out,trust me ;)