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

Jan Spengen

Greenhorn
+ Follow
since Nov 28, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jan Spengen

This time I'll just go with a LinkedHashMap, as the time pressure is rising, and this is for this project the easier, faster solution.(And I already coded it ) Plus I found that a sorted list is only necessary in 2 places, where I can easily work with the LinkedHashMap (and "resorting" the map is not a problem performance wise).
(And well this is for an in-house application, so code quality is not as high on the priority list, as if it were a customer project. )

Though next time I encounter this, I'll try your approach, cause it seems to be the better way to handle this.

Thanks a lot for the input though, I really appreaciate it.
[ May 25, 2007: Message edited by: Jan Spengen ]
14 years ago
Damn, then I've got to find other solutions to deal with the problem it seems.

LinkedHashMap doesn't sound too bad.. but as I remove and insert values on the map, it will be unsorted again. (Though, I could probably repeat the process, got to think about that.)

Well anyway thanks a lot.
Just the answer that what I wanted is not going to become true saves me quite some time (even though that would have been the easiest solution).
14 years ago
Hi.

I'm trying to sort a HashMap by values. I know that it might not be "good style", but it would save a lot of work, as I wouldn't have to rewrite lots of code if I could just get the HashMap sorted.

After lots of searching and trial and error cases I'm still stuck.

I found this old topic: https://coderanch.com/t/370496/java/java/Sorting-Hashtable-values-retriving-kay

and I thought that might be it. But all I can get is a sorted System.out ..
the HashMap itself is still unsorted.
I tried using this approach, which is mentioned in the old thread.


Now my qustion is, how to put those sorted Entry sets back in a HashMap?
This is probably very easy, but I'm just not seeing it.

Thanks in advance for reading. Any input is appreciated.
14 years ago
Again a very simple mistake, but I just didn't see it.

It has to be:



The Z for the timezone has to be 'Z'.
15 years ago
Hello Ranchers!

I got a problem converting an XML dateTime String to a Date object.

The XML dateTime String looks like this:
2006-11-07T05:31:33Z

I tried to convert it this way:



From the results I found using google this should be correct . (?)
But it's always giving me a parsing error saying:

Unparseable date: "2006-11-07T05:31:33Z"

And well I can't figure out how to do it.

I hope someone here is able to give me a hint at least. ;)

Thanks a lot in advance.
15 years ago
It would have been so easy
Like this it works:
You could try Blender3D.
It's quite powerfull and I personally like it very much. It has a steep learning curve though.
But there are a number of good video tutorials available from the blender site to get you started.
15 years ago

Originally posted by Paul Clapham:
I also have no idea about XOM, and the link you posted goes to a site that isn't responding.


Hmm strange, both links are working for me.

Originally posted by Paul Clapham:
The JAXP org.w3c.dom classes have both setAttribute and setAttributeNS methods, the latter to be used for namespaced attributes. Maybe XOM is the same except that it does better validation than DOM, which allows you to sneak attributes into the setAttribute method?


I think I don't understand your question.

Well thanks already for the reply.
I guess I'll have to do some more digging for information.
I thought a moment about switching to JDOM,
but unfortunately that is not really an option.

Edit:
Obviously the problem arises with the "xsi:"
in

If I cut that out and do instead :

Creation runs through to the end without problem. But then I get the problem at validation time as my XML is then not valid against its schema.

Any Ideas why this is causing the error or how to walk around it?
[ November 29, 2006: Message edited by: Jan Spengen ]
Thanks for the idea.

But there is no setAttribute method on Element in the XOM API.

Plus I'd expect the same behaviour.
Adding attributes the way I described is also no problem on other Elements in my XML message.
[ November 28, 2006: Message edited by: Jan Spengen ]
Hello Ranchers.
I have a small but annoying problem, and hope that you can help me out.
I'm working on a programm which reads out xml messages and creates xml messages.
I'm using the XOM package for that. Reading out the XML works fine, validating it is working fine as well. But on creation I got a problem.
The root element of my created XML has to look like that:


The namespace is no problem, I add that in the following way:


But when I want to add the schema-declaration as an attribute:

I get the following error message:

nu.xom.NamespaceConflictException: Attribute prefixes must be declared.
at nu.xom.Attribute._setNamespace(Attribute.java:516)
at nu.xom.Attribute.<init>(Attribute.java:168)
at nu.xom.Attribute.<init>(Attribute.java:70)

But I don't understand it.

I think I declared the prefix in the attribute ? (xsi:noNamespaceSchemaLocation)

Elliott Rusty Harold writes in his tutorial at www.cafeconleche.org
the following:

Attaching a schema is no harder. Just place the necessary xmlns:xsi and xsi:noNamespaceSchemaLocation attributes on the root element.



Didn't I do just that? But it is not working... .

If anyone could shed a light on this I would be really grateful.
I tried the IBM tutorials, the cafeconleche.org tutorials, and various others I found on google, but to no result yet
.
[ November 28, 2006: Message edited by: Jan Spengen ]