[MOBY-l] parameter handling problems

Ulrich Harttig harttig at mail.dife.de
Wed Aug 3 07:48:34 UTC 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dirk Haase wrote:
> On Tuesday 02 August 2005 17:42, Ulrich Harttig wrote:
> 
> 
>>($secondary) = getNodeContentWithArticle($input, "Parameter", "VarType");
>>
>>does not find any content although the $input node contains
>>
>><moby:Parameter moby:articleName="VarType">
>>     <moby:Value>xml</moby:Value>
>></moby:Parameter>
>>
>>Is there any reason why this shouldn't work ?
> 
> 
> If I remember correctly, I tried the same and didn't work for me neither...
> 
> 
>>Could someone point me to examples where accessing parameters works ?
> 
> 
> Here is what works for me: the service takes several secondaries, so it puts 
> all parameter values into a %paramHash:
> 
> if ( $articleType == SECONDARY ) {
>   my $param = $input->getAttribute('articleName');
>   my @valueNodes = $input->getChildrenByTagName('moby:Value');
>   my $value = $valueNodes[0]->textContent(); # there should be only one value
>   $paramHash{$param} = $value;
> }
> 
> Hope this helps. 
> 
> Regards,
> dirk
Thanks a lot for the help, your example did work.

But I still wondered why $input->getChildrenByTagName('moby:Value') worked but
$input->getElementByTagName('moby:Parameter') would not. I was guessing that
this had something to do with the structure/content of the node from the
secondary article.
getElementsByTagName is supposed to return a named descendant of the node.
According to the DOM spec: "A descendant node of any node A is any node below A
in a tree model, where "below" means "away from the root."
But to me it seems that <moby:Parameter> is actually the root of the node ,
judging by the content of the $input parameter, so one would not be able to find
a descendant of the same name.
So if I pass instead the original message using the $input->parentNode to the
CommonSub function 'getNodeContentWithArticle' it then returns the desired
parameter value

($secondary) = getNodeContentWithArticle($input->parentNode, "Parameter",
"VarType");

best regards
Ulrich

- --
Ulrich Harttig
German Institute of Human Nutrition Potsdam-Rehbruecke
Dept. of Epidemiology
Arthur-Scheunert-Allee 114-116, 14558 Nuthetal, Germany
phone: +49 (0)33200 88-729, fax: +49 (0)33200 88-721
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFC8HbSeYdmlKJoHzkRAp6ZAJ98gonlRj76yBlZEf8feQYd+fx9QACgtVqI
qDx3gY2ljO29ZcdGqy9QZ14=
=OuRI
-----END PGP SIGNATURE-----



More information about the moby-l mailing list