elementFormDefault="qualified" validation and gene
Posted: Tue Apr 10, 2007 1:01 am
Hello,
Here's a sample schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:normal.client" xmlns:n1="http://schemas.xmlsoap.org/wsdl/" xmlns:s0="java:normal.client" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myRoot">
<xs:complexType>
<xs:sequence>
<xs:element name="LoanRequest" type="s0:LoanStruct"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="LoanStruct">
<xs:sequence>
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="SSN" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="Rate" nillable="false" type="xs:double"/>
<xs:element minOccurs="0" name="Amount" nillable="false" type="xs:long"/>
<xs:element minOccurs="0" name="NumOfYear" nillable="false" type="xs:int"/>
<xs:element minOccurs="0" name="Notes" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
With elementFormDefault="qualified", elements in local declarations must use qualified element-type names in the instance.
If I understand this correctly, the following instance should be invalid:
<?xml version="1.0" encoding="UTF-8"?>
<myRoot xmlns="java:normal.client"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="java:normal.client file:/C:/TestCases/LoanStruct.xsd">
<LoanRequest>
<Name>Name0</Name>
<SSN>SSN0</SSN>
<Rate>3.14159E0</Rate>
<Amount>922337203</Amount>
<NumOfYear>2147483647</NumOfYear>
<Notes>Notes0</Notes>
</LoanRequest>
</myRoot>
In order to be valid, something like the following would be required:
<?xml version="1.0" encoding="UTF-8"?>
<s0:myRoot xsi:schemaLocation="java:normal.client LoanStruct1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s0="java:normal.client">
<s0:LoanRequest>
<s0:Name>String</s0:Name>
<s0:SSN>String</s0:SSN>
<s0:Rate>3.14159265358979E0</s0:Rate>
<s0:Amount>2147483647</s0:Amount>
<s0:NumOfYear>0</s0:NumOfYear>
<s0:Notes>String</s0:Notes>
</s0:LoanRequest>
</s0:myRoot>
oXygen validates both instance examples, but the first should fail.
The XML document generation feature produces a document instance with the invalid first format.
The brand "X" xml editor works as I would expect with this.
Regards
Here's a sample schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:normal.client" xmlns:n1="http://schemas.xmlsoap.org/wsdl/" xmlns:s0="java:normal.client" xmlns:s1="http://example.org" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myRoot">
<xs:complexType>
<xs:sequence>
<xs:element name="LoanRequest" type="s0:LoanStruct"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="LoanStruct">
<xs:sequence>
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="SSN" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="Rate" nillable="false" type="xs:double"/>
<xs:element minOccurs="0" name="Amount" nillable="false" type="xs:long"/>
<xs:element minOccurs="0" name="NumOfYear" nillable="false" type="xs:int"/>
<xs:element minOccurs="0" name="Notes" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
With elementFormDefault="qualified", elements in local declarations must use qualified element-type names in the instance.
If I understand this correctly, the following instance should be invalid:
<?xml version="1.0" encoding="UTF-8"?>
<myRoot xmlns="java:normal.client"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="java:normal.client file:/C:/TestCases/LoanStruct.xsd">
<LoanRequest>
<Name>Name0</Name>
<SSN>SSN0</SSN>
<Rate>3.14159E0</Rate>
<Amount>922337203</Amount>
<NumOfYear>2147483647</NumOfYear>
<Notes>Notes0</Notes>
</LoanRequest>
</myRoot>
In order to be valid, something like the following would be required:
<?xml version="1.0" encoding="UTF-8"?>
<s0:myRoot xsi:schemaLocation="java:normal.client LoanStruct1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s0="java:normal.client">
<s0:LoanRequest>
<s0:Name>String</s0:Name>
<s0:SSN>String</s0:SSN>
<s0:Rate>3.14159265358979E0</s0:Rate>
<s0:Amount>2147483647</s0:Amount>
<s0:NumOfYear>0</s0:NumOfYear>
<s0:Notes>String</s0:Notes>
</s0:LoanRequest>
</s0:myRoot>
oXygen validates both instance examples, but the first should fail.
The XML document generation feature produces a document instance with the invalid first format.
The brand "X" xml editor works as I would expect with this.
Regards