I'd like to share some news and asks for confirmation.

The problem: I save an XML data in a text file, use parse() method and obtain an invalid document object.

I wrote this test code:

        SchedaCensimento sc = SchedaCensimento.Factory.newInstance();
        Capitolo capitolo = sc.addNewCapitolo();
        // add and set some data to DOM

        // save the text output

        FileOutputStream fos = new FileOutputStream( "try.xml" );
        PrintStream ps = new PrintStream(fos);
        ps.println( sc.xmlText() );
        fos.flush();
        fos.close();
       
        // open the text file
        File f = new File( "try.xml" );
        sc = SchedaCensimento.Factory.parse(f);
        sc.validate();


the validate() method says it's all right. (Of course, you will say)

What's the difference with my previous example?
The presence of the these 2 rows in the xml text file:
<?xml version="1.0" encoding="UTF-8"?>
<SchedaCensimento xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SchedaCensimento.xsd">

So, maybe I should not put those rows... or cut them out in some way.
But I presume there is a way to tell XMLBeans to avoid those data authomatically.
Does anyone knows how to do this?

I looked in XmlOptions javadoc but I didn't find any clues.

Thx again


Bolletta salata? Passa a Yahoo! Messenger with Voice

Reply via email to