Question

I have 2 xsds.

I'm trying to redefine some complex type from 1 xsd in the second one.

But I get validation error on the redefinition.

I can't understand why.

The First Xsd (ConfigProperties.xsd):

?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://example.com/configProperties" targetNamespace="http://example.com/configProperties" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="config-properties">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="System"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="System">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="1" maxOccurs="1" name="PushMessageFields" type="PushMessageFields"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="PushMessageFields"/>
</xs:schema>

The Second Xsd (SomeConfigProperties.xsd):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://example.com/SomeConfigProperties"  targetNamespace="http://example.com/SomeConfigProperties"  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">


    <xs:redefine schemaLocation="ConfigProperties.xsd">
        <xs:complexType name="PushMessageFields">
          <xs:complexContent>
            <xs:extension base="PushMessageFields">
              <xs:sequence>
                <xs:element name="color" type="xs:string"/>
              </xs:sequence>
            </xs:extension>
          </xs:complexContent>
        </xs:complexType>
      </xs:redefine>
</xs:schema> 

I get the error in the second XSD: "cannot resolve the name 'PushMessageFields' ".

Where is my problem?

Was it helpful?

Solution

It can't resolve the name because it can't find a PushMessageFields in the http://example.com/SomeConfigProperties namespace. There is none. You can't redefine types from a different target namespace.

Unless you have other errors, it should work if you change the target namespace of your new stylesheet to match the target namespace of the imported one. In your second XSD replace:

<xs:schema xmlns="http://example.com/SomeConfigProperties"   
           targetNamespace="http://example.com/SomeConfigProperties"   ... >

with

<xs:schema xmlns="http://example.com/configProperties"  
           targetNamespace="http://example.com/configProperties"  ...>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top