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!

element must have a child 1

Status
Not open for further replies.

MaineRunner

Programmer
Aug 28, 2007
5
US
I am working on a schema for validating incoming XML data files. The basic form of the xml coming in should be:


Code:
<job_foo>

    <global_info>
      ...
    </global_info>

    <data>
       print data here
    </data>
    <data>
       more print data
    </data>
    ...more data tags

</job_foo>

In my schema, I want to verfiy that there are elements below the 'data' tag. Validation of that informaiton is done in a second validation step. Therefore this schema only cares that the sending applicaiton has sent something below data tag, but it does not know about the contents of data tags.

Could someone tell/show me a way to use the XML schema to verify there is a child (or children) under 'data'?

Thanks
 
Device the top level element named "data" and refer to it in the job_foo element.
[tt]
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" minOccurs="1" maxOccurs="unbounded" processContents="skip" />
</xs:sequence>
</xs:complexType>
</xs:element>
[/tt]
ps: If you allow mixed type content, put mixed="true" into xs:element tag. If you further allow any attribute to data, add xs:anyAttribute after the xs:sequence.
 
Don't understand what you mean by:

Device the top level element named "data" and refer to it in the job_foo element
 
[tt]<xs:schema xmlns:xs=" elementFormDefault="qualified">>

<xs:element name="data">
<!-- etc etc -->
</xs:element>

<xs:element name="job_foo">
<!-- etc etc : what do you have here? you pose the question as if you have something here -->
<xs:element ref="data" maxOccurs="unbounded" />
<!-- etc etc -->
</xs:element>

<!-- etc etc -->

</xs:schema>[/tt]
 
In the original snippet, the root element of the schema is job_foo. It has the child global_info (occurrs once) and child data (occurs 1 to N).

by "device" you mean to pull out the data element information and put it equal to job_foo in the xsd?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top