Schema validating document with any element names

H

Honza Pazdziora

Hello,

I'm processing documents that can have any element names in them. The
only restriction is placed on the attributes of these elements, each
of them can only have two attributes of given names. I'd like to
validate this input.

I can specify this requirement using xsd:any for /root element, like:

<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" processContents="strict"
namespace="##targetNamespace"/>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="ph" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

However, I'm probably missing a way to specify the

<xsd:element name="root">

as a wildcard matching type. I tried

<xsd:any>
<xsd:complexType>
<xsd:sequence>
<xsd:any minOccurs="1" maxOccurs="unbounded" processContents="strict"
namespace="##targetNamespace"/>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="ph" type="xsd:string"/>
</xsd:complexType>
</xsd:any>

but xsd:any is not allowed directly in xsd:schema.

I'd appreciate any pointer that would help me to specify element type
for wildcard name. Likewise, I tried to find a way to achieve this
with DTD but got stuck in the same place -- specifying the <!ELEMENT>
as a wildcard, matching all element names.
 
G

Georg Bauhaus

:
: Hello,
:
: I'm processing documents that can have any element names in them. The
: only restriction is placed on the attributes of these elements, each
: of them can only have two attributes of given names. I'd like to
: validate this input.

Can you assume that input is wellformed?
In this case you could transform the document and replcace
all element names with any one of your choice and thus reduce
the number of element type definitions to 1.


Georg
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top