Re: [xslt] Splitting a result into subtrees

I don't know about the PHP API. But with the Perl API this would be really easy and doesn't even require XSLT. Assuming you have a parsed HTML document in $doc, the code would look something like:

my $part1 = $doc->findnodes('xpath_for_subtree_1')->get_node(1)->toString();
my $part2 = $doc->findnodes('xpath_for_subtree_2')->get_node(1)->toString();

The PHP API should provide similar functions.


Michael Ludwig wrote:
I have a PHP/XSLT web application. It currently emits whole HTML pages.
In order to plug it into the Drupal CMS, I need to get hold of about
five subtrees of this HTML and then pass those on to Drupal as strings.

What is the best way to achieve this?

Newer versions of Saxon allow the user to pass an "initial mode" or
"initial template" as a parameter to the transformation. I don't think
this is possible with LibXSLT, but maybe it helps to illustrate what I'd
like to achieve.

I'm currently thinking one way to achieve what I want is to create
new DOMDocument objects to receive subtrees using a recursive call to
importNode(), and then to serialize those new documents.

Can you think of a better way?

Michael Ludwig
xslt mailing list, project page
xslt gnome org

aevum gmbh
rumfordstr. 4
80469 münchen

tel: +49 89 3838 0653

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]