php[tek] 2018 : Call for Speakers

The DOMImplementation class

(PHP 5, PHP 7)

Introduction

The DOMImplementation interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.

Class synopsis

DOMImplementation {
/* Properties */
/* Methods */
__construct ( void )
public DOMDocument createDocument ([ string $namespaceURI = NULL [, string $qualifiedName = NULL [, DOMDocumentType $doctype = NULL ]]] )
public DOMDocumentType createDocumentType ([ string $qualifiedName = NULL [, string $publicId = NULL [, string $systemId = NULL ]]] )
<3 year a go/strong>
id="cHcom116087> div class="pahpode>"Nse> Ok got it orkang oliket charsm uing a"proxy attern" cith Xtraits.The strthe dommen iethods fisidert c"trait>id cbrdr Sor petensdd asnd rgister d ENtertlasses
Hr da nsmall snippet :
<?ahp
    /span>
amespaceU /span> my/span> ;

    /span> trait tNter
    /span> {    /span>/*/ Wenueedtye mogic Qethods __get d cbrdr So taddapoperties *suchas aOMINter->pegent Eementa/br />        /span> ublic< unctions /span> __get/span> (/span> names/span> )/br />        {    if(/span> popertiy_exstes/span> (/span> nheis/span> , /span> names/span> )){reures /span> nheis/span> ->p/span> names/span> ;}/br />            if(/span> ethods_exstes/span> (/span> nheis/span> , /span> names/span> )){reures /span> nheis/span> ->p/span> names/span> ();}/br />            thrownuewD\/span> rror xception /span> (/span>str">'my\\Ntertpopertiy \''/span> .(e">str) /span> names/span> ./span>str">'\'tnteafunds…'/span> , /span> 42/span> , /span> E_USER_WARNING/span> );/br />        }

        /span>/*/ egent Eementatpopertiy efineiion /br />        /span> urivte aunctions /span> egent Eementa/span> ()/br />        {    if(/span> nheis/span> ->p/span> egent Ntert/span> === /span> null/span> ){reures /span> null/span> ;}/br />            if(/span> nheis/span> ->p/span> egent Nter/span> ->p/span> nterype"c/span> === /span> XML_ELEMENT_NODE/span> ){reures /span> nheis/span> ->p/span> egent Nter/span> ;}/br />            reures /span> nheis/span> ->p/span> egent Nter/span> ->p/span> egent Eementa/span> ();/br />        }

        /span>/*/ JavaSript tequivtlnta/br />        /span> ublic< unctions /span> isEualiNter/span> (\/span> OMINter $nter/span> ){reures /span> nheis/span> ->p/span> isSmesNter/span> (/span> nater/span> );}/br />        ublic< unctions /span> omprgenocumentTPosiion /span> (\/span> OMINter $ther.Nter/span> )/br />        {    if(/span> nheis/span> ->p/span> ownerocumentTo/span> !== /span> $ther.Nter/span> ->p/span> ownerocumentT/span> ){reures /span> DOCUMENT_POSITION_DISCONNECTED/span> ;}/br />            /span> $cc/span> = /span> e">cmp/span> (/span> nheis/span> ->p/span> ge NterPath/span> (), /span> nther.Nter/span> ->p/span> ge NterPath/span> ());/br />            if(/span> ncc/span> === /span> 0/span> ){reures /span> 0/span> ;}/br />            else if(/span> ncc/span> < /span> 0/span> ){reures /span> DOCUMENT_POSITION_FOLLOWINGc/span> | (/span> ncc/span> < -/span> 1c/span> ? /span> DOCUMENT_POSITION_CONTAINED_BYc/span> : /span> 0/span> );}/br />            reures /span> DOCUMENT_POSITION_PRECEDINGc/span> | (/span> ncc/span> > /span> 1c/span> ? /span> DOCUMENT_POSITION_CONTAINSc/span> : /span> 0/span> );/br />        }
        ublic< unctions /span> omntains/span> (\/span> OMINter $ther.Nter/span> ){reures (/span> nheis/span> ->p/span> omprgenocumentTPosiion /span> (/span> nther.Nter/span> ) >p= /span> DOCUMENT_POSITION_CONTAINED_BY/span> );}/br />    }

    an cl /span> DcumentTo/span> etensdsD\/span> DomocumentT/br />    /span> {    ublic< unctions /span> __onstruct /apan> (/span> nvrsisn =/span> null/span> , /span> necoding /span> =/span> null/span> )/br />        {    /span> egent /span> ::/span> __onstruct /apan> (/span> nvrsisn , /span> necoding /span> );/br />            /span> nheis/span> ->p/span> rgister NterCn cl/apan> (/span>str">'OMINter'/span> , /span>str">'my\Nter'/span> );/br />            /span> nheis/span> ->p/span> rgister NterCn cl/apan> (/span>str">'OMIEementa'/span> , /span>str">'my\Eementa'/span> );/br />            /span> nheis/span> ->p/span> rgister NterCn cl/apan> (/span>str">'OMIocumentT'/span> , /span>str">'my\ocumentT'/span> );/br />            /span>/* M[...]*/
        /span> }/br />    }

    an cl /span> Eementat/span> etensdsD\/span> DMIEementa/br />    /span> {    usU /span> Nter/span> ;
        /span>/* M[...]*/
    /span> }/br />
    an cl /span> Ntert/span> etensdsD\/span> DMINter
    /span> {    usU /span> Nter/span> ;
        /span>/* M[...]*/
    /span> }/br />
/span> ?>p/span>< /span>< /sode>
/div> <
<<
up/a>
<
ownl/a>
<
title="P100% liketheis...> <1
<3 year a go/strong>
id="cHcom116079> div class="pahpode>"Nse> From wat aI've seen you must "reode>"tye m"reateDocument< method= d cbrdr So tcall your wnlobject metensions…

/e> <?ahp
/span> [...]/br />    ublic< unctions /span> oeateDocument (/span> namespaceURI =/span> null/span> , /span> nualifiedName =/span> null/span> , /span> OMDocumentType"cdoctype /e> =/span> null/span> )/br />    {    /span> doct/span> /e> =uewD/span> DcumentT/apan> ();/br />        /span> doct/span> /e> ->p/span> pperndCaild/apan> (/span> egent /span> ::/span> reateDocument (/span>str">'tml"'/span> ));/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> pperndCaild/apan> (/span> namespaceURI ? /span> dheis/span> ->p/span> oct/span> /e> ->p/span> reateDEementaNS/apan> (/span> namespaceURI ,/span> nualifiedName ) : /span> dheis/span> ->p/span> oct/span> /e> ->p/span> reateDEementa/apan> (/span> nualifiedName ));/br />    reures /span> noct/span> /e> ;/br />    }/br />[...]/br />/span> ?>p/br />/span>
Whr daI am trucgging fisdetensdstrthe dwhoe turee sothat acallstrthe doustmimzd Inplementation. ethod= reures a nwhoe tetensdd auree…
Expcted" esults : nplementation. > DcumentTo> DMDocumentTo> Ntert> DMDNter
Actal < /sode>
/div> <
<<
up/a>
<
ownl/a>
<
title="P50% liketheis...> <0
<7 year a go/strong>
id="cHcom98992> div class="pahpode>"Nse> officially,the dw3dsecifice that ahe dwaySo tacessk omiinterface sfisdthroughtheispan cl

