Validate against schema, but ignore the rest

Andy (54)

Usenet Archive
Joined
Mar 22, 2004
Messages
4
Reaction score
0
Hello All!

Is there any way to validate XML document agains schema, but at the same time ignore any attributes or elements that are not specified in schema?

Example:
<Customer>
<LastName></LastName>
<FirstName></FirstName>
<Age></Age>
<AnyNode/>
</Customer >

Assume that schema only define LastName, and FirstName. How can Age be ignored without knowing that it is Age?
How can AnyNode be ignored?

Thank you
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Andy wrote:

Is there any way to validate XML document agains schema, but at the same time ignore any attributes or elements that are not specified in schema?

Example:
<Customer>
<LastName></LastName>
<FirstName></FirstName>
<Age></Age>
<AnyNode/>
</Customer >

Assume that schema only define LastName, and FirstName. How can Age be ignored without knowing that it is Age?
How can AnyNode be ignored?

Here is a schema that specifies that <Customer> is a sequence of <LastName>, <FirstName> and an unspecified number of elements that are skipped during validation:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="LastName" type="xs:string" />
<xs:element name="FirstName" type="xs:string" />
<xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element>

</xs:schema>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top