aspose file tools*
The moose likes XML and Related Technologies and the fly likes Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Exception" Watch "Exception" New topic
Author

Exception

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi all,
Am building an XML and while paring thru JDOM am getting exception like this..So what might be the reason

org.jdom.JDOMException: Error in building: no protocol:
My XML is like this

<?xml version="1.0" encoding="UTF-8"?>
<MassC>
<AOptions>
<OOptions ALL="" UN="Y" CA="" US="Y" JP="" EU="" />
<TOptions address1="Y" />
</AOptions>
<TradeP>
<Reference>TP1</Reference>
<Reference>TradePPT</Reference>
</TradeP>
</MassC>
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Sounds like the problem isn't with the XML but the instructions your code gives to the JDom parser. Could you post the piece of code telling the parser which document to parse?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
I have built this XML using JDOM
and I convert this to a string and again pass it to JDOM
using the code below

SAXBuilder builder = new SAXBuilder();
org.jdom.Document jDomObj = builder.build(psXML);
And it throws that Exception after this line...
Pls reply urgently
pls Note-- am not using any DTD
Thx
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
I conver that XML into a string like this
StringBuffer loStringBuffer = new StringBuffer();
loStringBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
loStringBuffer.append(xmlOutputter.outputString(eleM));

Where eleM is my root element( which is MassC)
Thx
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Your problem is that you're trying to pass the XML document as a string into a method of which signature is build(java.lang.String systemId) and that causes the exception.
In other words, you need to doinstead of
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Thx Lasse Koskela,

Hats off to u
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception