I have got xsd with choice statement
<xs:complexType name="opt_type">
<xs:choice>
<xs:element name="opt_1_1" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xsd:string">
<xs:enumeration value="opt_1_1 value 1"/>
<xs:enumeration value="opt_1_1 value 2"/>
<xs:enumeration value="opt_1_1 value 3"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="opt_1_2" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xsd:string">
<xs:enumeration value="opt_1_2 value"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="opt_1_3" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xsd:string">
<xs:enumeration value="opt_1_3 value"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:complexType>
...
<xs:element name="opt" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
...
<xs:element name="opt_1" type="myns:opt_type" minOccurs="0"></xs:element>
...
</xs:sequence>
</xs:complexType>
</xs:element>
I need xforms (I'm working with Orbeon), which will give me, depending on users choice, xml with nodes like those:
<myns:opt_1>
<myns:opt_1_1>opt_1_1 value 1</myns:opt_1_1>
</myns:opt_1>
or
<myns:opt_1>
<myns:opt_1_1>opt_1_1 value 2</myns:opt_1_1>
</myns:opt_1>
or
<myns:opt_1>
<myns:opt_1_1>opt_1_1 value 3</myns:opt_1_1>
</myns:opt_1>
or
<myns:opt_1>
<myns:opt_1_2>opt_1_2 value</myns:opt_1_1>
</myns:opt_1>
or
<myns:opt_1>
<myns:opt_1_3>opt_1_3 value</myns:opt_1_1>
</myns:opt_1>
How can I achieve that?
How should xforms be constructed?
In short you want to change the structure of the XML (using different element names). To do this, your tools should be actions using xf:insert and xf:delete, to insert and delete elements. You need to do this "by hand", as the XForms engine will not do this for you automatically based on the schema.
Related
I have the following schema which I would like to create an enum class
<xs:simpleType name="TopicValuesType">
<xs:union memberTypes="xs:string">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="APPLE"/>
<xs:enumeration value="BANANA"/>
<xs:enumeration value="ORANGE"/>
<xs:enumeration value="#"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="TopicType">
<xs:attribute name="name" type="TopicValuesType" use="required"/>
</xs:complexType>
I've tried to create a binding class but it doesn't work.
<bindings schemaLocation="MySchema.xsd">
<globalBindings typesafeEnumBase="xs:string" typesafeEnumMemberName="generateName" />
</bindings>
I've read this post XJC does not generate enum inside xs:union where it's not possible to create enum.
Is there any other way to create enum out of this schema? Unfortunately I'm unable to edit the schema because it's from a third party.
I'm using maven jaxb2
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
I have created and published a data source with Bing SDS but it is a singular point and am wondering how to create a data source that defines an area?
Essentially I need a geo-fence around a certain point. Below is what my schema currently looks like, what parameters do I need to add to it to define an area?
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<MainRoot>
<xs:schema id="FourthCoffeeShops_ds" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="FourthCoffeeShops_ds" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="FourthCoffeeShops">
<xs:complexType>
<xs:sequence>
<xs:element name="EntityID" type="xs:string" />
<xs:element name="AddressLine" type="xs:string" minOccurs="0" />
<xs:element name="Locality" type="xs:string" minOccurs="0" />
<xs:element name="AdminDistrict" type="xs:string" minOccurs="0" />
<xs:element name="PostalCode" type="xs:string" minOccurs="0" />
<xs:element name="CountryRegion" type="xs:string" minOccurs="0" />
<xs:element name="Phone" type="xs:string" minOccurs="0" />
<xs:element name="Manager" type="xs:string" minOccurs="0" />
<xs:element name="Latitude" type="xs:double" minOccurs="0" />
<xs:element name="Longitude" type="xs:double" minOccurs="0" />
<xs:element name="Confidence" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//FourthCoffeeShops" />
<xs:field xpath="EntityID" />
</xs:unique>
</xs:element>
</xs:schema>
<FourthCoffeeShops>
<EntityID>1000</EntityID>
<AddressLine>1 Microsoft Way</AddressLine>
<Locality>Redmond</Locality>
<AdminDistrict>WA</AdminDistrict>
<PostalCode>98052</PostalCode>
<Phone>303-555-0188</Phone>
<Manager>Alan Steiner</Manager>
<Latitude>47.640049</Latitude>
<Longitude>-122.129797</Longitude>
<Confidence>High</Confidence>
</FourthCoffeeShops>
<FourthCoffeeShops>
<EntityID>1001</EntityID>
<AddressLine>1 Microsoft Way</AddressLine>
<Locality>Redmond</Locality>
<AdminDistrict>WA</AdminDistrict>
<PostalCode>98052</PostalCode>
<CountryRegion>United States</CountryRegion>
<Phone>425-555-0111</Phone>
<Manager>Phil Spencer</Manager>
<Latitude>47.639767</Latitude>
<Longitude>-122.129959</Longitude>
<Confidence>Medium</Confidence>
</FourthCoffeeShops>
</MainRoot>
To be clear by an area I mean a certain radius around a location or a polygon that contains the location.
Thanks!
You can create a column that is of type "Edm.Geography" or "xs:anyType". This property type takes in Well Known Text, a standard way of representing spatial shapes as text. This allows you to store common spatial shapes such as Point, LineString, Polygon, Multipoint, MultiLineString, MultiPolygon, GeometryCollection. Here is the documentation around this:
https://msdn.microsoft.com/en-us/library/gg585138.aspx
https://msdn.microsoft.com/en-us/library/dn436149.aspx
To represent a GeoFence you will want to create a Polygon that represents the area you want. If you want to represent a circle you will need to calculate the points that approximate the circle: http://pietschsoft.com/post/2008/02/09/Virtual-Earth-Draw-a-Circle-Radius-Around-a-LatLong-Point
Here is a blog post on using Geofences stored in SDS with tracked devices: http://blogs.msdn.com/b/bingdevcenter/archive/2014/04/03/geo-fencing-with-bing-spatial-data-services-and-azure-mobile-services.aspx
Does anyone know what extra classes parameter from Java2WSDL tool mean?
Java2DSDL Reference
I am looking to answer this question, but have no success.
It is used to include those types in WSDL definition whose parents appears as return types or parameters. Consider very simple example:
public class DemoService {
public Animal pickRandomAnimal() {
return new Dog(); // or any other animal
}
}
.. where Animal is an interface. At a WSDL generation time Axis2 will not be able to automatically trace all possible implementations of Animal that you might expect to be returned. Without extraClasses you'll get something like this:
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://demo.com/xsd">
<xs:complexType name="Animal">
<xs:sequence>
<xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
.. and if you add extraClasses="com.demo.Dog", you'll cover all types you need in your WSDL schema part:
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://demo.com/xsd">
<xs:complexType name="Animal">
<xs:sequence>
<xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Dog">
<xs:sequence>
<xs:element minOccurs="0" name="animalName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
With C# and .Net 4.0, I have a recursive XSD schema. XML based on that XSD serializes just fine with XmlSerializer. It also deserializes with no errors, but without retrieving all of the elements.
Here's a snippit from the XSD:
<xs:complexType name="SettingGroup">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Notes" type="xs:string" minOccurs="0" />
<xs:element name="SettingGroup" type="SettingGroup" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="Setting" type="Setting" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
Note that the type SettingGroup recursively contains 0 or more SettingGroup elements, and also 0 or more elements of a different type named Setting. It works well when a SettingGroup contains just SettingGroups or when it contains just Settings. But, when the SettingGroup has both SettingGroups and Settings, although it serializes as expected, when deserialized, all of the Settings elements are missing.
I have also tried using ref, with similar results:
<xs:element ref="SettingGroup" minOccurs="0" maxOccurs="unbounded" />
I created the .xsd file by hand, and used xsd.exe to create the C# classes.
In case it may be of use, here's the definition of Setting:
<xs:complexType name="Setting">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Notes" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="Roam" type="xs:boolean" minOccurs="0" default="true" />
<!--<xs:element name="RoamConditions" type="RoamConditions" />-->
<xs:element name="SettingLocation" type="SettingLocation" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
I'd appreciate any suggestions about why deserialization can't retrieve all elements.
I have a problem with the XJC tool that it doesn't generate an Enum class for the attribute myEnum using this schema.
<xs:element name="myClass">
<xs:complexType>
<xs:attribute name="myEnum" >
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
<xs:enumeration value="C"/>
<xs:enumeration value="M"/>
<xs:enumeration value="S"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
but it generates it if I use only this
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
<xs:enumeration value="C"/>
<xs:enumeration value="M"/>
<xs:enumeration value="S"/>
</xs:restriction>
</xs:simpleType>
here is the external binding file content :
<?xml version="1.0" encoding="UTF-8" ?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
version="2.1" xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<globalBindings typesafeEnumMemberName="generateName">
</globalBindings>
</bindings>
You could try this: define a small XSD file with just that particular type declared as a global type, e.g.:
<xs:simpleType name="myEnumSimpleType">
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
<xs:enumeration value="C"/>
<xs:enumeration value="M"/>
<xs:enumeration value="S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="myClass">
<xs:complexType>
<xs:attribute name="myEnum" type="myEnumSimpleType">
</xs:complexType>
</xs:element>
That will generate a JAXB class (let's call it the 'artificial JAXB class).
Then you can run xjc on the larger XSD and customize the generation to make use of this type for the particular elements.
Alternately, if the JAXB generation from this external XSD is a one-time operation (and then you put the JAXB-generated code in your SVN/Git for instance), then you can rewrite that potion of the code to use your 'artificial' JAXB type instead.
Another you may want to try is to have your binding customization
<globalBindings typesafeEnumMemberName="generateName">
not be a global one, but use expression to try to nail it exactly on this type. It is likely that JAXB will generate a new class for each occurrence, even though they are going to be the same.
Since I find xpath tedious, I would test it out quickly on a local copy of that big XSD, that you modify with the namespace, e.g.
<xs:element name="myClass">
<xs:complexType>
<xs:attribute name="myEnum" >
<xs:simpleType >
<xs:annotation>
<xs:appinfo>
<jaxb:typesafeEnumClass/>
</xs:appinfo>
</xs:annotation> <xs:restriction base="xs:string">
<xs:maxLength value="1"/>
<xs:enumeration value="C"/>
<xs:enumeration value="M"/>
<xs:enumeration value="S"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>