There is no Unicode byte order mark. Cannot switch to Unicode

The reality of your file’s encoding appears to conflict with that specified by your XML declaration. If your file actually uses one-byte characters, declaring encoding=”utf-16″ won’t change it to use two-byte characters, for example. Try removing the conflicting encoding from the XML declaration. Replace <?xml version=”1.0″ encoding=”utf-16″?> with <?xml version=”1.0″?> You may also be able … Read more

XSD Definition for Enumerated Value

You can define an enumeration within the context of a simpleType. <xs:simpleType name=”color” final=”restriction” > <xs:restriction base=”xs:string”> <xs:enumeration value=”green” /> <xs:enumeration value=”red” /> <xs:enumeration value=”blue” /> </xs:restriction> </xs:simpleType> <xs:element name=”SomeElement”> <xs:complexType> <xs:sequence> <xs:element name=”Color” type=”color” /> </xs:sequence> </xs:complexType> </xs:element>

Validating XML against XSD [duplicate]

Returns simply true or false (also you don’t need any external library): static boolean validateAgainstXSD(InputStream xml, InputStream xsd) { try { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new StreamSource(xsd)); Validator validator = schema.newValidator(); validator.validate(new StreamSource(xml)); return true; } catch(Exception ex) { return false; } }

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

Does XML care about the order of elements?

XML schema compositor “sequence” will enforce ordering I know this is old but I just came upon the post. Until today I would most likely answer the question Does XML care about the order of elements? with No, unless you use a poorly written xml parser. However, today a third party application complained that the … Read more

Generate Json schema from XML schema (XSD) [closed]

Disclaimer: I am the author of Jsonix, a powerful open-source XML<->JSON JavaScript mapping library. Today I’ve released the new version of the Jsonix Schema Compiler, with the new JSON Schema generation feature. Let’s take the Purchase Order schema for example. Here’s a fragment: <xsd:element name=”purchaseOrder” type=”PurchaseOrderType”/> <xsd:complexType name=”PurchaseOrderType”> <xsd:sequence> <xsd:element name=”shipTo” type=”USAddress”/> <xsd:element name=”billTo” type=”USAddress”/> … Read more