Well, yes. However what I've done (intentionally) is to create a schema such that there is no "Document" wrapper. I do not wish to expose a "VinDecodeRequestDocument" to users as it only confuses them and there is no need to manipulate the schema at that level. The schema looks like:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://vindecode.servicebeans.trivin.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sv="http://common.servicebeans.trivin.com" xmlns:vd="http://vindecode.servicebeans.trivin.com" targetNamespace="http://vindecode.servicebeans.trivin.com" elementFormDefault="qualified"> <xs:import namespace="http://common.servicebeans.trivin.com" schemaLocation="ServiceElements.xsd"/> <xs:complexType name="VinDecodeRequest"> <xs:sequence> <xs:element name="ProductID" type="sv:ProductID"/> <xs:element name="SourceCredentials" type="sv:Credentials" minOccurs="0"/> <xs:element name="DestinationCredentials" type="sv:Credentials"/> <xs:element name="DestinationState" type="sv:US-State"/> <xs:element name="Fields" type="sv:Fields"/> </xs:sequence> </xs:complexType> </xs:schema> And what XMLBeans generates is a VinDecodeRequest interface that has the elements above. There is no VinDecodeRequestDocument. This is what I want, and apparently XMLBeans understands this when generated the classes. Now I need it to save and parse VinDecodeRequest objects properly, and that is where the problem lies. Particularly Parsing. Am I asking XMLBeans to do something it cannot do? I really do not wish to add a level of abstraction VinDecodeRequestDocument to the system when all that is ever really used is VinDecodeRequest, both in the XML that is passed around and by the applications that read and populate it. -----Original Message----- From: Bartlett, David HLTH:EX [mailto:[EMAIL PROTECTED] Sent: Friday, February 03, 2006 11:41 AM To: [email protected] Subject: RE: XmlObject.parse xmlFragment workaround? hmmm, well that's slightly different from the way I believe that it is supposed to work. Your code should look something like the following: VinDecodeRequestDocument VinDecodeRequestDoc = VinDecodeRequestDocument.Factory.newInstance(); VinDecodeRequest req = VinDecodeRequestDoc.addNewVinDecodeRequestDoc(); Then you would populate your req object as per normal and when done your save should look like the following: VinDecodeRequestDoc.save(new File("out.txt")); But that is based on how my project is set up. -----Original Message----- From: Paul Grillo [mailto:[EMAIL PROTECTED] Sent: Friday, February 03, 2006 8:31 AM To: [email protected] Subject: RE: XmlObject.parse xmlFragment workaround? Code used to create object with sample data is as follows is below. VinDecodeRequest VinDecodeRequestDoc = VinDecodeRequest.Factory.newInstance(); req.setProductID(100); Fields fds = req.addNewFields(); Field field = fds.addNewField(); field.setName("VIN"); field.setValue("4F4YR12U63TM07491"); try { req.save(new File("out.txt")); ; } catch (IOException ex) {ex.printStackTrace(); } As mentioned, the outgoing text ("out.txt") has <xml-fragment> in it, which of course, is not what I'm looking for. Be that as it may, xml coming in from other clients using our SOA services are sending it with the appropriate "VinDecodeRequest " tags around it. XMLBeans documentation indicates that parse will only work for a document that complies to the Schema. I generate sample data using XMLSpy for that schema and, (of course) it doesn't have xml-fragment in it, it looks like the XML that XMLBeans will not import. So the question I have is, how do I get XmlObject.parse(input) to actually work on XML that conforms to the schema that generated the XMLOject to begin with? Like the documentation says? Looks like this "xml-fragment" issue is getting in the way, and I'm hoping there is a work around or some setting that I need to make to get this to work. As it stands, it looks to me like it is not doing what the documentation appears to claim. thanks. ________________________________ From: Bartlett, David HLTH:EX [mailto:[EMAIL PROTECTED] Sent: Friday, February 03, 2006 11:07 AM To: [email protected] Subject: RE: XmlObject.parse xmlFragment workaround? how are you saving the your object? Normally when you create your actual object you first create a document factory object that you use to create you actual document (VinDecodeRequest). If you save just the actual document it will generate the xml as a fragment because the actual document is considered a part of the document factory object. So to generate a proper xml document you need to save the doucment factory object. So maybe if you save it the proper way you will be able to input it later on. Sorry if my terminology is off. I am new to xmlbeans myself. [Bartlett, David HLTH:EX] -----Original Message----- From: Paul Grillo [mailto:[EMAIL PROTECTED] Sent: Friday, February 03, 2006 7:52 AM To: [email protected] Subject: XmlObject.parse xmlFragment workaround? I have been having problems parsing incoming xml for my XMLBeans object. The classes were generated from XSD Schemas. XMLObjec Class Name: VinDecodeRequest If I populate it and issue oVinDecodeRequest.save(...) it produces the following xml. It places <xml-fragment> where normally integrated with our SOA system the xml-fragment tag is replaced with the the pair of tags: <VinDecodeRequest xmlns="http://vindecode.servicebeans.trivin.com"> </VinDecodeRequest> The input xml below parses: <?xml version="1.0" encoding="UTF-8"?> <xml-fragment> <vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID> <vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com"> <com:Field xmlns:com="http://common.servicebeans.trivin.com"> <com:Name>VIN</com:Name> <com:Value>4F4YR12U63TM07491</com:Value> </com:Field> </vin:Fields> </xml-fragment> The input xml does not parse: <?xml version="1.0" encoding="UTF-8"?> <VinDecodeRequest xmlns="http://vindecode.servicebeans.trivin.com <http://vindecode.servicebeans.trivin.com/> "> <vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID> <vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com <http://vindecode.servicebeans.trivin.com/> "> <com:Field xmlns:com="http://common.servicebeans.trivin.com <http://common.servicebeans.trivin.com/> "> <com:Name>VIN</com:Name> <com:Value>4F4YR12U63TM07491</com:Value> </com:Field> </vin:Fields> </VinDecodeRequest> The ONLY way i seem to be able to read in XML and create the appropriate VinDecodeRequest object is if the XML i'm reading in actually "contains" <xml-fragment> tags. How can i XmlObject.parse to properly parse the incoming XML The code i use is fairly straight forward, i set the schematype to the appropriate class XmlOptions opts = new XmlOptions(); SchemaType type = XmlBeans.typeForClass(com.trivin.servicebeans.vindecode.VinDecodeRequest .class); opts.setDocumentType(type); XmlObject obj = XmlObject.Factory.parse(res.getInputStream(),opts); Is there a simple workaround or explanation? I simply need to be able to parse that second set of XML. thanks for any help or advice. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

