Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help a n00b! :)

Status
Not open for further replies.

redi78

Programmer
Jul 24, 2007
3
CA
i've got an xml and an xsd schema and i'm trying to validate them (using this:
the results are:
Well Formed: VALID
Schema Validation: INVALID

and I'm getting the same error on every element.. the error reads:

s4s-elt-must-match.1: The content of 'ITEMNO' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: restriction.

s4s-elt-must-match.1: The content of 'Company' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: restriction.

etc....

here's my XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="minimalized data.XLS.xsl"?>
<!-- This XML file is generated by RustemSoft XML Converter Evaluation version -->
<table name="NewDataSet">
<CUSTORDS>
<ITEMNO>17803015211</ITEMNO>
<Company>15</Company>
<SHIPTO>25</SHIPTO>
<QUANTITY>50</QUANTITY>
<PONUMBER>59695</PONUMBER>
<REMARKS>Loblaws Inc.</REMARKS>
<DUEDATE>20070530</DUEDATE>
<CUSTNUMBER>NATGRO</CUSTNUMBER>
<STATUS>4</STATUS>
</CUSTORDS>
<CUSTORDS>
<ITEMNO>14313016271</ITEMNO>
<Company>15</Company>
<SHIPTO>25</SHIPTO>
<QUANTITY>70</QUANTITY>
<PONUMBER>59738</PONUMBER>
<REMARKS>Loblaws Inc.</REMARKS>
<DUEDATE>20070601</DUEDATE>
<CUSTNUMBER>NATGRO</CUSTNUMBER>
<STATUS>1</STATUS>
</CUSTORDS>
</table>


and here's my xsd schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs=" <xs:element name="NewDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="CUSTORDS">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ITEMNO" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="32" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Company" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Division" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Corporation" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Sold" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Department" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" fixed="KIKMRI" name="SHIPTO" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="12" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="QUANTITY" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="8" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="Filler" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="0" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="PONUMBER" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="13" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="REMARKS" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="30" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="DUEDATE" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="8" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="CUSTNUMBER" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="8" />
</xs:restriction>
</xs:element>
<xs:element minOccurs="0" name="STATUS" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="4" />
</xs:restriction>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>


I haven't had to work wtih XML much at all, so I know *very* little. I've done some googling but i'm still stumped. any help would be greatly appreciated!
 
I am certainly no XML Schema expert, but xs:length is used to require an exact length. Perhaps you are looking for xs:maxLength? Your input document clearly is not valid according to several restrictions.

Tom Morrison
 
thanks for the reply! I've tried using the maxlength property instead, but i'm still getting the same errors. the schema wasn't written by me, it was just handed to me, along with a customer's xml and I was asked to validate the two.
 
oh.. yes.. i left those as length.

i'm still getting the same errors..i.e on the first element still:

s4s-elt-must-match.1: The content of 'ITEMNO' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: restriction.

so something is still amuck

i'm assuming something in here isn't right then:

<xs:element minOccurs="0" name="ITEMNO" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="32" />
</xs:restriction>
</xs:element>
 
To:eek:p
I don't know if you want to put the worst face of RustemSoft (that I don't know anything about) or because of your ignorance make RustemSoft really look bad!

[1] Your schema is wrong from the root down. The root is "table". Your schema implies a root named "NewDataSet". Why is that?

> <xs:element name="NewDataSet">
[tt] <xs:element name="[red]table[/red]">[/tt]

[2] The root has an attribute named name. It is not in the schema.
[tt]
<xs:element name="[red]table[/red]">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<!-- etc etc -->
</xs:choice>
[red]<xs:attribute name="name" type="xs:string" use="required" />[/red]
</xs:complexType>
</xs:element>
[/tt]
[3] The obvious xs:length mismatch... and you let it through posting!

[4] The restriction is not done like that. Are they generated by RustemSoft??? I wonder. Take one out of the repetitive for other elements.
[tt]
[red]<!--[/red] <xs:element minOccurs="0" name="ITEMNO" [red]type="xs:string"[/red]> [red]-->[/red]
[blue]<xs:element minOccurs="0" name="ITEMNO">[/blue]
[blue]<xs:simpleType>[/blue]
<xs:restriction base="xs:string">
[blue]<!-- If xs:length value is not right, put it right. -->[/blue]
<xs:length value="32" />
</xs:restriction>
[blue]</xs:simpleType>[/blue]
</xs:element>
[/tt]
I think that is quite enough for a go and you'll come and say it does not work. Make you own effort. I would say there may still things to correct, but there should not be any major modification of the changes I suggest above.
 
After having had another look, note also this with new illustrative aspect.

[5] If you use fixed on element, you don't restrict.

<xs:element minOccurs="0" fixed="KIKMRI" name="SHIPTO" type="xs:string">
<xs:restriction base="xs:string">
<xs:length value="12" />
</xs:restriction>
</xs:element>

It should be this.
[tt]
<xs:element minOccurs="0" fixed="KIKMRI" name="SHIPTO" />[/tt]

[5.1] And you change the xml in order to be validated.
[tt]
<SHIPTO>[red]KIKMRI[/red]</SHIPTO>
[/tt]
[5.2] If it is not really meant to be that, take out fixed and restore to restrict according to need in the proper way shown previously.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top