I have trouble constructing an .xsd to validate the following simple XML:
------
<?xml version = "1.0" encoding="UTF-8"?>
<FormatSpec FormatName="Tes t" Encoding="ISO-8859-1" TableName="Reco rdSet"
xmlns="http://www.xyz.com"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="FormatSpec .xsd">
<RowSpec Iterations="1">
<ColSpec BeginOffset="0" EndOffset="8" RegExMatch="udg start"/>
</RowSpec>
<RowSpec RowName="Record ">
<ColSpec BeginOffset="0" EndOffset="12" ColName="Buildi ngId"/>
<ColSpec BeginOffset="17 " EndOffset="21" ColName="StartD ateYear"/>
<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="windo ws-1252" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xyz.com"
targetNamespace ="http://www.xyz.com"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d">
<!-- Entry point? -->
<xs:element name="FormatSpe c" type="FormatSpe cType"/>
<xs:complexTy pe name="FormatSpe cType">
<xs:sequence maxOccurs="unbo unded" minOccurs="0">
<xs:element name="RowSpec" type="RowSpecTy pe"/>
</xs:sequence>
<xs:attribute name="FormatNam e" type="xs:normal izedString"/>
<xs:attribute name="Encoding" type="xs:normal izedString"
default="ISO-8859-1"/>
<xs:attribute name="TableName " type="xs:normal izedString"
default="Record Set"/>
</xs:complexType>
<xs:complexTy pe name="RowSpecTy pe">
<xs:sequence maxOccurs="unbo unded" minOccurs="0">
<xs:element name="ColSpec" type="ColSpecTy pe"/>
</xs:sequence>
<xs:attribute name="Iteration s" default="999999 9"
type="xs:positi veInteger"/>
<xs:attribute name="RowName" type="xs:normal izedString"
default="Record "/>
</xs:complexType>
<xs:complexTy pe name="ColSpecTy pe">
<xs:attribute name="BeginOffs et" type="xs:nonNeg ativeInteger"
default="0"/>
<xs:attribute name="EndOffset " type="xs:positi veInteger"/>
<xs:attribute name="Trim" default="false"
type="xs:boolea n"/>
<xs:attribute name="RegExMatc h" type="xs:string "/>
<xs:attribute name="ColName" type="xs:normal izedString"/>
</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="Tes t" Encoding="ISO-8859-1" TableName="Reco rdSet"
xmlns="http://www.xyz.com"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="FormatSpec .xsd">
<RowSpec Iterations="1">
<ColSpec BeginOffset="0" EndOffset="8" RegExMatch="udg start"/>
</RowSpec>
<RowSpec RowName="Record ">
<ColSpec BeginOffset="0" EndOffset="12" ColName="Buildi ngId"/>
<ColSpec BeginOffset="17 " EndOffset="21" ColName="StartD ateYear"/>
<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="windo ws-1252" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xyz.com"
targetNamespace ="http://www.xyz.com"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d">
<!-- Entry point? -->
<xs:element name="FormatSpe c" type="FormatSpe cType"/>
<xs:complexTy pe name="FormatSpe cType">
<xs:sequence maxOccurs="unbo unded" minOccurs="0">
<xs:element name="RowSpec" type="RowSpecTy pe"/>
</xs:sequence>
<xs:attribute name="FormatNam e" type="xs:normal izedString"/>
<xs:attribute name="Encoding" type="xs:normal izedString"
default="ISO-8859-1"/>
<xs:attribute name="TableName " type="xs:normal izedString"
default="Record Set"/>
</xs:complexType>
<xs:complexTy pe name="RowSpecTy pe">
<xs:sequence maxOccurs="unbo unded" minOccurs="0">
<xs:element name="ColSpec" type="ColSpecTy pe"/>
</xs:sequence>
<xs:attribute name="Iteration s" default="999999 9"
type="xs:positi veInteger"/>
<xs:attribute name="RowName" type="xs:normal izedString"
default="Record "/>
</xs:complexType>
<xs:complexTy pe name="ColSpecTy pe">
<xs:attribute name="BeginOffs et" type="xs:nonNeg ativeInteger"
default="0"/>
<xs:attribute name="EndOffset " type="xs:positi veInteger"/>
<xs:attribute name="Trim" default="false"
type="xs:boolea n"/>
<xs:attribute name="RegExMatc h" type="xs:string "/>
<xs:attribute name="ColName" type="xs:normal izedString"/>
</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
Comment