Code used to create object with sample data is as follows is below.

  VinDecodeRequest req = 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]

Reply via email to