www.webdeveloper.com
Results 1 to 3 of 3

Thread: adding namespace to xhtml and validating

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    2

    adding namespace to xhtml and validating

    Hi all.
    I have question. I want to add my own namespace to xhtml and validate my document. my docoment like below. I cant write my schema file. I need saple xsd file. Help me please.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:my="http://www.my.net/docs/gml/my">
      <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>page title</title>
    
        <my:headtag>
                <my:desc>description</my:desc>
                <my:sometag description="tag desc" value="tag value"></my:sometag>
       </my:heaadtag>
    
    </head>
    
    <body>
      <div >
        <div id="ids">
    
          <my:anothertag attr="value">
    	<div>
    	         <my:subanothertag attr="value"></bb:subanothertag></my:anothertag>
            </div>
             <my:subanothertag attr="value"></bb:subanothertag>
          </my:anothertag>
        </div>
    
      </div>
      
    </body>
    </html>

  2. #2
    Join Date
    Jan 2009
    Posts
    2

    correction

    Hi
    Sorry there are some errors in my code. Below is correct code
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:my="http://www.my.net/docs/gml/my">
      <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>page title</title>
    
        <my:headtag>
                <my:desc>description</my:desc>
                <my:sometag description="tag desc" value="tag value"></my:sometag>
       </my:heaadtag>
    
    </head>
    
    <body>
      <div >
        <div id="ids">
    
          <my:anothertag attr="value">
    	<div>
    	         <my:subanothertag attr="value">foo foo foo</my:subanothertag
            </div>
             <my:subanothertag attr="value">hot hot hot</my:subanothertag>
          </my:anothertag>
        </div>
    
      </div>
      
    </body>
    </html>

  3. #3
    Join Date
    May 2008
    Posts
    381
    It is more of a problem regarding writing the rest of the DTD... You would need to add more things to the contents of div elements and the like (possibly extend the Block.extra entity) as well as adding an attribute to the html element for the "my" namespace. It really is a bit more trouble than it is worth if you're using it on the Web. That is why XHTML 1.1, XHTML 1.1+MathML+SVG, etc. all have different DTDs, especially when using XHTML 1.1+MathML+SVG because each one of the languages can be a host language (e.g. using mainly XHTML 1.1, mixing SVG or MathML in via namespaces or using mainly MathML, mixing in some XHTML 1.1 via namespace). That is why languages like the W3C's own XML Schema recommendation or the Relax NG grammar files are used - they are XML-based and can address some shortcomings of DTDs. Unfortunately, you wouldn't use the W3C Markup Validator then since it is DTD-based. You would instead use XSV - the XML Schema Validator or another schema validation service instead for checking an XML Schema file or Relax NG grammar file (and any files they include or import). Long story short - modify the DTD or build on it in your own DTD like the following DTD file:
    Code:
    <!ENTITY &#37; xhtml1.strict.dtd "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    %xhtml1.strict.dtd; <!-- includes the XHTML 1.0 Strict DTD -->
    
    <!ENTITY % xhtml.Block.extra
      "| my:anothertag
       | my:headtag">
    
    <!ENTITY % xhtml.Inline.extra
      "| my:sometag
       | my:desc
       | my:subanothertag">
    
    <!ELEMENT my:anothertag (%xhtml.Flow.mix;)>
    ....
    You really need to know how the DTD works to be able to use it. =/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles