Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Non-whitespace characters are not allowed ...

843834Sep 14 2005 — edited May 2 2008
I'm trying to parse the following XML fragment into a DOM Document object:
<CNetSpecs><section name="General
"><spec name="Printer Type
">Personal printer - ink-jet - colour
</spec><spec name="Weight
">6.4 kg
</spec></section><section name="Printer
"><spec name="Print Speed
">Up to 15 ppm - black draft ? Up to 15 ppm - colour draft ? Up to 0.65 min/page - photo best - 101.6 x 152.4 mm ? Up to 1.28 min/page - photo best - 203 x 254 mm
</spec><spec name="Built-in Devices
">Preview screen
</spec><spec name="Max Resolution ( B&W )
">5760 dpi x 1440 dpi
</spec><spec name="Max Resolution ( Colour )
">5760 dpi x 1440 dpi
</spec></section><section name="Software / System Requirements
"><spec name="OS Required
">Microsoft Windows 98 Second Edition / Windows ME, Apple MacOS X 10.1, Apple MacOS X 10.2, Microsoft Windows 2000 / XP, Apple MacOS 8.6 - 9.2
</spec></section></CNetSpecs>
The fragment is pulled out of a text field in a database.

The code I'm using to do the parseing is:
// Parse the CNet XML into a proper doc.
DOMParser parser = new DOMParser();
parser.parse(new InputSource(new StringReader(cnetSpecs)));
org.w3c.dom.Document cnetXml = parser.getDocument();
xmlUtil.toFile(cnetXml, "/tmp/cnetxml.xml");
NodeList cnetRoot = cnetXml.getElementsByTagName("CNetSpecs");
		
Node CNetStatsNode = xml.importNode(cnetRoot.item(0), true);
		
root.appendChild(CNetStatsNode);
and I get the following errors:
[Error] :1:107: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Personal printer - ink-jet - colour'.
[Error] :1:150: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '6.4 kg'.
[Error] :1:391: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Up to 15 ppm - black draft ? Up to 15 ppm - colour draft ? Up to 0.65 min/page - photo best - 101.6 x 152.4 mm ? Up to 1.28 min/page - photo best - 203 x 254 mm'.
[Error] :1:452: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Preview screen'.
[Error] :1:528: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '5760 dpi x 1440 dpi'.
[Error] :1:603: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '5760 dpi x 1440 dpi'.
[Error] :1:847: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Microsoft Windows 98 Second Edition / Windows ME, Apple MacOS X 10.1, Apple MacOS X 10.2, Microsoft Windows 2000 / XP, Apple MacOS 8.6 - 9.2'.
Can anyone point me in the right direction? I've been scratching my head all day.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2008
Added on Sep 14 2005
6 comments
6,171 views