[jdom-interest] About PI-Urgent

Jeelani sjeelani at infinitymarkets.com
Wed Jan 10 04:27:00 PST 2001


Hi,

I have used getMixedContent to set the ProcessingInstruction and Comment,
Reason being  if I use 
	Document_Obj.addContent(ProcessingInstruction p);
	Document_Obj.addContent(Comment c);
Both PI and comment are appearing at the end of document after root element.

After setting the content using setMixedContent(),still when I try to get the root element, it is returning null;

I also have a feeling that since get/setMixedContent can contain only Root Element, PI and Comment,
it doesn't really make sense of using it when addCotent(PI) and addContent(Comment) are provided.
and I didn't get the logic behind implemetation of addContent(PI) and addContent(Comment) to append
the same at the end of document.

---CODE

Element eRoot = new Element("PriceCheckResult");
Document doc = new Document(eRoot);

ProcessingInstruction process = new ProcessingInstruction("PIName","PIValue");
Comment comment = new Comment("Instance of PriceCheckResult");

List list = doc.getMixedContent();
list.add(0,process);
list.add(1,comment);

System.out.println("-size of list "+list.size());
System.out.println(list.get(0).toString());
System.out.println(list.get(1).toString());
System.out.println(list.get(2).toString());

doc = doc.setMixedContent(list);

Element eRoot1 = doc.getRootElement();
if(eRoot1 == null)
	System.out.println("root element is null");
else
	System.out.println("root element is not null");

-------OUTPUT

-size of list 3
[Processing Instruction: <?name value?>]
[Comment: <!--Instance of PriceCheckResult-->]
[Element: <PriceCheckResult />]
root element is null

Thanks and Regards,
Jeelani




More information about the jdom-interest mailing list