Obyx has an enviroment variable that can be a source of confusion.
This variable is called OBYX_VALIDATE_ALWAYS and is a boolean variable and is currently based on existance rather that contents so even if the variable contains false it still exists and therefore will be activated.
This variable will set obyx to always validate XML objects thereby forcing each object to have its own namespace and doctype declaration.
So for an example
view.html
<!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" lang="en" xml:lang="en">
<head>
<title>Page</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<div id="objectgoeshere" />
</body>
</html>
We shall import this in to a store in obyx using the following code.
index.obyx
<instruction xmlns="http://www.obyx.org">
<input>
<instruction>
<output space="store" value="view" />
<input space="file" value="view.html" />
</instruction>
<instruction>
<input space="store" value="view" release="true" />
</instruction>
</input>
</instruction>
Now we want to insert an xml object in to the view store object.
object.html
<div id="insertme" xmlns="http://www.w3.org/1999/xhtml">
Some Text
</div>
Our obyx code becomes:
<instruction xmlns="http://www.obyx.org">
<input>
<instruction>
<output space="store" value="view" />
<input space="file" value="view.html" />
</instruction>
<instruction>
<output space="store" value="view#//div[@id=objectgoeshere]/child-gap()" />
<input space="file" value="object.html" />
</instruction>
<instruction>
<input space="store" value="view" release="true" />
</instruction>
</input>
</instruction>
If OBYX_VALIDATE_ALWAYS is enabled this block of xhtml is invalid and will generate an error. To be made valid it requires a doctype. Notice the 'html' text directly after !DOCTYPE this identifies the root element that you are using in the specified schema. So for a div we need to change the html to div.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and the object now reads:
<!DOCTYPE div PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<div id="insertme" xmlns="http://www.w3.org/1999/xhtml">
Some Text
</div>
This is the best way to write code as it conforms to XML standards and XHTML schema or whatever schema you descide to use.
Last Modified: Thu, 15 Jan 2015