eTianbun Posted October 22, 2011 Share Posted October 22, 2011 <example><title>this is html title</title><title>this is a book title</title></example> Why namespace? Is it that if i run the above, i ll get error or what? Link to comment Share on other sites More sharing options...
Ingolme Posted October 23, 2011 Share Posted October 23, 2011 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 More sharing options...
eTianbun Posted October 23, 2011 Author Share Posted October 23, 2011 Why not do it this way, instead of using NS? <h_table><h_tr><h_td> </h_td></h_tr></h_table><f_table><f_color>red</f_color></f_table> Link to comment Share on other sites More sharing options...
Ingolme Posted October 23, 2011 Share Posted October 23, 2011 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 More sharing options...
boen_robot Posted October 23, 2011 Share Posted October 23, 2011 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 More sharing options...
Synook Posted November 2, 2011 Share Posted November 2, 2011 Using the prefix notation is also more error-prone, as boen_robot demonstrates . Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.