XML validation with XSD: how to avoid caring about the sequence of the elements?

<xsd:complexType name=”questions”> <xsd:all> <xsd:element name=”location” type=”location”/> <xsd:element name=”multipleChoiceInput” type=”multipleChoiceInput”/> <xsd:element name=”textInput” type=”textInput”/> <xsd:element name=”pictureInput” type=”pictureInput”/> </xsd:all> </xsd:complexType> NOTE: I have changed “sequence” to “all” Sequence forces order (as defined). if order doesn’t matter then all is used. If there are chances of element occurence more than once then xsd:any can be used. <xsd:complexType name=”questions”> <xsd:sequence> … Read more

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

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

How to resolve “Could not find schema information for the element/attribute “?

I’ve created a new scheme based on my current app.config to get the messages to disappear. I just used the button in Visual Studio that says “Create Schema” and an xsd schema was created for me. Save the schema in an apropriate place and see the “Properties” tab of the app.config file where there is … Read more

How to generate a Java class which implements Serializable interface from xsd using JAXB?

Serializable Use xjc:serializable in a custom bindings file to add the java.io.Serializable interface to your classes along with a serialVersionUID: <?xml version=”1.0″ encoding=”UTF-8″?> <bindings xmlns=”http://java.sun.com/xml/ns/jaxb” xmlns:xsi=”http://www.w3.org/2000/10/XMLSchema-instance” xmlns:xjc=”http://java.sun.com/xml/ns/jaxb/xjc” xsi:schemaLocation=” http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd” version=”2.1″> <globalBindings> <serializable uid=”1″ /> </globalBindings> </bindings> toString() Use a superclass (see xjc:superClass) from which all your bound classes will inherit. This class won’t be … Read more

Recursion in an XML schema?

if you need a recursive type declaration, here is an example that might help: <xs:schema id=”XMLSchema1″ targetNamespace=”http://tempuri.org/XMLSchema1.xsd” elementFormDefault=”qualified” xmlns=”http://tempuri.org/XMLSchema1.xsd” xmlns:mstns=”http://tempuri.org/XMLSchema1.xsd” xmlns:xs=”http://www.w3.org/2001/XMLSchema” > <xs:element name=”node” type=”nodeType”></xs:element> <xs:complexType name=”nodeType”> <xs:sequence minOccurs=”0″ maxOccurs=”unbounded”> <xs:element name=”node” type=”nodeType”></xs:element> </xs:sequence> </xs:complexType> </xs:schema> As you can see, this defines a recursive schema with only one node named “node” which can be as … Read more

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘init-param’

The order of elements in web.xml matters and in all examples I’ve come across, the <load-on-startup> comes after <init-param>. <servlet> <servlet-name>spring1</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>

cvc-elt.1: Cannot find the declaration of element ‘MyElement’

Your schema is for its target namespace http://www.example.org/Test so it defines an element with name MyElement in that target namespace http://www.example.org/Test. Your instance document however has an element with name MyElement in no namespace. That is why the validating parser tells you it can’t find a declaration for that element, you haven’t provided a schema … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)