Deserialize object property with StringReader vs XmlNodeReader

It looks like this is a very old XmlNodeReader bug that Microsoft have no intention of fixing. (Archived Microsoft Connect link here). I found a workaround on Lev Gimelfarb’s blog here that adds namespaces to the reader’s NameTable as prefixes are looked up. public class ProperXmlNodeReader : XmlNodeReader { public ProperXmlNodeReader(XmlNode node) : base(node) { … Read more

What does the XML syntax with a colon mean?

The XML syntax, rd:, is a namespace prefix, an abbreviation for a namespace URI. XML Namespaces The purpose of XML namespaces is explained clearly in Section 1, Motivation and Summary of the W3C Recommendation: Namespaces in XML 1.0 (Third Edition): We envision applications of Extensible Markup Language (XML) where a single XML document may contain … Read more

Middle way between XSD all and XSD sequence

Could you just turn your “nationality” thingie into its own complexType and then use that new complex type inside your xs:all? <xs:complexType name=”NationalityType”> <xs:sequence> <xs:element name=”nationality” minOccurs=”1″ maxOccurs=”unbounded” /> </xs:sequence> </xs:complexType> <xs:all> <xs:element name=”name” blabla /> <xs:element name=”email” blabla /> <xs:element name=”nationalities” type=”NationalityType” /> </xs:all> I don’t have anything at hand to test this, so … 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

Using JAXB generated class for an element that requires an integer with a pattern

You could do the following: NumberFormatter You can do this by writing your own formatter: package forum7182533; public class NumberFormatter { public static String printInt(Integer value) { String result = String.valueOf(value); for(int x=0, length = 7 – result.length(); x<length; x++) { result = “0” + result; } return result; } public static Integer parseInt(String value) … 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

What is the purpose of XSD files?

XSD files are used to validate that XML files conform to a certain format. In that respect they are similar to DTDs that existed before them. The main difference between XSD and DTD is that XSD is written in XML and is considered easier to read and understand.