SUBJECT: XML schema together with XHTML

Discussion in 'XML' started by dantohester@gmail.com, Feb 13, 2007.

  1. Guest

    Hi there,

    I have the following situation:
    I want to create an XML document that contains 2 parts:
    a) a XHTML part (it can be either version 1.0 or 1.1 )
    b) a non XHTML part that contains some information about the first
    part - like the location of that content or some other info on
    different constituents of the first part

    The elements of the second part are defined by an XML schema.

    My question is how to do this in an elegant manner?
    Should I import somehow (I have no idea how) the XHTML schema on the
    part 2 schema? Or should I deal only on the instance XML file with
    this issue (if yes - how)?

    Thanks a lot for the help.

    Daniel
     
    , Feb 13, 2007
    #1
    1. Advertising

  2. wrote:

    > I have the following situation:
    > I want to create an XML document that contains 2 parts:
    > a) a XHTML part (it can be either version 1.0 or 1.1 )
    > b) a non XHTML part that contains some information about the first
    > part - like the location of that content or some other info on
    > different constituents of the first part
    >
    > The elements of the second part are defined by an XML schema.
    >
    > My question is how to do this in an elegant manner?
    > Should I import somehow (I have no idea how) the XHTML schema on the
    > part 2 schema? Or should I deal only on the instance XML file with
    > this issue (if yes - how)?


    You can author the schema for the elements you want to define yourself
    and then, where XHTML elements are allowed, you use xs:any together with
    the XHTML namespace http://www.w3.org/1999/xhtml. On the xs:any element
    you use the attribute processContents="lax", that way the processor will
    validate if a schema for that namespace is known or skip validation if
    no schema is known.
    As for importing an XHTML schema, the W3C has made various efforts at
    doing this, one is <http://www.w3.org/TR/xhtml1-schema/>, it is only a
    note however, not a normative schema. Importing a schema is simply done
    with e.g.
    <xs:import namespac="http://www.w3.org/1999/xhtml"/>
    with an optional URL provided for the schema location.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 13, 2007
    #2
    1. Advertising

  3. Guest

    Martin,
    Thanks for your pointer - it is very useful.
    I am still getting an error on the validation. Maybe I am doing
    something wrong.


    I did this:

    ###schema
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.myTarget.com"
    xmlns="http://www.myTarget.com"
    elementFormDefault="qualified">

    <xsd:element name="LDOC">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="XHTML" minOccurs="1" maxOccurs="1"/>
    <xsd:element ref="META" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    <xsd:element name="XHTML" type="XHTMLType"/>
    <xsd:complexType name="XHTMLType">
    <xsd:complexContent>
    <xsd:restriction base="xsd:anyType">
    <xsd:anyAttribute namespace="http://www.w3.org/1999/
    xhtml" processContents="lax"/>
    </xsd:restriction>
    </xsd:complexContent>
    </xsd:complexType>

    ####### xml file

    <?xml version="1.0" encoding="UTF-8"?>
    <lxx:LCCDOC xmlns:lxx="http://www.myTarget.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.myTarget.com
    file:LDocument_V0.xsd">

    <lxx:XHTML>
    <html></html> <!-- ERROR -->
    </lxx:XHTML>

    <lxx:META>



    On Feb 13, 9:39 am, Martin Honnen <> wrote:
    > wrote:
    > > I have the following situation:
    > > I want to create an XML document that contains 2 parts:
    > > a) a XHTML part (it can be either version 1.0 or 1.1 )
    > > b) a non XHTML part that contains some information about the first
    > > part - like the location of that content or some other info on
    > > different constituents of the first part

    >
    > > The elements of the second part are defined by an XML schema.

    >
    > > My question is how to do this in an elegant manner?
    > > Should I import somehow (I have no idea how) the XHTML schema on the
    > > part 2 schema? Or should I deal only on the instance XML file with
    > > this issue (if yes - how)?

    >
    > You can author the schema for the elements you want to define yourself
    > and then, where XHTML elements are allowed, you use xs:any together with
    > the XHTML namespacehttp://www.w3.org/1999/xhtml. On the xs:any element
    > you use the attribute processContents="lax", that way the processor will
    > validate if a schema for that namespace is known or skip validation if
    > no schema is known.
    > As for importing an XHTML schema, the W3C has made various efforts at
    > doing this, one is <http://www.w3.org/TR/xhtml1-schema/>, it is only a
    > note however, not a normative schema. Importing a schema is simply done
    > with e.g.
    > <xs:import namespac="http://www.w3.org/1999/xhtml"/>
    > with an optional URL provided for the schema location.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    , Feb 13, 2007
    #3
  4. Guest

    My BAD,
    I was making a mistake. Bellow is the good example.
    A problem still arises: the solution works if my XHTML part has an
    XHTM schema header. What if that XHTML is "coordinated" by a DTD? How
    can I still incorporate that part in my XML file?

    I do appreciate your help - Thank you!

    Daniel

    the good XML schema:
    <xsd:element name="XHTML">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:any minOccurs="0" namespace="http://www.w3.org/
    1999/xhtml" processContents="lax"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
     
    , Feb 13, 2007
    #4
    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,665
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    998
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    482
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,329
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    3,175
Loading...

Share This Page