Allowing specific elements from another namespace...

Discussion in 'XML' started by Simon Brooke, May 27, 2008.

  1. Simon Brooke

    Simon Brooke Guest

    I have a document type which I'm developing and working with, which is
    currently defined in a DTD, mainly because I still haven't really
    learned to use schemas. In this document type I need to specify that
    some specific elements may have children which are XHTML %Flow;
    elements. It isn't valid for these elements to contain arbitrary
    XHTML, and it isn't valid for other elements in my language to have
    any XHTML children.

    I presume I can't do this in a DTD (except by including the XHTML DTD
    into mine, which would mean that I would end up with the whole of
    XHTML in my namespace, which isn't what I want). But how would I go
    about doing it in a schema?
     
    Simon Brooke, May 27, 2008
    #1
    1. Advertising

  2. Simon Brooke wrote:
    > I have a document type which I'm developing and working with, which is
    > currently defined in a DTD, mainly because I still haven't really
    > learned to use schemas. In this document type I need to specify that
    > some specific elements may have children which are XHTML %Flow;
    > elements. It isn't valid for these elements to contain arbitrary
    > XHTML, and it isn't valid for other elements in my language to have
    > any XHTML children.
    >
    > I presume I can't do this in a DTD (except by including the XHTML DTD
    > into mine, which would mean that I would end up with the whole of
    > XHTML in my namespace, which isn't what I want). But how would I go
    > about doing it in a schema?


    The W3C XML schema language has an xs:any element where you can specify
    a namespace so you can allow any element in the XHTML namespace. You
    can't specify a certain type however so I don't know how you could
    restrict the element children to be of type flow. It might be best to
    import a schema for XHTML and then allow an XHTML div element as the
    child e.g.
    <xs:element ref="xhtml:div"/>
    that way you can then have the other elements inside the div element.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 27, 2008
    #2
    1. Advertising

  3. > I presume I can't do this in a DTD

    DTDs are not namespace aware. You could allow specific elements with a
    particular prefix, and try to set up required/default declarations for
    that prefix to be the intended namespace... but in general if you're
    using namespaces (and these days you should be), you should move to XML
    Schema and handle them properly.

    In schemas, allowing specific elements in another namespace should be
    straightforward: you should be able to bind a prefix to that namespace
    and use the appropriate prefixed QNames in your schema's description of
    legal contents just as you would reference elements within the same
    namespace. There should be examples of this on the web in various schema
    tutorials; I haven't gone hunting for one recently so I don't have a
    good pointer to give you other than the Schema recommendation (which is
    not easy reading).
     
    Joseph J. Kesselman, May 27, 2008
    #3
    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. MENTAT
    Replies:
    8
    Views:
    1,010
    MENTAT
    Apr 4, 2005
  2. Parker Thompson
    Replies:
    0
    Views:
    369
    Parker Thompson
    Apr 29, 2005
  3. Leif K-Brooks
    Replies:
    4
    Views:
    371
    Alan Kennedy
    Feb 12, 2004
  4. Robert Brewer
    Replies:
    1
    Views:
    354
    Alan Kennedy
    Feb 13, 2004
  5. Replies:
    24
    Views:
    617
    =?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
    Dec 1, 2006
Loading...

Share This Page