[phpXML] Re: [phpXML] miss-match
Brought to you by:
bs_php,
nigelswinson
From: <nig...@us...> - 2001-10-09 13:11:54
|
> I was initially thrown off by the 'trivialness' of the example but = when I=20 > look at how you intend to process the file it seems to cry out for a=20 > different structure altogether. >=20 > Is it not true that _if_ there are children _then_ the children should = > stand as elements of the parent? ((then the other 'content' is/are = really=20 > attributes of the parent)) >=20 > That would say to me that the example being discussed could (should?) = > better be constructed like >=20 > <blah1 precursor=3D"Text" postcursor=3D"text."> > <blah2>more</blah2> > </blah> >=20 > Wouldn't that be more parallel to the processing that you intend to do = to=20 > the file? The problem with this approach is when you come to an XML fragment like = this: <p>Hello there <b>my</b> name is <i>Nigel</i> Swinson</p> Where do we put the "name is" text with a precursor, postcursor = approach? Currently this is the structure that we obtain (This clearly shows the = "Hello therename isSwinson" text property of the /p[1] entry): We currently have I suggest we aim for =20 xml Object ( [nodes] =3D> Array ( [/p[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 1 [name] =3D> p [text] =3D> Hello therename isSwinson [parent] =3D>=20 [attributes] =3D> Array ( ) [children] =3D> Array ( [b] =3D> 1 [i] =3D> 1 ) ) [] =3D> Array ( [document-position] =3D> 0 [children] =3D> Array ( [p] =3D> 1 ) ) [/p[1]/b[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 2 [name] =3D> b [text] =3D> my [parent] =3D> /p[1] [attributes] =3D> Array ( ) ) [/p[1]/i[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 2 [name] =3D> i [text] =3D> Nigel [parent] =3D> /p[1] [attributes] =3D> Array ( ) ) ) ) xml Object ( [nodes] =3D> Array ( [/p[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 1 [name] =3D> p [text] =3D> "Hello there " [after-element-text] =3D> "" [parent] =3D>=20 [attributes] =3D> Array ( ) [children] =3D> Array ( [b] =3D> 1 [i] =3D> 1 ) ) [] =3D> Array ( [document-position] =3D> 0 [children] =3D> Array ( [p] =3D> 1 ) ) [/p[1]/b[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 2 [name] =3D> b [text] =3D> "my" [after-element-text] =3D> " name is " [parent] =3D> /p[1] [attributes] =3D> Array ( ) ) [/p[1]/i[1]] =3D> Array ( [context-position] =3D> 1 [document-position] =3D> 2 [name] =3D> i [text] =3D> "Nigel" [after-element-text] =3D> " Swinson" [parent] =3D> /p[1] [attributes] =3D> Array ( ) ) ) )=20 =20 Using a system like this I think is scaleable, lossless, and wouldn't be = all that hard to implement. ? Nigel |