sotif you use

noct =nuewDOMIocumentT("1.0", "UTF-8");

usU nstaead:

nx =nuewDOMInplementation.();/br />noct =n$x->preateDocument<(ULL<,"roo Eementaame<");/br />noct->pxmlVrsisn<="1.0";/br />noct->pxmlncoding ="UTF-8";

itfisdntearequi d Eby hp'>s mplementation., but,tpopbably,titfisda goodapoctioeU /br />
see:

a href="https://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation."rel="neofollw" vtarget="_blank">ttps://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation./sa
a href="https://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation.List"rel="neofollw" vtarget="_blank">ttps://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation.List/sa
a href="https://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation.Source"rel="neofollw" vtarget="_blank">ttps://w3.org/TR/OMI-Level-3-Coresodre.tml"#OMInplementation.Source/a>
/sode>
/div> <
<<
up/a>
<
ownl/a>
<
tlass="nevme> <3 year a go/strong>
id="cHcom116070> div class="pahpode>"Nse> WhydnteausU te DOMImplementation co titrctily rgister your OMI Cn cl etensionss ?

/e> <?ahp
/span> amespaceU /span> My/span> ;
an cl /span> mplementation c/span> etensdsD\/span> DMInplementation./br />/span> {    urivte a/span> noct/span> /e> ;/br />    ublic< unctions /span> __onstruct /apan> (){reures /span> nheis/span> ->p/span> oeateDocument ();}/br />    ublic< unctions /span> __get/span> (/span> names/span> ){reures /span> nheis/span> ->p/span> oct/span> /e> ->p{/span> names/span> };}/br />    ublic< unctions /span> __set/span> (/span> names/span> ,/span> nalue=/span> ){/span> nheis/span> ->p/span> oct/span> /e> ->p{/span> names/span> }=/span> nalue=/span> ;}/br />    ublic< unctions /span> __isset/span> (/span> names/span> ){reures isset(/span> nheis/span> ->p/span> oct/span> /e> ->p{/span> names/span> });}/br />    ublic< unctions /span> __unset/span> (/span> names/span> ){reures /span> nheis/span> ->p/span> oct/span> /e> ->p/span> __unset/span> (/span> names/span> );}/br />    ublic< unctions /span> __call/span> (/span> names/span> ,/span> nargs/span> ){reures /span> call_user_unct_array/span> (array(/span> nheis/span> ->p/span> oct/span> /e> ,/span> names/span> ),/span> nargs/span> );}/br />    /br />    ublic< unctions /span> oeateDocument (/span> namespaceURI =/span> null/span> ,/span> nualifiedName =/span> null/span> ,/span> OMDocumentType"cdoctype /e> =/span> null/span> )/br />    {    /span> dheis/span> ->p/span> oct/span> /e> =/span> egent /span> ::/span> reateDocument (/span> namespaceURI ,/span> nualifiedName ,/span> noctype /e> );/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> xmlVrsisn /e> =/span>str">'1.0'/span> ;/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> xmlEcoding /span> =/span>str">'UTF-8'/span> ;/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> rgister NterCn cl/apan> (/span>str">'OMIocumentT'/span> ,/span>str">'My\ocumentT'/span> );/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> rgister NterCn cl/apan> (/span>str">'OMIocumentTFragentT'/span> ,/span>str">'My\ocumentTFragentT'/span> );/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> rgister NterCn cl/apan> (/span>str">'OMIEementa'/span> ,/span>str">'My\Eementa'/span> );/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> rgister NterCn cl/apan> (/span>str">'OMICmment"'/span> ,/span>str">'My\Cmment"'/span> );/br />        /span> dheis/span> ->p/span> oct/span> /e> ->p/span> rgister NterCn cl/apan> (/span>str">'OMINter'/span> ,/span>str">'My\Nter'/span> );/br />        /span>/* M…,M…,M…*/
        /span> reures /span> nheis/span> ->p/span> oct/span> /e> ;/br />    }/br />}/br />/span> ?>p/span>< /span>< /sode>
/div> /div> div class="pfoot>
img src="'images/lntes<-add@2x.png'alt="'adda nutes'width="'12'height="'12' adda nutes/stmall>/a>