C
Casper B
I have trouble constructing an .xsd to validate the following simple XML:
------
<?xml version = "1.0" encoding="UTF-8"?>
<FormatSpec FormatName="Test" Encoding="ISO-8859-1" TableName="RecordSet"
xmlns="http://www.xyz.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="FormatSpec.xsd">
<RowSpec Iterations="1">
<ColSpec BeginOffset="0" EndOffset="8" RegExMatch="udgstart"/>
</RowSpec>
<RowSpec RowName="Record">
<ColSpec BeginOffset="0" EndOffset="12" ColName="BuildingId"/>
<ColSpec BeginOffset="17" EndOffset="21" ColName="StartDateYear"/>
<ColSpec BeginOffset="55" EndOffset="80" Trim="true" ColName="Name"/>
</RowSpec>
</FormatSpec>
------
My parser (oracle v2 for Java) only seems to validate the top element
and never any attributtes even though I (think) I specify this with the
following .xsd schema:
------
<?xml version="1.0" encoding="windows-1252" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xyz.com"
targetNamespace="http://www.xyz.com"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<!-- Entry point? -->
<xs:element name="FormatSpec" type="FormatSpecType"/>
<xs:complexType name="FormatSpecType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="RowSpec" type="RowSpecType"/>
</xs:sequence>
<xs:attribute name="FormatName" type="xs:normalizedString"/>
<xs:attribute name="Encoding" type="xs:normalizedString"
default="ISO-8859-1"/>
<xs:attribute name="TableName" type="xs:normalizedString"
default="RecordSet"/>
</xs:complexType>
<xs:complexType name="RowSpecType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="ColSpec" type="ColSpecType"/>
</xs:sequence>
<xs:attribute name="Iterations" default="9999999"
type="xsositiveInteger"/>
<xs:attribute name="RowName" type="xs:normalizedString"
default="Record"/>
</xs:complexType>
<xs:complexType name="ColSpecType">
<xs:attribute name="BeginOffset" type="xs:nonNegativeInteger"
default="0"/>
<xs:attribute name="EndOffset" type="xsositiveInteger"/>
<xs:attribute name="Trim" default="false"
type="xs:boolean"/>
<xs:attribute name="RegExMatch" type="xs:string"/>
<xs:attribute name="ColName" type="xs:normalizedString"/>
</xs:complexType>
</xs:schema>
------
What am I doing wrong? Is it impossible to validate attributtes (all
examples I see deal with validating element content).
Regards,
Casper
------
<?xml version = "1.0" encoding="UTF-8"?>
<FormatSpec FormatName="Test" Encoding="ISO-8859-1" TableName="RecordSet"
xmlns="http://www.xyz.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="FormatSpec.xsd">
<RowSpec Iterations="1">
<ColSpec BeginOffset="0" EndOffset="8" RegExMatch="udgstart"/>
</RowSpec>
<RowSpec RowName="Record">
<ColSpec BeginOffset="0" EndOffset="12" ColName="BuildingId"/>
<ColSpec BeginOffset="17" EndOffset="21" ColName="StartDateYear"/>
<ColSpec BeginOffset="55" EndOffset="80" Trim="true" ColName="Name"/>
</RowSpec>
</FormatSpec>
------
My parser (oracle v2 for Java) only seems to validate the top element
and never any attributtes even though I (think) I specify this with the
following .xsd schema:
------
<?xml version="1.0" encoding="windows-1252" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xyz.com"
targetNamespace="http://www.xyz.com"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<!-- Entry point? -->
<xs:element name="FormatSpec" type="FormatSpecType"/>
<xs:complexType name="FormatSpecType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="RowSpec" type="RowSpecType"/>
</xs:sequence>
<xs:attribute name="FormatName" type="xs:normalizedString"/>
<xs:attribute name="Encoding" type="xs:normalizedString"
default="ISO-8859-1"/>
<xs:attribute name="TableName" type="xs:normalizedString"
default="RecordSet"/>
</xs:complexType>
<xs:complexType name="RowSpecType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="ColSpec" type="ColSpecType"/>
</xs:sequence>
<xs:attribute name="Iterations" default="9999999"
type="xsositiveInteger"/>
<xs:attribute name="RowName" type="xs:normalizedString"
default="Record"/>
</xs:complexType>
<xs:complexType name="ColSpecType">
<xs:attribute name="BeginOffset" type="xs:nonNegativeInteger"
default="0"/>
<xs:attribute name="EndOffset" type="xsositiveInteger"/>
<xs:attribute name="Trim" default="false"
type="xs:boolean"/>
<xs:attribute name="RegExMatch" type="xs:string"/>
<xs:attribute name="ColName" type="xs:normalizedString"/>
</xs:complexType>
</xs:schema>
------
What am I doing wrong? Is it impossible to validate attributtes (all
examples I see deal with validating element content).
Regards,
Casper