I appear to be reading in circles, or perhaps am simply not grasping some of the concepts here. I'm reworking a set of PHP template classes, that previously used some fancy regular expressions to combine and duplicate documents and regions of documents, producing an output page. An example of my previous method (for the sake of completeness):
<div id="myId">
<!-- {{ region:myRegion }} -->
<div class="myClass">
<h1>{{ var:myHeading }}</h1>
<h2>{{ var:myDatetime format:datetime(Y-m-d H:i:s) }}</h2>
<p>{{ var:myText format:maxLength(300) }}</p>
</div>
<!-- {{ region:myRegion }} -->
</div>
Anyways, it works quite well, but I really want to move it up to the next level, and figured that would logically be extending the markup itself, becoming something like:
<div id="myId">
<zuq:region name="myRegion">
<div class="myClass">
<h1><zuq:var name="myHeadi开发者_StackOverflowng" /></h1>
<h2><zuq:var name="myDatetime" format="datetime" param="Y-m-d H:i:s" /></h2>
<p><zuq:var name="myText" format="maxLength" param="300" /></p>
</div>
</zuq:region>
</div>
I've been reading the W3 specifications, and even the W3Schools tutorials on various relevant technologies, like XML Schema for writing the template specifications. Obviously I want to keep everything well formed and valid in all namespaces used. Primarily this will be used mixed with XHTML markup.
Anyways, can anyone point me towards some good reading on understanding XML namespaces, the limits and best practices of mixing namespaces, and most importantly I suppose, working with PHP/DOM/XML. Are there any critical flaws in my approach here that anyone can see? It doesn't appear that PHP has a particularly powerful implementation for working with namespaced markup documents, whether its through DOMDocument (and brethren) or SimpleXML.
Any advice, reading material suggestions, or criticism is welcomed!
Edit: In case anyone is curious, elements from the zuq namespace should not be present at the time of output rendering, having been parsed and otherwise removed. However, beyond the good practice of keeping documents valid, I intend on taking advantage of the markup present in the templates, so that via a CMS WYSIWYG editor, administrators can quickly edit pages.
Namespaces are really a very simple concept that somehow gets blown out of proportion. See http://www.xml.com/pub/a/1999/01/namespaces.html for a good tutorial on XML Namespaces.
As for dealing with namespaced XML from PHP, the DOM interface works very well. For example, you can getElementsByTagNameNS, you can lookupNamespaceURI, look up a given URI's prefix...
Beyond that, the question feels incredibly subjective and vague, so if you care to edit it or post further questions that refine it, perhaps you can get some more concrete help.
精彩评论