Unmarshaling XML document with no namespace declarations



Given a schema that has a target namespace, such as the example shown below,



<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://ift.tt/tphNwY" elementFormDefault="qualified" targetNamespace="http://ift.tt/1Drc5QB" xmlns:messaging="http://ift.tt/1Drc5QB">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="messaging:CustAddress"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CustAddress">
<xs:complexType>
<xs:sequence>
<xs:element ref="messaging:AddressLine"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AddressLine" type="xs:string"/>
</xs:schema>


How do I unmarshall a XML instance that does not have any namespaces, such as this one:



<?xml version="1.0" encoding="UTF-8"?>
<Customer>
<CustAddress>
<AddressLine>Address Line 1</AddressLine>
</CustAddress>
</Customer>


I keep running into error: file:/C:/customer.xml; lineNumber: 2; columnNumber: 11; cvc-elt.1: Cannot find the declaration of element 'Customer'


Is there anyway to be able to unmarshall this XML? While I do not have control over how the XML is generated, I can modify the schema if needed.


Thanks Aspi


No comments:

Post a Comment