Re: Moving an element to another place under the same parent

67 views
Skip to first unread message

TechnoSophos

unread,
Apr 16, 2013, 5:39:13 PM4/16/13
to support-...@googlegroups.com

Error #1:

remove() returns the element you just detached, which no longer is part of the tree. So it doesn't have a parent.

$image->remove(); $image->parent() is probably what you want.

Error #2:

Based on the error, I believe what is missing from the original document is xmlns:draw="SOME_NS_URN"

Since OD* documents are namespaced, it gets complicated to work with fragments. Make sure that the xmlns is specified somewhere in the doc.

-- 
TechnoSophos
Twitter: @technosophos
Sent with Sparrow

On Tuesday, April 16, 2013 at 4:01 PM, JC wrote:

Hi,

Im kind of a newb here, and its likely that my question will make that very clear...
I feel that I've done due diligence scouring the internet for details... but I'm empty handed.
I've even tried a few work arounds...

Any help is hugely appreciated!

Thank You!



I am working with an openoffice draw document.
Everything was going well until I ran into an issue related to:

I am trying to move a snippet of XML to be the LAST child under its parent. It seems this native xml ordering how open office arranges items in the z plane. 

So here the operations seem to be:
-Get the xml you want to move
-Remove the xml you want to move (from its old position)
-Append the xml you want to move (in its new position)

$imageXML=$image->xml(); //grab the xml

$image->remove()->parent();   <----FAIL HERE

$image->append($imageXML);

I get a giant loop of stuff like this:

PHP Notice:  Trying to get property of non-object in /Users/jc/Dropbox/xxx/Design Tool DV/External Tools/QueryPath-2.1.2-minimal/QueryPath.php on line 1159


So it appear that I can't get back to the parent to do the append?

Also,

I tried to just append the xml to the parent, and I get this error:

PHP Fatal error:  Uncaught exception 'QueryPathParseException' with message 'DOMDocumentFragment::appendXML(): namespace error : Namespace prefix draw for name on frame is n
ot defined (/Users/jc/Dropbox/xxx/Design Tool DV/External Tools/QueryPath-2.1.2-minimal/QueryPath.php: 974)' in /Users/jc/Dropbox/xxx/Design Tool D
V/External Tools/QueryPath-2.1.2-minimal/QueryPath.php:2348
Stack trace:
#0 [internal function]: QueryPathParseException::initializeFromError(2, 'DOMDocumentFrag...', '/Users/jc/Dropb...', 974, Array)
#1 /Users/jc/Dropbox/xxx/Design Tool DV/External Tools/QueryPath-2.1.2-minimal/QueryPath.php(974): DOMDocumentFragment->appendXML('<draw:frame dra...')
#2 /Users/jc/Dropbox/xxx/Design Tool DV/External Tools/QueryPath-2.1.2-minimal/QueryPath.php(691): QueryPath->prepareInsert('<draw:frame dra...')
#3 /Users/jc/Dropbox/xxx/Design Tool DV/Scripts/class.arrayImageRescaler.php(96): QueryPath->append('<draw:frame dra...')
#4 /Users/jc/Dropbox/xxx/Users/jc/Dropbox/xxxDesign Tool DV/External Tools/QueryPath-2.1.2-minimal/QueryPath.php on line 2348


which seems to be crazy, because I'm taking a copy of open office xml from a known good open office document and trying to reinsert it elsewhere....


This is the snipped I want to move:



<draw:frame draw:name="ArrayImage" draw:style-name="gr13" draw:text-style-name="P1" draw:layer="layout" svg:width="20.294cm" svg:height="12.647cm" draw:transform="rotate (3.
5003633238604) translate (29.763cm 4.471cm)"><draw:image xlink:href="Pictures/1000000000000114000000AC89274823.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onL
oad"><text:p/></draw:image><svg:desc>ScaleDenominator=&lt;150&gt;</svg:desc></draw:frame>


--
You received this message because you are subscribed to the Google Groups "support-querypath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to support-queryp...@googlegroups.com.
To post to this group, send email to support-...@googlegroups.com.
Visit this group at http://groups.google.com/group/support-querypath?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

JC

unread,
Apr 16, 2013, 11:07:41 PM4/16/13
to support-...@googlegroups.com
Thank you Matt, for the quick response.

I did a retry on item #1.

$image->find('svg|desc')->text('ScaleDenominator=<'.$this->ScaleDenominator.'>')->parent();

$image->remove();    <-------- remove is now on its own

$image->parent()->find('draw|custom-shape[draw|name="Azimuth"]');

Unfortunately, php is still going bananas with that error message.


any other ideas?
Reply all
Reply to author
Forward
0 new messages