Namespaces & prefixed attributes (one more time)

Discussion in 'XML' started by kj, Apr 21, 2004.

  1. kj

    kj Guest

    In an earlier thread, JKrugman posted the following quote:

    > ...the purpose of XML namespaces is to uniquely identify element
    > and attribute names. Unprefixed attribute names can be uniquely
    > identified based on the element type to which they belong, so
    > there is no need identify them further by including them in an
    > XML namespace. In fact, the only reason for allowing attribute
    > names to be prefixed is so that attributes defined in one XML
    > language can be used in another XML language.


    >(from http://www.rpbourret.com/xml/NamespacesFAQ.htm#q5_3)



    This quote suggests that, when designing a schema/DTD one can safely
    let most (if not all) attributes have no namespace (i.e. be
    "unprefixed"); during this design phase, only rarely need one
    specify an attribute as belonging to a namespace (i.e. requiring
    a prefix).

    But I am interested in learning to recognize those rare situations
    in which, as a designer, one *should* put a particular attribute
    in a namespace. This is still very unclear to me. What are the
    requirements that an attribute must fulfill to be a good candidate
    for being placed in a namespace?

    Thanks!

    kj
    --
    NOTE: In my address everything before the period is backwards.
     
    kj, Apr 21, 2004
    #1
    1. Advertising

  2. kj wrote:


    > But I am interested in learning to recognize those rare situations
    > in which, as a designer, one *should* put a particular attribute
    > in a namespace. This is still very unclear to me. What are the
    > requirements that an attribute must fulfill to be a good candidate
    > for being placed in a namespace?


    The one which comes to mind is where the attribute belongs to a
    different namespace than that of the sorrounding element. This is
    relevant e.g. when specifying that the "id" attribute should have the
    properties of the special XML Schema "id" attribute (it has to be unique
    in all the XML document):
    <html:table title="Jack's finest recipies" xsd:id="recipies">
    The "title" attribute doesn't need a namespace, because it is inferred
    from the sorrounding element. The "id" attribute in this case does not
    belong to the html namespace. Using xsd:id can be useful for validation
    purposes.

    --
    Victor
     
    Victor Engmark, Apr 21, 2004
    #2
    1. Advertising

  3. Victor Engmark <> writes:

    > kj wrote:
    >
    > > ... What are the
    > > requirements that an attribute must fulfill to be a good
    > > candidate for being placed in a namespace?


    > The one which comes to mind is where the attribute belongs
    > to a different namespace than that of the sorrounding element.


    This is true.

    > This is relevant e.g. when specifying that the "id" attribute
    > should have the properties of the special XML Schema "id"
    > attribute (it has to be unique in all the XML document):


    > <html:table title="Jack's finest recipies" xsd:id="recipies">


    Er, I'm not sure this is right. The XML Schema namespace does not
    define a top-level attribute named 'id'. It defines a top-level
    simple type named ID (or xsd:ID, if you've bound the 'xsd' prefix to
    "http://www.w3.org/2001/XMLSchema"), which requires its value to be
    unique among the values of that type occurring in a document, just
    like the ID attribute type of DTDs. But no top-level attribute.

    There are occasional proposals for an xml:id attribute which would be
    declared as having type xsd:ID -- indeed, the W3C XML Core Working
    Group published a Working Draft proposing such an attribute just the
    other day (http://www.w3.org/TR/2004/WD-xml-id-20040407/). If you
    changed 'xsd:id' to 'xml:id' in the example above I think the usage
    shown would be correct.


    On the original question, one answer is simple: it makes sense to
    define a top-level attribute when you can say what the attribute means
    without any reference to the meaning or type of the element it appears
    on. An attribute like 'xml:id' qualifies because its meaning
    ('provides an identifier which uniquely identifies the host element
    within the document') can be described without any reference to the
    name, type, or meaning of the host element.

    I hope this helps.

    -C. M. Sperberg-McQueen
    World Wide Web Consortium
     
    C. M. Sperberg-McQueen, Apr 23, 2004
    #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. Quentin Huo

    What's directories prefixed "_vti"?

    Quentin Huo, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,423
    Juan T. Llibre
    Jun 7, 2005
  2. Simon Harris

    Pound sign - Prefixed with Â

    Simon Harris, Jan 28, 2005, in forum: HTML
    Replies:
    3
    Views:
    12,178
    Simon Harris
    Jan 29, 2005
  3. Michael TEpperis

    non-prefixed xmlns attribute

    Michael TEpperis, May 17, 2004, in forum: XML
    Replies:
    1
    Views:
    436
    Richard Tobin
    May 17, 2004
  4. Michael TEpperis

    non-prefixed xmlns attribute

    Michael TEpperis, May 17, 2004, in forum: XML
    Replies:
    0
    Views:
    356
    Michael TEpperis
    May 17, 2004
  5. Brian Davis
    Replies:
    3
    Views:
    195
    Brian Davis
    Jan 19, 2014
Loading...

Share This Page