Generating a WSDL from an XSD file

You cannot – a XSD describes the DATA aspects e.g. of a webservice – the WSDL describes the FUNCTIONS of the web services (method calls). You cannot typically figure out the method calls from your data alone. These are really two separate, distinctive parts of the equation. For simplicity’s sake you would often import your … Read more

JAXB: How to change XJC-generated classes names when attr type is specified in XSD?

JAXB provides two ways to accomplish this: 1. Inline Schema Anntotations You can use JAXB schema annotations to control the class names. <xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema” xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb” jaxb:version=”2.1″> <xs:complexType name=”itemType”> <xs:annotation> <xs:appinfo> <jaxb:class name=”Item”/> </xs:appinfo> </xs:annotation> <xs:attribute name=”id” type=”xs:string” use=”required”/> </xs:complexType> </xs:schema> 2. External Binding File This customization can also be done via and external binding file: … Read more

How can I tell jaxb / Maven to generate multiple schema packages?

I had to specify different generateDirectory (without this, the plugin was considering that files were up to date and wasn’t generating anything during the second execution). And I recommend to follow the target/generated-sources/<tool> convention for generated sources so that they will be imported in your favorite IDE automatically. I also recommend to declare several execution … Read more

What is the difference between XML and XSD?

Actually the XSD is XML itself. Its purpose is to validate the structure of another XML document. The XSD is not mandatory for any XML, but it assures that the XML could be used for some particular purposes. The XML is only containing data in suitable format and structure.

Generating XML file using XSD file

Suppose we have Test.xsd file that looks like this: <?xml version=”1.0″?> <xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <xs:element name=”MyClass”> <xs:complexType> <xs:sequence> <xs:element name=”Field1″ type=”xs:string”/> <xs:element name=”Field2″ type=”xs:string”/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Create classes using xsd tool: xsd.exe /classes Test.xsd This will generate Test.cs file. Add Test.cs file to your solution. Create instance of MyClass, defined in XSD schema and … Read more

XML Schema How to Restrict Attribute by Enumeration

The numerical value seems to be missing from your price definition. Try the following: <xs:simpleType name=”curr”> <xs:restriction base=”xs:string”> <xs:enumeration value=”pounds” /> <xs:enumeration value=”euros” /> <xs:enumeration value=”dollars” /> </xs:restriction> </xs:simpleType> <xs:element name=”price”> <xs:complexType> <xs:extension base=”xs:decimal”> <xs:attribute name=”currency” type=”curr”/> </xs:extension> </xs:complexType> </xs:element>

XML namespaces and attributes

Most of the time, attributes will not be in any namespace. The namespace spec says (emphasis mine): A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear. There’s … Read more