Understanding xsd:choice and minOccurs

I tell you you can go to the shops at least once and at most twice, and each time you have a choice of what to buy: you can buy apples (either one apple or two apples), or you can buy oranges (either no oranges or one orange). It’s entirely possible that you will choose … Read more

XML Schema: Element that can contain elements or text?

I did some research on this a while ago and the only solution I found was to used the mixed attribute: <xs:element name=”field”> <xs:complexType mixed=”true”> <xs:sequence> <xs:element ref=”subfield” minOccurs=”0″ maxOccurs=”unbounded” /> </xs:sequence> <xs:attribute name=”name” type=”xs:string” /> </xs:complexType> </xs:element> This sadly also allows <field name=”test_field_0″> Some text I’m sure you don’t want. <subfield>Some text.</subfield> More text … Read more

How to validate xml against xsd and get *ALL* errors?

Between Validator validator = schema.newValidator(); and StreamSource xmlFile = new StreamSource(xml); add this fragment: final List<SAXParseException> exceptions = new LinkedList<SAXParseException>(); validator.setErrorHandler(new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { exceptions.add(exception); } @Override public void fatalError(SAXParseException exception) throws SAXException { exceptions.add(exception); } @Override public void error(SAXParseException exception) throws SAXException { exceptions.add(exception); } }); This … Read more

MinOccurs 0 and nillable true

Setting nillable=”true” means that the <birthDate> tag can appear as follows: <birthDate xsi:nil=”true”/> However, since you also set minOccurs=”0″, you could also omit the <birthDate> tag completely from the XML and it would also still validate against your XSD. Note that <birthDate/> or <birthDate></birthDate> is not considered null according to XSD rules. Have a look … Read more

Can I have one XML Schema (XSD) include another XML-Schema?

There are two methods for this. <xsd:include schemaLocation=”pathToFile” /> should be used for including files of the same namespace. <xsd:import namespace=”namespace” schemaLocation=”pathToFile” /> should be used for include files in a different namespace. Usually you will specify the namespace given as the targetNamespace of the imported schema.

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