Click to See Complete Forum and Search --> : adding namespace to xhtml and validating


ub_old
01-11-2009, 09:00 PM
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.


<?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>

ub_old
01-11-2009, 10:37 PM
Hi
Sorry there are some errors in my code. Below is correct 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>

rpgfan3233
01-13-2009, 04:30 PM
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 (http://www.w3.org/2001/03/webdata/xsv) 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:
<!ENTITY % 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. =/