Problem with a XML schema

P

Patrick

Hello,

I'm a newbie in XML and I want to create a schema (XSD file) to describe
the syntax of a XML file.

I've this problem : the text of a particular XML tag (called <change>)
may contain HTML tags like <b>, <i>, <ul>, <li> and others.

How can I describe this tag in XSD to allow any HTML tag inside ?

For example, the XML document has the line :

<change date="2006-11-02">Bug fix for <i>Products</i> and <i>Users</i>
in the <b><i>main</i></b> form</change>

Thanks for your help.

Patrick
 
J

Joseph Kesselman

Patrick said:
How can I describe this tag in XSD to allow any HTML tag inside ?

Either spell out the full list of tags, or use xs:any
(http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#Wildcards)

A slightly better answer, I think, would be to explicitly allow XHTML
tags inside -- since XHTML is an XML language (which HTML isn't, so
you'd have to XMLify the HTML anyway) and since that would let you
constrain the xs:any specifically to tags in the XHTML namespace so
folks couldn't drop something completely bogus there.
 
P

Patrick

Joseph Kesselman a écrit :
Either spell out the full list of tags, or use xs:any
(http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#Wildcards)

A slightly better answer, I think, would be to explicitly allow XHTML
tags inside -- since XHTML is an XML language (which HTML isn't, so
you'd have to XMLify the HTML anyway) and since that would let you
constrain the xs:any specifically to tags in the XHTML namespace so
folks couldn't drop something completely bogus there.

Thanks for your quick answer.

I tried xs:any but have still a problem ...

I wrote the following XSD code :

<xsd:complexType name="change_type" mixed="true">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="date"
type="xsd:date"
use="required"/>
</xsd:complexType>

<xsd:element name="change"
type="change_type"
maxOccurs="unbounded"/>

to describe the following XML line :

<change date="2006-11-02">Bug fix for <i>Products</i> and <i>Users</i>
in the <b><i>main</i></b> form</change>

But the validator returns the error :

The element 'i' is not declared

Where is the problem ?

Thanks a lot.
 
P

Patrick

Patrick a écrit :
Joseph Kesselman a écrit :

Thanks for your quick answer.

I tried xs:any but have still a problem ...

I wrote the following XSD code :

<xsd:complexType name="change_type" mixed="true">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="date"
type="xsd:date"
use="required"/>
</xsd:complexType>

<xsd:element name="change"
type="change_type"
maxOccurs="unbounded"/>

to describe the following XML line :

<change date="2006-11-02">Bug fix for <i>Products</i> and <i>Users</i>
in the <b><i>main</i></b> form</change>

But the validator returns the error :

The element 'i' is not declared

Where is the problem ?

Thanks a lot.

A self-answer ...

I had forgotten to add the attribute processContents="skip" in the
xsd:any declaration (an other newbie error).

Now all is ok, the XML is validated.

Thanks ... to me and to the documentation !!!

Patrick
 

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
474,006
Messages
2,570,265
Members
46,861
Latest member
SanoraS48

Latest Threads

Top