Mmm, thats fine if you want to return a STRING, but not to create new XML nodes in the document. LibXSLT doesn't know what you're returning in a string is XML and thus XSLT just sees a string and applies normal output escaping to it and adds it to the document as a single text node, which is really all it can do.

Anyway, at least with recent versions of XML::LibXML you CAN return a nodelist of one node only from a callback and it works fine. Returning multiple nodes results in the XSLT processor object looping endlessly. I haven't really tried to dope out exactly what goes wrong, but in general the current functionality seems adequate, you can always do something like:

<xsl:variable name='mynodes' select='common:node-set(cblibrary:cbfunction())'/>

and then pick out just the child nodes with <xsl:for-each/> or <xsl:apply-templates/> later if you need to. I think 99% of the taglib type use cases probably want a single containing tag anyway. It certainly is fine with me!

Tom Schindl wrote:

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

I thought from my tests that returning an XML-String like this works:

- -----------------------------8<-----------------------------
return <<EOT;
<list>
~    <item name="a" />
~    <item name="b" />
~    <item name="c" />
</list>
EOT
- -----------------------------8<-----------------------------

Tom

Tod Harter schrieb:
| Yeah, I have since tried that. I discovered that it works fine as long
| as you pass only one node in the list, which is probably the best
| practice anyway :). Thanks very much for the help!
|
| Robin Berjon wrote:
|
|> Tod Harter wrote:
|>
|>> This works fine for returning scalars, but if I return an
|>> XML::LibXML::NodeList object tragedy strikes!
|>>
|>> Specifically the callback code is thus:
|>>
|>> sub attributes : CallBack(attributes)
|>>        {
|>>
|>>        get_logger()->debug("ATTRIBUTES WAS CALLED");
|>>        my $df = XML::LibXML::NodeList->new();
|>>        for my $key (keys %{get_session_handler()->session()})
|>>                {
|>>                get_logger()->debug("key is $key");
|>>                my $e = XML::LibXML::Element->new('key');
|>>                $e->setAttribute('name',$key);
|>> $e->appendText(get_session_handler()->session()->{$key});
|>>                $df->push($e);
|>>                }
|>> use Data::Dumper;
|>> get_logger()->debug("NODE LIST IS : ".Dumper($df));
|>>       return $df;
|>>        }
|>
|>
|>
|> There used to be known issues with this, and I don't know if they were
|> fixed so your problem might require some backtracing and XS patching.
|>
|> However I do note that the elements you return belong to no document,
|> which shouldn't happen. Maybe if you passed your function a node from
|> the document it's processing and used that document to create the
|> elements it would work better?
|>
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCrZLAkVPeOFLgZFIRAmHBAJ9p/C/8bS5cyTB48k0R1MhTO0L5gQCeNoQm
s0QsCN8VP9I5YJynvu/F40s=
=U1Ps
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to