just to add little infos. with the .xsd that I provide JAXB and Xmlbeans works. Maybe it's not suppose to work with a xml that didn't respect the sequence order (I don't know enough Xml Schemas), but I'm able to unmarshal and marshal.
so for me it's enough for now.. I think.. maybe I'll found a problem later. thanks 2009/12/30 Sebastien Dionne <[email protected]> > thanks. > > I know, It's in my TODO list to understand XML Schemas.. be able to create > them from scratch. Now I'm just trying to make it work until I have time to > read more about that. > > I retrieve a official xsd for upnp device, but few devices use non standard > tags, so I need to support them and that's why I want to add <xs:any> in all > the Type to be sure that I don't lost informations. > > and my program will support jaxb and xmlbeans that why I want to try to > have a xsd that will contains all the informations instead of creating a > custom parser for Xmlbeans and Jaxb. > > So <xs:sequence> won't work :( > > but there is a way to retrieve extra info ? > > > <xs:complexType name="DeviceType"> > <xs:all> > <xs:element name="friendlyName" type="xs:string"/> > <xs:element name="manufacturer" type="xs:string"/> > <xs:element name="manufacturerURL" type="xs:string" > minOccurs="0"/> > <xs:element name="modelDescription" type="xs:string" > minOccurs="0"/> > <xs:element name="modelName" type="xs:string"/> > <xs:element name="modelNumber" type="xs:string" minOccurs="0"/> > <xs:element name="modelURL" type="xs:string" minOccurs="0"/> > <xs:element name="serialNumber" type="xs:string" > minOccurs="0"/> > <xs:element name="UDN" type="xs:string"/> > <xs:element name="UPC" type="xs:string" minOccurs="0"/> > <xs:element name="iconList" type="tns:IconListType" > minOccurs="0"/> > <xs:element name="serviceList" type="tns:ServiceListType" > minOccurs="0"/> > <xs:element name="deviceList" type="tns:DeviceListType" > minOccurs="0"/> > <xs:element name="presentationURL" type="xs:string" > minOccurs="0"/> > <xs:any namespace="##other" minOccurs="0"/> (THAT DOESN'T > WORK) > </xs:all> > > example of XML that I'll receive. > > > <device> > <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType> > <friendlyName>Sebastien Dionne Demo</friendlyName> > <manufacturer>Sebastien Dionne .ca</manufacturer> > > <presentationURL>/index.html</presentationURL> > <dlna:X_DLNADOC > xmlns:ns2="urn:schemas-upnp-org:device-1-0" > xmlns="" > >DMS-1.00</dlna:X_DLNADOC> > </device> > > the extra tag in that case is the <dlna> > > sometime it's custom tags for Xbox and PS3.. > > It would have been lot easier if there were custom tags within the specs.. > > 2009/12/30 Wing Yew Poon <[email protected]> > >> Sebastien, >> you may find it helpful to read up on XML Schema, or at least have a good >> reference on hand; it really is necessary to have a sound understanding of >> it whether you're working with JAXB or XMLBeans. A lot of people needing to >> understand XML Schema because they work with WSDL or other things that use >> it don't bother to acquire even a basic understanding of XML Schema. >> A sequence is a group of elements that must appear in that order. If the >> elements can appear in any order, don't use a sequence. >> If you have >> <xs:sequence> >> <xs:element name="presentationURL" type="xs:string" minOccurs="0"/> >> <xs:any namespace="##other" minOccurs="0"/> >> </xs:sequence> >> that means that presentationURL must appear first, if it does, followed by >> zero or one of any element just not in the target namespace. >> - Wing Yew >> ------------------------------ >> *From:* Sebastien Dionne [mailto:[email protected]] >> *Sent:* Wednesday, December 30, 2009 11:26 AM >> >> *To:* [email protected] >> *Subject:* Re: jaxb to xmlbeans : xmlbeans fail on xs:any >> >> thanks. I was not suspecting a problem with Xmlbeans, is just that Jaxb >> didn't generate error, so I assumed that it was valid some how. >> >> I was able to fix the problem by replacing : >> >> <xs:all> >> ... >> <xs:element name="presentationURL" type="xs:string" minOccurs="0"/> >> </xs:all> >> <xs:anyAttribute namespace="##other" processContents="skip"/> >> >> by >> <xs:sequence> >> <xs:element name="presentationURL" type="xs:string" minOccurs="0"/> >> <xs:any namespace="##other" minOccurs="0"/> >> </xs:sequence> >> >> but I don't know if there will be side effects. >> >> I hope that I didn't broke the order.. I had to be order less. >> >> >> is it OK ? >> >> >> 2009/12/30 Wing Yew Poon <[email protected]> >> >>> It is not weird. And there is nothing weird with XMLBeans. >>> The XMLBeans error tells you exactly what the problem is. >>> If you encounter an error from XMLBeans, I'd advise you to first look to >>> see what you may be doing wrong, instead of thinking XMLBeans is doing >>> something wrong. >>> In this case, your schema is invalid. You cannot have an xs:any in an >>> xs:all group, only xs:element (and xs:annotation). An xs:all group is used >>> to indicate that elements should appear in any order, but no more than once >>> each. It can only contain element declarations and references. >>> - Wing Yew >>> >>> ------------------------------ >>> *From:* Sebastien Dionne [mailto:[email protected]] >>> *Sent:* Wednesday, December 30, 2009 9:30 AM >>> *To:* [email protected] >>> *Subject:* Re: jaxb to xmlbeans : xmlbeans fail on xs:any >>> >>> it wierd.. even jaxb is not able to recompile it. >>> >>> >>> >>> 2009/12/30 Sebastien Dionne <[email protected]> >>> >>>> hello >>>> >>>> I used jaxb to generate schema from java source and now I'm trying to >>>> regenerate java with xmlbeans but it failed on this line >>>> >>>> <xs:any processContents="lax" maxOccurs="unbounded"/> >>>> >>>> if I remove this line it will compile. >>>> >>>> there is something wierd with xmlbeans ? >>>> >>>> >>>> <xs:complexType name="DeviceType"> >>>> <xs:all> >>>> <xs:element name="deviceType" type="xs:string"/> >>>> <xs:element name="friendlyName" type="xs:string"/> >>>> <xs:element name="manufacturer" type="xs:string"/> >>>> <xs:element name="manufacturerURL" type="xs:string" >>>> minOccurs="0"/> >>>> <xs:element name="modelDescription" type="xs:string" >>>> minOccurs="0"/> >>>> <xs:element name="modelName" type="xs:string"/> >>>> <xs:element name="modelNumber" type="xs:string" minOccurs="0"/> >>>> <xs:element name="modelURL" type="xs:string" minOccurs="0"/> >>>> <xs:element name="serialNumber" type="xs:string" minOccurs="0"/> >>>> <xs:element name="UDN" type="xs:string"/> >>>> <xs:element name="UPC" type="xs:string" minOccurs="0"/> >>>> <xs:element name="iconList" type="tns:IconListType" >>>> minOccurs="0"/> >>>> <xs:element name="serviceList" type="tns:ServiceListType" >>>> minOccurs="0"/> >>>> <xs:element name="deviceList" type="tns:DeviceListType" >>>> minOccurs="0"/> >>>> <xs:element name="presentationURL" type="xs:string" >>>> minOccurs="0"/> >>>> <xs:any processContents="lax" maxOccurs="unbounded"/> >>>> </xs:all> >>>> <xs:anyAttribute namespace="##other" processContents="skip"/> >>>> </xs:complexType> >>>> >>>> [ERROR] BUILD ERROR >>>> [INFO] >>>> ------------------------------------------------------------------------ >>>> [INFO] XmlBeans compile failed: >>>> xml ErrorLoading schema file >>>> C:\test\upnp-xsd-xmlbeans-jar\src\main\xsd\device. >>>> xsd >>>> xml ErrorC:\test\upnp-xsd-xmlbeans-jar\src\main\xsd\device.xsd:43:7: >>>> error: cvc- >>>> complex-type.2.4a: Expected element 'element@ >>>> http://www.w3.org/2001/XMLSchema' i >>>> nstead of 'a...@http://www.w3.org/2001/XMLSchema' here in element all@ >>>> http://www. >>>> w3.org/2001/XMLSchema >>>> xml ErrorLoading config file >>>> C:\test\upnp-xsd-xmlbeans-jar\src\main\xsdconfig\de >>>> vice.xsdconfig >>>> >>>> >>> >>> >>> -- >>> ------------- >>> A+ >>> >>> Sébastien. >>> >>> Vous pouvez me suivre sur Twitter / You can follow me on Twitter : >>> http://twitter.com/survivant >>> >> >> >> >> -- >> ------------- >> A+ >> >> Sébastien. >> >> Vous pouvez me suivre sur Twitter / You can follow me on Twitter : >> http://twitter.com/survivant >> > > > > -- > ------------- > A+ > > Sébastien. > > Vous pouvez me suivre sur Twitter / You can follow me on Twitter : > http://twitter.com/survivant > -- ------------- A+ Sébastien. Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant

