First, it has come to my attention that emails from our exchange server are getting
threaded incorrectly, so if this ends up in a wrong thread, instead of as a new thread, I
apologize.
On to the issue.
Basically I am trying to mimic the results of:
api.php?action=query&list=categorymembers&cmtitle=category:Foo
I have code that iterates over an object and extracts attributes and creates an indexed
array with the relevant attributes of the element as well as other elements.
The indexed array looks like this:
$attribs = array('pageid'=>$articleID, 'ns'=>$namespaceID,
'title'=>$preFixedTitle, 'classification'=>$classString);
When I try calling $result->addValue( array('query','categorymembers'),
'cm', $attribs ) from inside the iteration I get the error:
"Exception Caught: Internal error in ApiResult::setElement: Attempting to merge
element cm"
(external to the iteration I get [as expected] the correct format, but for only the final
value of $attribs)
If I try omitting the $name (whether by using an empty string, null, or using $attribs as
$name and omitting $value) I get this error:
"Exception Caught: Internal error in ApiFormatXml::recXmlPrint: (categorymembers,
...) has integer keys without _element value. Use ApiResult::setIndexedTagName()."
So I tried using $result->setIndexedTagName($attribs, 'cm') but that
doesn't change anything.
I have been trying to find an example of setIndexedTagName() in use in the code, so that I
can understand how it is used correctly, but I haven't managed yet. I have read the
doxygen generated docs on ApiResult, but I am still unclear on the correct usage and, more
importantly, the appropriate implantation of it.
Can anyone here provide some insight, please? Either on a better way to mimic the output,
or the correct usage of the methods in question.
Thank you in advance.
--Sean Prunka
Show replies by date
I found the code I needed for a clear example in ApiQueryCategoryMembers.php
But thank you for taking the time to read my dilemma and either not scolding me, or
preparing an answer...
--Sean Prunka
________________________________
From: mediawiki-api-bounces(a)lists.wikimedia.org
[mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of Prunka, Sean
Sent: Wednesday, April 29, 2009 1:51 PM
To: mediawiki-api(a)lists.wikimedia.org
Subject: [Mediawiki-api] result->addValue() or setIndexedTagName() assistance.
First, it has come to my attention that emails from our exchange server are getting
threaded incorrectly, so if this ends up in a wrong thread, instead of as a new thread, I
apologize.
On to the issue.
Basically I am trying to mimic the results of:
api.php?action=query&list=categorymembers&cmtitle=category:Foo
I have code that iterates over an object and extracts attributes and creates an indexed
array with the relevant attributes of the element as well as other elements.
The indexed array looks like this:
$attribs = array('pageid'=>$articleID, 'ns'=>$namespaceID,
'title'=>$preFixedTitle, 'classification'=>$classString);
When I try calling $result->addValue( array('query','categorymembers'),
'cm', $attribs ) from inside the iteration I get the error:
"Exception Caught: Internal error in ApiResult::setElement: Attempting to merge
element cm"
(external to the iteration I get [as expected] the correct format, but for only the final
value of $attribs)
If I try omitting the $name (whether by using an empty string, null, or using $attribs as
$name and omitting $value) I get this error:
"Exception Caught: Internal error in ApiFormatXml::recXmlPrint: (categorymembers,
...) has integer keys without _element value. Use ApiResult::setIndexedTagName()."
So I tried using $result->setIndexedTagName($attribs, 'cm') but that
doesn't change anything.
I have been trying to find an example of setIndexedTagName() in use in the code, so that I
can understand how it is used correctly, but I haven't managed yet. I have read the
doxygen generated docs on ApiResult, but I am still unclear on the correct usage and, more
importantly, the appropriate implantation of it.
Can anyone here provide some insight, please? Either on a better way to mimic the output,
or the correct usage of the methods in question.
Thank you in advance.
--Sean Prunka