[xsde-users] xsd:any and xsd:restriction

antoine.hincelin at non.schneider-electric.com antoine.hincelin at non.schneider-electric.com
Mon Feb 27 13:02:39 EST 2012



Hi,

I would like to know if it is possible to use xsd:restriction on xsd:any
element with XSD/e?

As an example, I try to process 2 files.
First one (test.xml) is:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:scl="http://www.iec.ch/61850/2003/SCL"
xmlns="http://www.iec.ch/61850/2003/SCL"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.iec.ch/61850/2003/SCL"
elementFormDefault="qualified" attributeFormDefault="unqualified"
version="3.1">
	<xs:complexType name="tAnyContentFromOtherNamespace" abstract="true"
mixed="true">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:any namespace="##other" processContents="lax"/>
		</xs:sequence>
		<xs:anyAttribute namespace="##other" processContents="lax"/>
	</xs:complexType>
</xs:schema>


Second one (test2.xml) is:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.xxx.com/IEC61850/SCL"
xmlns:sclext="http://www.xxx.com/IEC61850/SCL"
xmlns:scl="http://www.iec.ch/61850/2003/SCL"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.xxx.com/IEC61850/SCL"
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:import namespace="http://www.iec.ch/61850/2003/SCL"
schemaLocation="test.xsd"/>
	<xs:complexType name="NewType">
		<xs:complexContent mixed="true">
			<xs:restriction base="scl:tAnyContentFromOtherNamespace">
				<xs:sequence minOccurs="0" maxOccurs="unbounded">
					<xs:element name="MyElement" type="xs:int"/>
				</xs:sequence>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>
</xs:schema>


I got the following error:
<<
test2.xsd:8:50: error: unable to match restricted particle
>>

When changing "restriction" to "extension", I got another error:
<<
:0:0: error: complex type 'NewType' violates the unique particle
attribution rule in its components '##other' and 'MyElement'
>>

The goal is to get a derived type in order to use polymorphism, without
modifying first file (test.xsd)

Thanks in advance.

Best regards
Antoine


More information about the xsde-users mailing list