Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Dorothy Taylor

Ranch Hand
+ Follow
since Nov 26, 2007
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 Dorothy Taylor


I have a string like this:

I want to split first on ; and then on :
Finally the output should be only the latter part around : i.e. my output should be def, ghi, jkl, pqr, stu, yza,aaa,bbb

This can be done using Split twice i.e. once with ; and then with : and then pattern match to find just the right part next to the :. Howvever, is there a better and optimized solution to achieve this?
9 years ago

Java 7 does not provide iteratable NodeList. I checked on forums and created an interface like this :

Next in my Java class I had as below:

However, the above code gives me an exception at the point of cast:

Could anyone please suggest how to fix this. Infact I am not even importing apache library. I dont know why apache is throwing exception
I changed it as below and it is working now:


I am facing problem in creating a schema if anyone could please assist. I am using Oxygen XML Editor. So the problem is that I have a schema declaration as below:

So what teh above intends is that some element has an 'output' attribute which is optional. But if this attribute is defined, then it cannot have values 'result' or 'isTimedOut' i.e. if in the instance xml I say output="result" then it should not validate.
Now the problem is that in the xml I cannot have the element without 'output' attribute even though I am declaring it as optional. So if the tag does not define the output attrbute then the xml is not validated. Could anyone please suggest how to mandate the optional behaviour for this attribute. Below is the error that Oxygen gives:
ok, so you mean that each thread that has something to write will push its message in a queue. At the same time, there is a thread that reads messages from this queue and updates in the file. So again, the writes are sequential since the first messages will be written first and then the next and so on. Is this right?

I have an xml file that has to be written by multiple threads running in parallel. How can we ensure that the structural integrity of the xml file i.e. many threads writing into the file can spoil the structure of the xml. One way is to make the write method synchronized, but that is a very high level approach with which only one thread may write at a time. So the other threads are ready with their data but cannot write until the lock is released. Is there a better way to do this?
yeah, so I guess this design is good that we have a DOM once in memory and we keep writing updates as they come, into the file system. But I now have a doubt that whether this DOM (in memory) can be made synchronized, so that parallel threads that are attempting to modify it do not conflict. Similarly the method that writes DOM tree to file system will be synchornized. But how can we make the in-mmeory DOM synchronized? Is it possible to do that?
Why I cannot choose another format is because (i) I want a format that is human readable (ii) my xml will not be too big in size. It would be something like 5-10KB max
Yes, but for every task that is performed, I need to visit the output xml twice to update the status and then write it to file system. So again the question is what is the best way to do this. Is it possible to have the DOM in memory just once or do we have to do that again and again for every task

ya so that was what I initially thought ought to be done which William invalidated and suggested using SAX parser for writing xml file and DOM for parsing so that performance is not impacted
Yes, the word log may not be accurate here. basically I have an input XML file that contains some tasks. I need to execute those tasks sequentially or in parallel. As these tasks get executed, I have to record the statuses of these tasks in a new xml file(which I create if does not exist already). I am referring to this output xml as the 'log' here. So for e.g., if there is a in the input xml, then I write in the log file. This would mean that the control reached task 'a' and assigned a thread to it. Now if 'a' is complete, I will change the status to 'end'. So an operational guy, by looking at the xml can exactly know what is happening as the input xml is getting processed. So the whole thing is that what should I do to create the output xml

William Brogden wrote:
With SAX parsing the log file can be huge but your memory use is small. For inserts and deletions write a new file from the SAX events.

I did not quite get how you are advising about insertions and deletions. I mean is serializing the DOM as xml a better approach or re-creating the same file again and again better? Moreover, I had read somewhere that SAX can be used only for read operations, but for editing things we can use DOM only.
Also please validate my understanding that even with 'shell' channel, to know the output of any one command from a sequence of multiple commands, we will need to parse the output stream. Even in this case, how will we know which output corresponds to which command, since all are clubbed together only
9 years ago
If I use 'exec' channel for multiple commands, how can I know the output of a particular command from the group?
9 years ago
Further can we make multiple parallel threads to write to this xml file