Problem with a XML schema

Discussion in 'XML' started by Patrick, Nov 3, 2006.

  1. Patrick

    Patrick Guest

    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
    Patrick, Nov 3, 2006
    #1
    1. Advertising

  2. Patrick wrote:
    > 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.


    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Nov 3, 2006
    #2
    1. Advertising

  3. Patrick

    Patrick Guest

    Joseph Kesselman a écrit :
    > Patrick wrote:
    >> 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.
    >
    >


    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.
    Patrick, Nov 3, 2006
    #3
  4. Patrick

    Patrick Guest

    Patrick a écrit :
    > Joseph Kesselman a écrit :
    >> Patrick wrote:
    >>> 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.
    >>
    >>

    >
    > 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
    Patrick, Nov 3, 2006
    #4
  5. Sorry I forgot to mention that; glad you got it working.
    Joseph Kesselman, Nov 3, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,518
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    938
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    461
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,243
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,825
Loading...

Share This Page