Make sure you use
http://au2.php.net/xml_parser_create_ns
and not
http://au2.php.net/xml_parser_create
to create your parser.
I'm assuming your element handler will then get "ff:customtag" in the second param (the $name).
PHP Code:
$arrQualified = explode(":",$name);
if(count($arrQualified) == 2) {
if($arrQualified[0] == "ff") // do you thang baby.
}
This is still a hack, because now you are relying on them to have "ff" to QUALIFY their elements. THis is BS though because an element name prefix is neccesarily bound to a declaration. It is the declaration that is unique and it is the declaration that should be specifid as part of your template specification. so maybe in the outer container of your template you have
PHP Code:
yadda yadda yadda....
<container scope="not necessarily the root element" xmlns:ff="prefab.org/specs/schema/customtemplates">
<ff:lalalala>foo bar choo</ff:lalalala>
</container>
more crap goes here if you like...
then you should use http://au2.php.net/xml-set-start-namespace-decl-handler
to test for "prefab.org/specs/schema/customtemplates" and then find out what prefix the user bound to it.
ie. they might have done
PHP Code:
yadda yadda yadda....
<container scope="not necessarily the root element" xmlns:fooloo="prefab.org/specs/schema/customtemplates">
<fooloo:lalalala>foo bar choo</fooloo:lalalala>
</container>
more crap goes here if you like...
so now your processor is obligated to parse the fooloo prefix.
It's worth doing properly. trust me.
Namespaces make the concept of XML work. If it weren't for namespaces, XML would be ignorable. Namespaces were designed precicely to handle situations like yours.
You do realise that you are re-inventing JSP/ASP.NET
PHP Code:
<jsp:useBean id="calendar" scope="application" class="org.whatever" />
PS.
The namespace declaration string doesn't have to mean anything, but it is intended to be a world-wide primary key (globally unique) so people use their domain names (plus a path) by convention.
Bookmarks