xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cezar Andrei" <ce...@bea.com>
Subject RE: Problem with XmlBeans.loadXsd
Date Fri, 23 Jul 2004 18:16:07 GMT
You need to make sure that the xmlObjects you pass in loadXsd() are instanceof  org.w3.x2001.xmlSchema.SchemaDocument
or org.w3.x2001.xmlSchema.SchemaDocument.Schema .

This means that you have to navigate the parsed wsdl object, to the xmlObjects that represent
the schema elements, see v2/src/**/SchemaCompiler.java:703 for details.

Cezar

> -----Original Message-----
> From: Jeffrey Crump [mailto:jcrump@sonicsoftware.com]
> Sent: Friday, July 23, 2004 12:41 PM
> To: xmlbeans-user@xml.apache.org
> Subject: RE: Problem with XmlBeans.loadXsd
> 
> 
> I have little more information on this problem.
> 
> When I extract the schema element from my WSDL and parse it
> "standalone", things work fine:
> 
> File f = new File("sample.xsd");
> SchemaTypeLoader loader = XmlBeans.loadXsd(new XmlObject[] {
> XmlObject.Factory.parse(f)}, new XmlOptions());
> SchemaType t = loader.findDocumentType(new 
> QName("http://ws.cdyne.com",
> "GetLatLong"));
> System.out.println("Type=" + t.toString()); 
> 
>   > Type=D=GetLatLong@http://ws.cdyne.com
> 
> When I parse from the WSDL document directly, things don't go so well:
> 
> File f = new File("ESB_BINDING_Zip2Geo.wsdl");
> SchemaTypeLoader loader = XmlBeans.loadXsd(new XmlObject[] {
> XmlObject.Factory.parse(f)}, new XmlOptions());
> SchemaType t = loader.findDocumentType(new 
> QName("http://ws.cdyne.com",
> "GetLatLong"));
> System.out.println("Type=" + t.toString());
> 
>   > org.apache.xmlbeans.XmlException: Thread main: The 0th supplied
> input is not a schema or a config document: its type is N=
> 
> So it looks like XML Beans is getting confused with the other elements
> in the WSDL document.
> 
> Is there anything I need to do to get WSDL to parse correctly?
> 
> -Jeff
> 
> > -----Original Message-----
> > From: Jeffrey Crump [mailto:jcrump@sonicsoftware.com] 
> > Sent: Friday, July 23, 2004 12:03 PM
> > To: xmlbeans-user@xml.apache.org
> > Subject: RE: Problem with XmlBeans.loadXsd
> > 
> > Trying another tack, I'm attempting to load the schema 
> > definitions from the WSDL directly through XMLBeans:
> > 
> >       File f = new File("mydoc.wsdl");
> >       SchemaTypeLoader loader = XmlBeans.getContextTypeLoader();
> >       XmlObject wsdldoc = loader.parse(f, null, options);
> >       SchemaTypeLoader newLoader = XmlBeans.loadXsd(new 
> > XmlObject[] {wsdldoc});
> > 
> > but then I get this error:
> > 
> > org.apache.xmlbeans.XmlException: Thread main: The 0th 
> > supplied input is not a schema or a config document: its type 
> > is D=definitions@http://www.apache.org/internal/xmlbeans/wsdlsubst
> > 	at
> > org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.forSchema
> > Xml(Schema
> > TypeSystemImpl.java:177)     
> > 
> > Am I missing something? Any help would be greatly appreciated.
> > 
> > -Jeff
> > 
> > > -----Original Message-----
> > > From: Jeffrey Crump [mailto:jcrump@sonicsoftware.com]
> > > Sent: Thursday, July 22, 2004 4:12 PM
> > > To: xmlbeans-user@xml.apache.org
> > > Subject: RE: Problem with XmlBeans.loadXsd
> > > 
> > > Thanks, Cezar. Alas, your suggestion didn't work.   I'm doing the
> > > initial parse of the WSDL through WSDL4J;  I also need to compile 
> > > documents on-the-fly, so the command line tool isn't an 
> > option.  And I 
> > > really want to avoid parsing the document twice, for 
> > obvious reasons.
> > > Any other ideas?  If you can't tell, I'm new to XML Beans ;-)
> > > 
> > > -Jeff
> > > 
> > > 
> > > > -----Original Message-----
> > > > From: Cezar Andrei [mailto:cezar@bea.com]
> > > > Sent: Thursday, July 22, 2004 4:02 PM
> > > > To: xmlbeans-user@xml.apache.org
> > > > Subject: RE: Problem with XmlBeans.loadXsd
> > > > 
> > > > I think the LoadAdditionalNamespaces option is used only
> > > when parsing
> > > > from text.
> > > > I'm not sure this will work but I suggest you replace: 
> > > > 	> XmlObject schemaObj = 
> XmlObject.Factory.parse(elem); with
> > > > 	> XmlObject schemaObj =
> > > > org.w3.x2001.xmlSchema.SchemaDocument.Factory.parse(elem);
> > > > 
> > > > A better way of doing this would be to parse the WSDL from the 
> > > > beginning with XmlBeans in the context of WSLD schema and 
> > S4S. This 
> > > > way the XmlObjects that represent the schema elements 
> > will have the 
> > > > type assigned to SchemaDocument.
> > > > 
> > > > Cezar
> > > > 
> > > > > -----Original Message-----
> > > > > From: Jeffrey Crump [mailto:jcrump@sonicsoftware.com]
> > > > > Sent: Thursday, July 22, 2004 2:01 PM
> > > > > To: xmlbeans-user@xml.apache.org
> > > > > Subject: Problem with XmlBeans.loadXsd
> > > > > 
> > > > > 
> > > > > 
> > > > > I'm trying to load some a schema definition and I'm
> > > having problems
> > > > > getting XML Beans to recognize my namespaces.
> > > > > 
> > > > > First of all, I have a parsed XML document (it's 
> WSDL) and I've 
> > > > > located the schema element, i.e.,
> > > > > 
> > > > > XmlObject[] = new XmlObject[size]; Element elem = ...
> > > > > XmlObject schemaObj = XmlObject.Factory.parse(elem); 
> > > > > schemaArray[count++] = schemaObj;
> > > > > 
> > > > > Then I try to load the schema:
> > > > > 
> > > > > XmlOptions options = new XmlOptions(); 
> > > > > options.setLoadAdditionalNamespaces(nsMap); 
> > //java.util.Map from 
> > > > > prefix to uri, obtained from the original document that
> > > > elem came from
> > > > > SchemaTypeLoader loader = XmlBeans.loadXsd(schemaArray, 
> > options);
> > > > > 
> > > > > But I get this exception:
> > > > > 
> > > > > 
> > > org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: Can't
> > > > > resolve prefix: xsd
> > > > >   at
> > > > > org.apache.xmlbeans.impl.values.JavaQNameHolder.parse(JavaQNam
> > > > > eHolder.ja
> > > > > va:133)
> > > > >   at
> > > > > org.apache.xmlbeans.impl.values.JavaQNameHolder.set_text(JavaQ
> > > > > NameHolder
> > > > > .java:148)
> > > > > 
> > > > > The map I set into the options maps "xsd" to the 
> > appropriate URI. 
> > > > > 
> > > > > Am I missing something?  How can I get this to work, short of 
> > > > > re-parsing the entire document?
> > > > > 
> > > > > Thanks,
> > > > > Jeff
> > > > > 
> > > > > -
> > > > > 
> > > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > > > 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/
> > > > > 
> > > > > 
> > > > 
> > > > -
> > > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > > 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/
> > > > 
> > > > 
> > > > 
> > > 
> > > -
> > > 
> > 
> ---------------------------------------------------------------------
> > > 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/
> > > 
> > > 
> > > 
> > 
> > - 
> > 
> ---------------------------------------------------------------------
> > 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/
> > 
> > 
> > 
> 
> - 
> ---------------------------------------------------------------------
> 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/
> 
> 

- ---------------------------------------------------------------------
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