Jump to content

Xml Namespace(S)


eTianbun

Recommended Posts

It just means that the two tables have different meanings, most likely you'll want the program to treat both of them differently, so the namespace is used to determine which <table> element is for what.

Link to comment
Share on other sites

Well, is there a big difference between <h:table> and <h_table>? It's just the standard that was chosen. Anyways, the <h_table> element is no longer the same thing as the <table> element. A browser wouldn't render a table if it found <h_table> For example, when using XSL to display an XML document as XHTML, the XHTML elements will display properly if it has the XHTML namespace assigned, while it will display as a normal XML document if not.

Link to comment
Share on other sites

Using the standard also allows you to declare the "prefix" once, and then continue without it, e.g.

<html xmlns="http://www.w3.org/1999/xhtml">  <head>    <title>Page with the circle (visible in browser's title bar)</title>  </head>  <body>    <svg xmlns="http://www.w3.org/2000/svg" version="1.1">      <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red">        <title>The circle (visible as a tooltip)</title>      </circle>    </svg>  </body></html>

If we were forced to use prefixes, this would look more like:

<h_html>  <h_head>    <h_title>Page with the circle (visible in browser's title bar)</h_title>  </h_head>  <h_body>    <s_svg version="1.1">      <s_circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red">        <s_title>The circle (visible as a tooltip)</s_title>      </s_circle>    </s_svg>  </s_body></s_html>

And you better not have any desire to use "h_" or "s_" as a prefix for your elements, or you might be in conflicts with them... that's the additional feature of namespaces - you can designate any prefix you want for a namespace, rather than being forced with a prefix the language defines.

Link to comment
Share on other sites

  • 2 weeks later...

Using the prefix notation is also more error-prone, as boen_robot demonstrates :P.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...