I am getting this error:
Error:(7, 50) cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceschemaLocation' is not allowed to appear in element 'fieldsMapper'.
My XML file is below:
<?xml version="1.0"?>
<fieldsMapper xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.company.com/core"
xsi:noNamespaceschemaLocation="http://www.company.com/core/fieldsMapper fieldsMapper.xsd"
sourceType="java.util.Map"
targetType="com.company.integration.demo.Transaction"
id="identityValidationInputMapper">
<fields>
<field name="msg_date1" type="Date">
<sourceField name="msg_date" type="String" inputFormat="YYYYMMDD" default="20200407"/>
</field>
<field name="msg[msg_date]" type="String" outputFormat="YYMMDD">
<sourceField name="msg_date" type="Date"/>
</field>
<field name="msg_date2" type="Date">
<sourceField name="msg[msg_date]" type="String" inputFormat="YYYYMMDD"/>
</field>
<field name="output_array[2]" type="Date">
<sourceField name="msg_date" type="String" inputFormat="YYYYMMDD"/>
</field>
<field name="smh_msg_date" type="Date">
<sourceField name="input_array[2]" type="String" inputFormat="YYYYMMDD"/>
</field>
<field name="msg_text" type="String">
<value>
<![CDATA[
Characters with markup
]]>
</value>
</field>
<field name="msg_constant_text" type="String">
<value>NAH</value>
</field>
<field name="order_amount">
<groovy>
just groovy code
</groovy>
</field>
</fields>
</fieldsMapper>
My fieldsMapper.xsd is as below:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="https://www.company.com/core" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="fieldsMapper" type="core:fieldsMapperType" xmlns:core="https://www.company.com/core"/>
<xs:complexType name="sourceFieldType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="inputFormat" use="optional"/>
<xs:attribute type="xs:string" name="default" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="fieldType">
<xs:sequence>
<xs:element type="core:sourceFieldType" name="sourceField" minOccurs="0" xmlns:core="https://www.company.com/core"/>
<xs:element type="xs:string" name="value" minOccurs="0"/>
<xs:element type="xs:string" name="groovy" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:boolean" name="sasDate" use="optional"/>
<xs:attribute type="xs:string" name="outputFormat" use="optional"/>
</xs:complexType>
<xs:complexType name="fieldsType">
<xs:sequence>
<xs:element type="core:fieldType" name="field" maxOccurs="unbounded" minOccurs="0" xmlns:core="https://www.company.com/core">
<xs:annotation>
<xs:documentation>Nested/Mapped field in a Java bean or Map as target Nested/Mapped field in a Java bean or Map as source Indexed field as target (in an array or List) Indexed field as source (in an array or List)</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fieldsMapperType">
<xs:sequence>
<xs:element type="core:fieldsType" name="fields" xmlns:core="https://www.company.com/core"/>
</xs:sequence>
<xs:attribute type="xs:string" name="targetType"/>
<xs:attribute type="xs:string" name="sourceType"/>
<xs:attribute type="xs:string" name="id"/>
</xs:complexType>
</xs:schema>
Any idea why I am getting this error? The XML file is valid and so is the XSD file. I tried changing the elementFormDefault
to unqualified
instead of qualified
but it did not make any difference.
For starters,
xsi:noNamespaceschemaLocation
should be
xsi:noNamespaceSchemaLocation
^
...but you shouldn't even be using xsi:noNamespaceSchemaLocation
since your XML is in a namespace. Use xsi:schemaLocation
instead.
Change
xsi:noNamespaceschemaLocation="http://www.company.com/core/fieldsMapper
fieldsMapper.xsd"
to
xsi:schemaLocation="http://www.company.com/core fieldsMapper.xsd"
Note both xsi:schemaLocation
and the change of the namespace to match your XML's default namespace and the targetNamespace
of the XSD.
See also