|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
XmlModify::addInsertAfterStep
by Madhu Sadagopan
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hey folks:
BerkeleyDB XML 2.2.13 FreeBSD 6.1 PHP Version 5.1.4 dbxml support enabled dbxml version Sleepycat Software: Berkeley DB XML 2.2.13: <foo> ...... </foo> I tried to insert another node after <foo> using XmlModify::addInsertAfterStep From the API documentation ------------------------------------- Description: XmlModify::addInsertAfterStep Inserts the provided data into the document after the selected node. If the operation's target is an attribute node or the document root node, an exception is thrown at modification execution time. Say, I'm inserting <tada> .... <tada/> The expected result is correct <foo> ... </foo> <tada> ... </tada> Now if the initial XML schema is <foo> ...... </foo> <bar/> <foo> .... </foo> The result is <foo> ...... </foo> <tada> ... </tada> <tada> .... </tada> <bar/> <foo> .... </foo> <tada> ... </tada> <tada> .... </tada> The node <tada> has been inserted TWICE for every <foo> node. The expected result should have only ONE <tada> for every <foo>. Then I tested with three <foo> nodes in the initial schema and every <foo> node has THREE <tada> nodes. Is this the expected result? If so, how to insert the node <tada> only ONCE after every <foo>. thanx, Madhu |
|
|
Re: XmlModify::addInsertAfterStep
by John Snelson-4
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hi Madhu,
I'd like to see the code fragment that you're using to do this, especially the way that you create the XmlResult (or XmlValue) argument to XmlModify:execute(), and the query that you use in XmlModify::addInsertAfterStep(). I suspect that one or both of these parts of your code may be incorrect. John Madhu Sadagopan wrote: > Hey folks: > > *BerkeleyDB XML 2.2.13 > FreeBSD 6.1 > PHP Version 5.1.4* > dbxml support enabled > dbxml version Sleepycat Software: Berkeley DB XML 2.2.13: > > **<foo> > ...... > </foo> > > I tried to insert another node after <foo> using > XmlModify::addInsertAfterStep > > From the API documentation > ------------------------------------- > Description: XmlModify::addInsertAfterStep > > Inserts the provided data into the document after the selected node. If > the operation's target is an attribute node or the document root node, > an exception is thrown at modification execution time. > > Say, I'm inserting > > <tada> > .... > <tada/> > > > The expected result is correct > <foo> > ... > </foo> > <tada> > ... > </tada> > > Now if the initial XML schema is > <foo> > ...... > </foo> > > <bar/> > > <foo> > .... > </foo> > > The result is > <foo> > ...... > </foo> > <tada> > ... > </tada> > <tada> > .... > </tada> > > <bar/> > > <foo> > .... > </foo> > <tada> > ... > </tada> > <tada> > .... > </tada> > > The node <tada> has been inserted TWICE for every <foo> node. The > expected result should have only ONE <tada> for every <foo>. > > Then I tested with three <foo> nodes in the initial schema and every > <foo> node has THREE <tada> nodes. > > Is this the expected result? If so, how to insert the node <tada> only > ONCE after every <foo>. > > thanx, > Madhu ------------------------------------------ To remove yourself from this list, send an email to xml-unsubscribe@... |
|
|
Re: XmlModify::addInsertAfterStep
by Madhu Sadagopan
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hi John: Inorder to rule out issues in code, I tried to insert a node using "insertAfter" from the dbxml shell. I attached the script file [test_afterInsert.db] and also pasted the same at the end. The script test_afterInsert.db creates a container "test.dbxml" and loads the document "book1" and "book2". Content of "book1" ------------------------ <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <book> <title>Knowledge Discovery in Databases</title> </book>' Content of "book2" ------------------------ <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <book> <title>Knowledge Discovery in Databases</title> <title>Knowledge Discovery in Databases</title> <title>Knowledge Discovery in Databases</title> </book> Then it issues "insertAfter" command to insert <author> Meow....Meow....Madhu </author> after the <title> in "book1" and "book2" dbxml "InsertAfter" command -------------------------------------- insertAfter "doc('dbxml:test.dbxml/book1')/book/title" "element" "" "<author>Meow....Meow....Madhu</author>" insertAfter "doc('dbxml:test.dbxml/book2')/book/title" "element" "" "<author>Meow....Meow....Madhu</author>" Then it prints the documents "book1" and "book2". Content of "book1" afterInsert -------------------------------------- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <book> <title>Knowledge Discovery in Databases</title> <author>Meow....Meow....Madhu</author> </book> Content of "book2" afterInsert -------------------------------------- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <book> <title>Knowledge Discovery in Databases</title> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> <title>Knowledge Discovery in Databases</title> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> <title>Knowledge Discovery in Databases</title> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> <author>Meow....Meow....Madhu</author> </book> To run the script --------------------- $ /usr/local/sleepycat/bin/dbxml dbxml> run <path_to>/test_afterInsert.db Hope this helps and thanx for the support. bye, Madhu test_insertAfter.db ------------------------ createContainer "test.dbxml" putDocument "book1" '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <book> <title>Knowledge Discovery in Databases</title> </book>' putDocument "book2" '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <book> <title>Knowledge Discovery in Databases</title> <title>Knowledge Discovery in Databases</title> <title>Knowledge Discovery in Databases</title> </book>' query "doc('dbxml:test.dbxml/book1')/book/title" insertAfter "doc('dbxml:test.dbxml/book1')/book/title" "element" "" "<author>Meow....Meow....Madhu</author>" getDocument book1 query "doc('dbxml:test.dbxml/book2')/book/title" insertAfter "doc('dbxml:test.dbxml/book2')/book/title" "element" "" "<author>Meow....Meow....Madhu</author>" getDocument book2 John Snelson <john.snelson@...> wrote: Hi Madhu, ------------------------------------------ To remove yourself from this list, send an email to xml-unsubscribe@... |
|
|
Re: XmlModify::addInsertAfterStep
by John Snelson-4
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Madhu,
The problem you are seeing here is a misunderstanding of how both the XmlModify interface works, and how the modification commands in the shell behave. The modification commands in the shell work on the result of the last query that was executed. Typically, to perform the operation that you want, you should do the following steps: query "doc('dbxml:test.dbxml/book1')/book/title" insertAfter "." "element" "" "<author>Meow....Meow....Madhu</author>" In code, this would mean executing the query, then passing the XmlResults object to XmlModify::execute(). Typically, the XmlQueryExpression object passed to the XmlModify::addInsertAfterStep(), should be created with a query expression of ".". This query is performed relative to the results passed into the execute() method. Hope that helps, John Madhu Sadagopan wrote: > > Hi John: > > Inorder to rule out issues in code, I tried to insert a node using > "insertAfter" from the dbxml shell. I attached the script file > [test_afterInsert.db] and also pasted the same at the end. > > The script test_afterInsert.db creates a container "test.dbxml" and > loads the document "book1" and "book2". > > Content of "book1" > ------------------------ > <?xml version="1.0" encoding="UTF-8" standalone="no" ?> > <book> > <title>Knowledge Discovery in Databases</title> > </book>' > > Content of "book2" > ------------------------ > <?xml version="1.0" encoding="UTF-8" standalone="no" ?> > <book> > <title>Knowledge Discovery in Databases</title> > <title>Knowledge Discovery in Databases</title> > <title>Knowledge Discovery in Databases</title> > </book> > > Then it issues "insertAfter" command to insert > > <author> > Meow....Meow....Madhu > </author> > > after the <title> in "book1" and "book2" > > dbxml "InsertAfter" command > -------------------------------------- > insertAfter "doc('dbxml:test.dbxml/book1')/book/title" "element" "" > "<author>Meow....Meow....Madhu</author>" > > insertAfter "doc('dbxml:test.dbxml/book2')/book/title" "element" "" > "<author>Meow....Meow....Madhu</author>" > > Then it prints the documents "book1" and "book2". > > Content of "book1" afterInsert > -------------------------------------- > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <book> > <title>Knowledge Discovery in Databases</title> > <author>Meow....Meow....Madhu</author> > </book> > > > Content of "book2" afterInsert > -------------------------------------- > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <book> > <title>Knowledge Discovery in Databases</title> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > <title>Knowledge Discovery in Databases</title> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > <title>Knowledge Discovery in Databases</title> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > <author>Meow....Meow....Madhu</author> > </book> > > To run the script > --------------------- > $ /usr/local/sleepycat/bin/dbxml > > dbxml> run <path_to>/test_afterInsert.db > > > Hope this helps and thanx for the support. > > bye, > Madhu > > test_insertAfter.db > ------------------------ > createContainer "test.dbxml" > > putDocument "book1" '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> > <book> > <title>Knowledge Discovery in Databases</title> > </book>' > > putDocument "book2" '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> > <book> > <title>Knowledge Discovery in Databases</title> > <title>Knowledge Discovery in Databases</title> > <title>Knowledge Discovery in Databases</title> > </book>' > > query "doc('dbxml:test.dbxml/book1')/book/title" > > > insertAfter "doc('dbxml:test.dbxml/book1')/book/title" "element" "" > "<author>Meow....Meow....Madhu</author>" > > getDocument book1 > > > query "doc('dbxml:test.dbxml/book2')/book/title" > > > insertAfter "doc('dbxml:test.dbxml/book2')/book/title" "element" "" > "<author>Meow....Meow....Madhu</author>" > > getDocument book2 > > > > > */John Snelson <john.snelson@...>/* wrote: > > Hi Madhu, > > I'd like to see the code fragment that you're using to do this, > especially the way that you create the XmlResult (or XmlValue) argument > to XmlModify:execute(), and the query that you use in > XmlModify::addInsertAfterStep(). I suspect that one or both of these > parts of your code may be incorrect. > > John > > Madhu Sadagopan wrote: > > Hey folks: > > > > *BerkeleyDB XML 2.2.13 > > FreeBSD 6.1 > > PHP Version 5.1.4* > > dbxml support enabled > > dbxml version Sleepycat Software: Berkeley DB XML 2.2.13: > > > > ** > > ...... > > > > > > I tried to insert another node after using > > XmlModify::addInsertAfterStep > > > > From the API documentation > > ------------------------------------- > > Description: XmlModify::addInsertAfterStep > > > > Inserts the provided data into the document after the selected > node. If > > the operation's target is an attribute node or the document root > node, > > an exception is thrown at modification execution time. > > > > Say, I'm inserting > > > > > > .... > > > > > > > > The expected result is correct > > > > ... > > > > > > ... > > > > > > Now if the initial XML schema is > > > > ...... > > > > > > > > > > > > .... > > > > > > The result is > > > > ...... > > > > > > ... > > > > > > .... > > > > > > > > > > > > .... > > > > > > ... > > > > > > .... > > > > > > The node has been inserted TWICE for every node. The > > expected result should have only ONE for every . > > > > Then I tested with three nodes in the initial schema and every > > node has THREE nodes. > > > > Is this the expected result? If so, how to insert the node only > > ONCE after every . > > > > thanx, > > Madhu > > > ------------------------------------------ > To remove yourself from this list, send an > email to xml-unsubscribe@... > > > > ------------------------------------------------------------------------ > > > ------------------------------------------ > To remove yourself from this list, send an > email to xml-unsubscribe@... ------------------------------------------ To remove yourself from this list, send an email to xml-unsubscribe@... |
| Free embeddable forum powered by Nabble | Forum Help |