Schema: element may have "any" content?

L

Lord0

Hi there,

How do I define in a schema that an element (<element>) may have any
content i.e. text, other elements, partial elements, angle brackets
etc?

So all of the following would be valid:

<element>
aaaaaaa<foo/>bbbbbb<bar/>cccccc
</element>

<element>
aaaaaaa<foo>bbbbbb<bar>cccccc
</element>

<element>
<foobbbbbbb<bar>cccccccc
</element>

etd

So I basically would like to tell the parser, via the schema, to ignore
anything between the opening and closing <element> tags

Lord0
 
L

Lord0

I should say that I got as far as this:

<element name="element" minOccurs="1" maxOccurs="unbounded">
<complexType mixed="true">
<sequence>
<any minOccurs="0" maxOccurs="unbounded"
processContents="skip"/>
</sequence>
</complexType>
</element>

But this obviously still tried to "parse" incomplete elements contained
within the element tag.
 
M

Martin Honnen

Lord0 said:
Hi there,

How do I define in a schema that an element (<element>) may have any
content i.e. text, other elements, partial elements, angle brackets
etc?

So all of the following would be valid:

<element>
aaaaaaa<foo/>bbbbbb<bar/>cccccc
</element>

<element>
aaaaaaa<foo>bbbbbb<bar>cccccc

The content has to be well-formed before you can talk about validity at
all so having a <foo> start tag but not closing </foo> is not possible.
</element>

<element>
<foobbbbbbb<bar>cccccccc

Same here, the contents has to be well-formed.
</element>

So I basically would like to tell the parser, via the schema, to ignore
anything between the opening and closing <element> tags

The content has to be well-formed, the parser will not ignore
well-formedness constraints.

As for not doing validation of the contents, look into xs:any and
processContents="skip":

<xs:element name="element" maxOccurs="unbounded">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
R

Richard Tobin

Lord0 said:
So I basically would like to tell the parser, via the schema, to ignore
anything between the opening and closing <element> tags

You can't. Schemas operate on documents that have already been
parsed. All you can do is add constraints to well-formed XML,
not remove them.

-- Richard
 
L

Lord0

"You can't. Schemas operate on documents that have already been
parsed."

Damn - I suspected as much!

BTW Richard how's the Text Mining/PDF parsing etc etc going with
Cognia? :)
 
M

Manuel Collado

Lord0 escribió:
"You can't. Schemas operate on documents that have already been
parsed."

Damn - I suspected as much!

Have you considered using CDATA sections? Its content is not parsed.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top