xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brenda K Hamilton <Brenda.Hamil...@turner.com>
Subject XMLBean/SAX error
Date Fri, 04 Jun 2004 15:11:10 GMT
I can use parse this XML file as a DOM without an error.  I can use the
SAX parser on the same file without an error.  When I use the XMLBean
parser, which is wrapping the SAX parser, I get this error.  I haven't
been able to find what the problem here.  I've included both my program
and the xml file.

I'd really appreciate hearing suggestions.

thanks,
Brenda Hamilton

<FEED TYPE="STORY">
  <HEADER PRIORITY="NORMAL">
    <HEADLINE>Police, Firefighters Propose Income Tax
Increase</HEADLINE>
  </HEADER>
  <BODY>
    <PARAGRAPH>
Cleveland police and fire are taking action to get the laid-off officers
and firefighters back on the streets, reported John Smith.
    </PARAGRAPH>
  </BODY>
</FEED>

import java.io.File;

import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.XmlError;

public class FeedsTest
{
    public static void main(String[] args)
    {
        String xmlFileName = "Simple.xml";

        try
        {
            File feedDoc = new File(xmlFileName);
            if(feedDoc.exists())
                System.out.println(xmlFileName + " exists");
            else
            {
                System.out.println(xmlFileName + " does not exist,
exiting");
                System.exit(-1);
            }

            XmlOptions opts = new XmlOptions();
            opts.setCompileNoValidation();
            System.out.println("Using XmlObject.Factory.parse to parse "
+ xmlFileName);
            XmlObject xobj = XmlObject.Factory.parse(xmlFileName,opts);
            System.out.println(xmlFileName + " parsed");
        }
        catch(XmlException spe)
        {
            XmlError err = spe.getError();
            int lin = err.getLine();
            int col = err.getColumn();
            System.err.println("FeedsTest: main: XmlException: Line: " +
lin + ", Col: " + col);
            System.err.println(spe.getMessage());
            spe.printStackTrace();
            System.exit(-2);
        }
        catch(Exception xmle)
        {
            xmle.printStackTrace();
            System.err.println("FeedsTest: main: Exception: " +
xmle.getMessage());
            System.exit(-1);
        }
    }
}




- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message