xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Krouse" <kkro...@bea.com>
Subject RE: New Eclipse Plug-in & SchemaTypeLoader error
Date Mon, 09 Aug 2004 17:03:46 GMT
You need to use a File or an InputStream instead of a String:

schemadoc = SchemaDocument.Factory.parse(new File(filename), options);


--k

________________________________

From: David Remy 
Sent: Monday, August 09, 2004 6:31 AM
To: xmlbeans-dev@xml.apache.org
Subject: RE: New Eclipse Plug-in & SchemaTypeLoader error


you might try replacing schemadoc = loader.parse(filename, null,
options) with schemadoc = SchemaDocument.Factory.parse(filename,
options);

(or did you try this already?)


________________________________

From: Don Stewart [mailto:Don.Stewart@corizon.com] 
Sent: Monday, August 09, 2004 2:51 AM
To: xmlbeans-dev@xml.apache.org
Subject: New Eclipse Plug-in & SchemaTypeLoader error



Hi,

 

I am writing an Eclipse Plug-in for XMLBeans.

 

The framework is complete along with a Nature and Builder.

 

The issue I am having is that I cannot get the SchemaTypeLoader.parse()
operation to work without throwing an exception.

I have gone through the source for SCOMP and this seems to be the method
use to create the in memory representation of the Schema.

 

The schema compiles with SCOMP and validates fine with the XMLBeans
validator, along with XMLSpy, JAXB and Excelon Stylus. When I try
programmatically with XMLBeans I get a SAX exception saying it cannot
find the root element in the schema.

The jar files from XML beans are the first in the classpath. The
following is the snippet where I am (trying) to setup the classloader,
XMLOptions and then parse the schema.

 

        SchemaTypeLoader loader =
XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader())
;

        XmlOptions options = new XmlOptions();

        options.setLoadLineNumbers();

        options.setLoadMessageDigest();

 
options.setLoadSubstituteNamespaces(MAP_COMPATIBILITY_CONFIG_URIS);

        XmlObject schemadoc = null;

            

                        if ( monitor != null ) {

                                    monitor.beginTask("XMLBean Build",
4);

                        }

        try

        {

                                    if ( kind == FULL_BUILD ) {

                                                ArrayList schemas = new
ArrayList();

                                                schemas =
findXSDFilesInProject(getProject(), schemas);

                                                Iterator iter =
schemas.iterator();

                                                while( iter.hasNext() )
{

                                                            IResource
schema = ((IResource)iter.next());

                                                            String
filename = schema.getRawLocation().toOSString();

                                    schemadoc = loader.parse(filename,
null, options);

                                    schemadoc.validate(options);

                                                }

 

The schemadoc = loader.parse(filename, null, options); causes the
following exception:-

 

org.apache.xmlbeans.XmlException: error: Document root element is
missing.

            at
org.apache.xmlbeans.impl.store.Root$SaxLoader.load(Root.java:762)

            at
org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1036)

            at
org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1028)

            at
org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1048)

            at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoa
derBase.java:200)

            at
uk.ltd.grian.eclipse.xmlbeans.XMLBeanBuilder.rebuildXMLBeans(XMLBeanBuil
der.java:157)

            at
uk.ltd.grian.eclipse.xmlbeans.XMLBeanBuilder.build(XMLBeanBuilder.java:6
4)

            at
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:56
4)

            at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.
java:615)

            at org.eclipse.core.runtime.Platform.run(Platform.java:747)

            at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.ja
va:157)

            at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.ja
va:249)

            at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:34
6)

            at
org.eclipse.core.internal.resources.Project.build(Project.java:81)

            at
uk.ltd.grian.eclipse.xmlbeans.XMLBeanNature$1.run(XMLBeanNature.java:34)

            at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)

Caused by: org.xml.sax.SAXParseException: Document root element is
missing.

            at
org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)

            at
org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)

            at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)

            at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)

            at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)

            at
org.apache.xmlbeans.impl.store.Root$SaxLoader.load(Root.java:735)

            ... 15 more

 

The base of the xsd is as follows:-

 

<?xml version="1.0"?>

<xsd:schema targetNamespace="http://www.corizon.com/ps/AdapterFramework"
xmlns:corz="http://www.corizon.com/ps/AdapterFramework"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

</xsd:schema>

 

Can anyone shed some light on this, or point out the deliberate mistake
I am making :o)

 

Regards

 

Don

 


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


Mime
View raw message